MongoDB C++ Driver mongocxx-4.0.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 <memory>
18
26
29
31
32namespace mongocxx {
33namespace v_noabi {
34
42class cursor {
43 public:
44 enum class type { k_non_tailable, k_tailable, k_tailable_await };
45
46 class iterator;
47
52
56 MONGOCXX_ABI_EXPORT_CDECL(cursor&) operator=(cursor&&) noexcept;
57
62
63 cursor(const cursor&) = delete;
64 cursor& operator=(const cursor&) = delete;
65
81
89
90 private:
91 friend ::mongocxx::v_noabi::client_encryption;
92 friend ::mongocxx::v_noabi::client;
93 friend ::mongocxx::v_noabi::collection;
94 friend ::mongocxx::v_noabi::database;
95 friend ::mongocxx::v_noabi::index_view;
96 friend ::mongocxx::v_noabi::search_index_view;
97
98 friend ::mongocxx::v_noabi::cursor::iterator;
99
100 cursor(void* cursor_ptr,
101 bsoncxx::v_noabi::stdx::optional<type> cursor_type = bsoncxx::v_noabi::stdx::nullopt);
102
103 class impl;
104 std::unique_ptr<impl> _impl;
105};
106
126 public:
133 using iterator_category = std::input_iterator_tag;
134 using difference_type = std::ptrdiff_t;
135
140
145
152
159
160 private:
161 friend ::mongocxx::v_noabi::cursor;
162
174
175 bool is_exhausted() const;
176
177 explicit iterator(cursor* cursor);
178
179 // If this pointer is null, the iterator is considered "past-the-end".
180 cursor* _cursor;
181};
182
183} // namespace v_noabi
184} // namespace mongocxx
185
187
A read-only, non-owning view of a BSON document.
Definition view.hpp:35
Class supporting operations for MongoDB Client-Side Field Level Encryption.
Definition client_encryption.hpp:42
Class representing a client connection to MongoDB.
Definition client.hpp:61
Class representing server side document groupings within a MongoDB database.
Definition collection.hpp:87
Class representing an input iterator of documents in a MongoDB cursor result set.
Definition cursor.hpp:125
friend bool operator!=(const iterator &, const iterator &)
Compare two iterators for (in)-equality. Iterators compare equal if they point to the same underlying...
const bsoncxx::v_noabi::document::view & operator*() const
Dereferences the view for the document currently being pointed to.
const bsoncxx::v_noabi::document::view * operator->() const
Accesses a member of the dereferenced document currently being pointed to.
iterator & operator++()
Pre-increments the iterator to move to the next document.
friend bool operator==(const iterator &, const iterator &)
Compare two iterators for (in)-equality. Iterators compare equal if they point to the same underlying...
void operator++(int)
Post-increments the iterator to move to the next document.
Class representing a pointer to the result set of a query on a MongoDB server.
Definition cursor.hpp:42
iterator end()
A cursor::iterator indicating cursor exhaustion, meaning that no documents are available from the cur...
iterator begin()
A cursor::iterator that points to the beginning of any available results. If begin() is called more t...
Class representing a MongoDB database.
Definition database.hpp:46
Class representing a MongoDB index view.
Definition index_view.hpp:39
Class representing a MongoDB search index view.
Definition search_index_view.hpp:24
Declares mongocxx::v_noabi::client.
Declares mongocxx::v_noabi::client_encryption.
Declares mongocxx::v_noabi::collection.
Declares mongocxx::v_noabi::cursor.
Declares mongocxx::v_noabi::database.
Provides bsoncxx::v_noabi::document::view.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition fwd.hpp:204
Declares mongocxx::v_noabi::index_view.
The mongocxx macro guard postlude header.
The mongocxx macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
The top-level namespace within which all mongocxx library entities are declared.
The top-level namespace reserved for the C++ standard library.
Provides std::optional-related polyfills for library API usage.
Declares mongocxx::v_noabi::search_index_view.