MongoDB C++ Driver 4.4.0
Loading...
Searching...
No Matches
cursor.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <mongocxx/v1/cursor-fwd.hpp> // IWYU pragma: export
18
19//
20
22
24
26
27#include <cstddef>
28#include <iterator>
29
30namespace mongocxx {
31namespace v1 {
32
39class cursor {
40 private:
41 class impl;
42 void* _impl;
43
44 public:
67
68 class iterator;
69
76
84
91 MONGOCXX_ABI_EXPORT_CDECL(cursor&) operator=(cursor&& other) noexcept;
92
96 cursor(cursor const&) = delete;
97
101 cursor& operator=(cursor const&) = delete;
102
120
126 iterator end() const;
127
128 class internal;
129
130 private:
131 /* explicit(false) */ cursor(void* impl);
132};
133
148 private:
149 void* _impl; // v1::cursor
150
151 public:
155 using iterator_category = std::input_iterator_tag;
156
161
165 using difference_type = std::ptrdiff_t;
166
170 using pointer = value_type const*;
171
176
183
191
198 MONGOCXX_ABI_EXPORT_CDECL(iterator&) operator=(iterator&& other) noexcept;
199
204
208 MONGOCXX_ABI_EXPORT_CDECL(iterator&) operator=(iterator const& other);
209
214
219
229
244
246 iterator& operator++(int) {
247 return this->operator++();
248 }
249
258 friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator==(iterator const& lhs, iterator const& rhs);
259
263 friend bool operator!=(iterator const& lhs, iterator const& rhs) {
264 return !(lhs == rhs);
265 }
266
267 class internal;
268
269 private:
270 /* explicit(false) */ iterator(void* impl);
271};
272
274 return {};
275}
276
277} // namespace v1
278} // namespace mongocxx
279
281
A non-owning, read-only BSON document.
Definition view.hpp:52
An iterator over the results of an associated cursor.
Definition cursor.hpp:147
friend bool operator!=(iterator const &lhs, iterator const &rhs)
Equivalent to !(lhs == rhs).
Definition cursor.hpp:263
iterator & operator++()
Increment this iterator.
iterator(iterator &&other) noexcept
Move construction.
value_type const * pointer
Provide std::iterator_traits<T>::pointer.
Definition cursor.hpp:170
~iterator()
Destroy this object.
bsoncxx::v1::document::view value_type
Provide std::iterator_traits<T>::value_type.
Definition cursor.hpp:160
std::ptrdiff_t difference_type
Provide std::iterator_traits<T>::difference_type.
Definition cursor.hpp:165
std::input_iterator_tag iterator_category
Provide std::iterator_traits<T>::iterator_category.
Definition cursor.hpp:155
friend bool operator==(iterator const &lhs, iterator const &rhs)
Equality comparison.
value_type reference
Provide std::iterator_traits<T>::reference.
Definition cursor.hpp:175
cursor(cursor &&other) noexcept
Move constructor.
type
Enumeration identifying the type of the cursor.
Definition cursor.hpp:48
@ k_tailable_await
A tailable "awaitData" cursor.
Definition cursor.hpp:65
@ k_non_tailable
A non-tailable cursor.
Definition cursor.hpp:53
@ k_tailable
A tailable cursor.
Definition cursor.hpp:59
iterator end() const
Return an end iterator.
Definition cursor.hpp:273
iterator begin()
Return an iterator over the results of the associated cursor.
~cursor()
Destroy this object.
Provides macros to control the set of symbols exported in the ABI.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v1 macro guard postlude header.
The mongocxx v1 macro guard prelude header.
Declares entities whose ABI stability is guaranteed for documented symbols.
The top-level namespace within which all mongocxx library entities are declared.
Declares mongocxx::v1::cursor.
Declares bsoncxx::v1::document::view.