MongoDB C++ Driver 4.2.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
41class cursor {
42 private:
43 class impl;
44 void* _impl;
45
46 public:
69
70 class iterator;
71
78
86
93 MONGOCXX_ABI_EXPORT_CDECL(cursor&) operator=(cursor&& other) noexcept;
94
98 cursor(cursor const&) = delete;
99
103 cursor& operator=(cursor const&) = delete;
104
122
128 iterator end() const;
129
130 class internal;
131
132 private:
133 /* explicit(false) */ cursor(void* impl);
134};
135
152 private:
153 void* _impl; // v1::cursor
154
155 public:
159 using iterator_category = std::input_iterator_tag;
160
165
169 using difference_type = std::ptrdiff_t;
170
174 using pointer = value_type const*;
175
180
187
195
202 MONGOCXX_ABI_EXPORT_CDECL(iterator&) operator=(iterator&& other) noexcept;
203
208
212 MONGOCXX_ABI_EXPORT_CDECL(iterator&) operator=(iterator const& other);
213
218
223
233
248
250 iterator& operator++(int) {
251 return this->operator++();
252 }
253
262 friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator==(iterator const& lhs, iterator const& rhs);
263
267 friend bool operator!=(iterator const& lhs, iterator const& rhs) {
268 return !(lhs == rhs);
269 }
270
271 class internal;
272
273 private:
274 /* explicit(false) */ iterator(void* impl);
275};
276
278 return {};
279}
280
281} // namespace v1
282} // namespace mongocxx
283
285
A non-owning, read-only BSON document.
Definition view.hpp:54
An iterator over the results of an associated cursor.
Definition cursor.hpp:151
friend bool operator!=(iterator const &lhs, iterator const &rhs)
Equivalent to !(lhs == rhs).
Definition cursor.hpp:267
iterator & operator++()
Increment this iterator.
iterator(iterator &&other) noexcept
Move construction.
value_type const * pointer
Provide std::iterator_traits<T>::pointer.
Definition cursor.hpp:174
~iterator()
Destroy this object.
bsoncxx::v1::document::view value_type
Provide std::iterator_traits<T>::value_type.
Definition cursor.hpp:164
std::ptrdiff_t difference_type
Provide std::iterator_traits<T>::difference_type.
Definition cursor.hpp:169
std::input_iterator_tag iterator_category
Provide std::iterator_traits<T>::iterator_category.
Definition cursor.hpp:159
friend bool operator==(iterator const &lhs, iterator const &rhs)
Equality comparison.
value_type reference
Provide std::iterator_traits<T>::reference.
Definition cursor.hpp:179
cursor(cursor &&other) noexcept
Move constructor.
type
Enumeration identifying the type of the cursor.
Definition cursor.hpp:50
@ k_tailable_await
A tailable "awaitData" cursor.
Definition cursor.hpp:67
@ k_non_tailable
A non-tailable cursor.
Definition cursor.hpp:55
@ k_tailable
A tailable cursor.
Definition cursor.hpp:61
iterator end() const
Return an end iterator.
Definition cursor.hpp:277
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.