17 #include <mangrove/config/prelude.hpp> 21 #include <bsoncxx/builder/basic/document.hpp> 22 #include <bsoncxx/stdx/optional.hpp> 23 #include <mongocxx/cursor.hpp> 25 #include <boson/mapping_functions.hpp> 28 MANGROVE_INLINE_NAMESPACE_BEGIN
45 return iterator(_c.begin(), _c.end());
59 iterator(mongocxx::cursor::iterator ci, mongocxx::cursor::iterator ci_end)
60 : _ci(ci), _ci_end(ci_end) {
61 skip_invalid_documents();
65 skip_invalid_documents();
70 _opt = mongocxx::stdx::nullopt;
71 skip_invalid_documents();
75 void operator++(
int) {
79 bool operator==(
const iterator& rhs) {
80 return _ci == rhs._ci;
83 bool operator!=(
const iterator& rhs) {
84 return _ci != rhs._ci;
96 mongocxx::cursor::iterator _ci;
98 mongocxx::cursor::iterator _ci_end;
101 mongocxx::stdx::optional<T> _opt;
111 void skip_invalid_documents() {
112 while (_ci != _ci_end) {
115 _opt = boson::to_obj<T>(*_ci);
120 _opt = mongocxx::stdx::nullopt;
126 MANGROVE_INLINE_NAMESPACE_END
129 #include <mangrove/config/postlude.hpp> An exception class thrown when things go wrong at runtime.
Definition: bson_archiver.hpp:75
Definition: deserializing_cursor.hpp:57
A class that wraps a mongocxx::cursor.
Definition: deserializing_cursor.hpp:37
Definition: collection_wrapper.hpp:28
T operator*()
Returns a deserialized object that corresponds to the current document pointed to by the underlying c...
Definition: deserializing_cursor.hpp:91