MongoDB C++ Driver  mongocxx-3.7.0
Public Types | Public Member Functions | List of all members
mongocxx::cursor::iterator Class Reference

Class representing an input iterator of documents in a MongoDB cursor result set. More...

#include <cursor.hpp>

Public Types

using value_type = bsoncxx::document::view
 std::iterator_traits
 

Public Member Functions

const bsoncxx::document::viewoperator* () const
 Dereferences the view for the document currently being pointed to.
 
const bsoncxx::document::viewoperator-> () const
 Accesses a member of the dereferenced document currently being pointed to.
 
iteratoroperator++ ()
 Pre-increments the iterator to move to the next document. More...
 
void operator++ (int)
 Post-increments the iterator to move to the next document. More...
 

Friends

bool operator== (const iterator &, const iterator &)
 Compare two iterators for (in)-equality. More...
 
bool operator!= (const iterator &, const iterator &)
 Compare two iterators for (in)-equality. More...
 

Detailed Description

Class representing an input iterator of documents in a MongoDB cursor result set.

All non-end iterators derived from the same mongocxx::cursor move in lock-step. Dereferencing any non-end() iterator always gives the first remaining document in the cursor. Incrementing one non-end iterator is equivalent to incrementing them all.

An iterator is 'exhausted' when no documents are available. An end-iterator is always exhausted. A non-end iterator is exhausted when the originating mongocxx::cursor has no more documents. When an iterator is exhausted, it must not be dereferenced or incremented.

For iterators of a tailable cursor, calling cursor.begin() may revive an exhausted iterator so that it no longer compares equal to the end-iterator.

Member Function Documentation

◆ operator++() [1/2]

iterator& mongocxx::cursor::iterator::operator++ ( )

Pre-increments the iterator to move to the next document.

Exceptions
mongocxx::query_exceptionif the query failed

◆ operator++() [2/2]

void mongocxx::cursor::iterator::operator++ ( int  )

Post-increments the iterator to move to the next document.

Exceptions
mongocxx::query_exceptionif the query failed

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const iterator ,
const iterator  
)
friend

Compare two iterators for (in)-equality.

Iterators compare equal if they point to the same underlying cursor or if both are exhausted.

◆ operator==

bool operator== ( const iterator ,
const iterator  
)
friend

Compare two iterators for (in)-equality.

Iterators compare equal if they point to the same underlying cursor or if both are exhausted.


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