Loading...
Searching...
No Matches
mongocxx::v1::change_stream::iterator Class Reference

`#include <mongocxx/v1/change_stream.hpp>`

## Description

An iterator over change stream events.

Important
  All iterators associated with the same change stream object share the same state.
  The end iterator has no associated change stream.

Note
  This iterator almost satisfies Cpp17ForwardIterator, but std::iterator_traits<T>::reference is defined as value_type, similar to std::vector<bool>::iterator and std::istreambuf_iterator<T>. Therefore, this iterator only fully satisfies Cpp17InputIterator.

See also
  - Change Streams (MongoDB Manual)

## Public Types

using | difference_type = std::ptrdiff_t
| Provide std::iterator_traits<T>::difference_type.
using | iterator_category = std::input_iterator_tag
| Provide std::iterator_traits<T>::iterator_category.
using | pointer = value_type const*
| Provide std::iterator_traits<T>::pointer.
using | reference = value_type
| Provide std::iterator_traits<T>::reference.
using | value_type = bsoncxx::v1::document::view
| Provide std::iterator_traits<T>::value_type.

## Public Member Functions

| iterator ()
| Initialize as an end iterator.
| iterator (iterator &&other) noexcept
| Move construction.
| iterator (iterator const &other)
| Copy construction.
| ~iterator ()
| Destroy this object.
value_type | operator* () const
| Return the current event document.
iterator & | operator++ ()
| Increment this iterator.
iterator & | operator++ (int)
| Increment this iterator.
pointer | operator-> () const
| Access the current event document.
iterator & | operator= (iterator &&other) noexcept
| Move assignment.
iterator & | operator= (iterator const &other)
| Copy assignment.

## Friends

bool | operator!= (iterator const &lhs, iterator const &rhs)
| Equivalent to !(lhs == rhs).
bool | operator== (iterator const &lhs, iterator const &rhs)
| Equality comparison.

## Member Typedef Documentation

## difference_type

using mongocxx::v1::change_stream::iterator::difference_type = std::ptrdiff_t

Provide std::iterator_traits<T>::difference_type.

## iterator_category

using mongocxx::v1::change_stream::iterator::iterator_category = std::input_iterator_tag

Provide std::iterator_traits<T>::iterator_category.

## pointer

using mongocxx::v1::change_stream::iterator::pointer = value_type const*

Provide std::iterator_traits<T>::pointer.

## reference

using mongocxx::v1::change_stream::iterator::reference = value_type

Provide std::iterator_traits<T>::reference.

## value_type

using mongocxx::v1::change_stream::iterator::value_type = bsoncxx::v1::document::view

Provide std::iterator_traits<T>::value_type.

## Constructor & Destructor Documentation

## ~iterator()

mongocxx::v1::change_stream::iterator::~iterator | ( |  | ) |

Destroy this object.

Warning
  Invalidates all associated views.

## iterator() [1/3]

mongocxx::v1::change_stream::iterator::iterator | ( | iterator && | other | ) |

noexcept

Move construction.

Postconditions:
  - other is in an assign-or-destroy-only state.

## iterator() [2/3]

mongocxx::v1::change_stream::iterator::iterator | ( | iterator const & | other | ) |

Copy construction.

## iterator() [3/3]

mongocxx::v1::change_stream::iterator::iterator | ( |  | ) |

Initialize as an end iterator.

## Member Function Documentation

## operator*()

value_type mongocxx::v1::change_stream::iterator::operator* | ( |  | ) | const

Return the current event document.

Returns
  Empty when there is no event document available.

## operator++() [1/2]

iterator & mongocxx::v1::change_stream::iterator::operator++ | ( |  | ) |

Increment this iterator.

Advance the underlying cursor to obtain the next event document. Compare equal to the end iterator when there are no event documents available.

Note
  Pre-increment, post-increment, and v1::change_stream::next() are equivalent.

Warning
  Invalidates all views to the current event document and resume token.

Exceptions

  mongocxx::v1::server_error | when a server-side error is encountered and a raw server error is available.
  mongocxx::v1::exception | for all other runtime errors.

## operator++() [2/2]

iterator & mongocxx::v1::change_stream::iterator::operator++ | ( | int |  | ) |

inline

Increment this iterator.

Advance the underlying cursor to obtain the next event document. Compare equal to the end iterator when there are no event documents available.

Note
  Pre-increment, post-increment, and v1::change_stream::next() are equivalent.

Warning
  Invalidates all views to the current event document and resume token.

Exceptions

  mongocxx::v1::server_error | when a server-side error is encountered and a raw server error is available.
  mongocxx::v1::exception | for all other runtime errors.

## operator->()

pointer mongocxx::v1::change_stream::iterator::operator-> | ( |  | ) | const

Access the current event document.

Preconditions:
  - *this does not compare equal to the end iterator.

## operator=() [1/2]

iterator & mongocxx::v1::change_stream::iterator::operator= | ( | iterator && | other | ) |

noexcept

Move assignment.

Postconditions:
  - other is in an assign-or-destroy-only state.

## operator=() [2/2]

iterator & mongocxx::v1::change_stream::iterator::operator= | ( | iterator const & | other | ) |

Copy assignment.

## Friends And Related Symbol Documentation

## operator!=

bool operator!= | ( | iterator const & | lhs,
|  | iterator const & | rhs )

friend

Equivalent to !(lhs == rhs).

## operator==

bool operator== | ( | iterator const & | lhs,
|  | iterator const & | rhs )

friend

Equality comparison.

lhs and rhs compare equal when:

- both are associated with the same change stream object, or
- both are end iterators, or
- one is an end iterator and the other has no event document available.

The documentation for this class was generated from the following file:

- mongocxx/v1/change_stream.hpp