MongoDB C++ Driver mongocxx-3.11.0
Loading...
Searching...
No Matches
change_stream.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
23
26
28
29namespace mongocxx {
30namespace v_noabi {
31
36 public:
38 class iterator;
39
44
49
54
76
85
110 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view>)
112
113 private:
114 friend ::mongocxx::v_noabi::client;
115 friend ::mongocxx::v_noabi::collection;
116 friend ::mongocxx::v_noabi::database;
117
118 friend ::mongocxx::v_noabi::change_stream::iterator;
119
120 change_stream(void* change_stream_ptr);
121
122 class impl;
123 std::unique_ptr<impl> _impl;
124};
125
130 public:
131 // Support input-iterator (caveat of post-increment returning void)
132 using difference_type = std::int64_t;
134 using pointer = std::add_pointer<value_type>::type;
135 using reference = std::add_lvalue_reference<value_type>::type;
136 using iterator_category = std::input_iterator_tag;
137
144
151 MONGOCXX_ABI_EXPORT_CDECL(const bsoncxx::v_noabi::document::view&) operator*() const;
152
159 MONGOCXX_ABI_EXPORT_CDECL(const bsoncxx::v_noabi::document::view*) operator->() const;
160
175
189 MONGOCXX_ABI_EXPORT_CDECL(void) operator++(int);
190
200 friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator==(const change_stream::iterator&,
201 const change_stream::iterator&) noexcept;
202
203 friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator!=(const change_stream::iterator&,
204 const change_stream::iterator&) noexcept;
207
208 private:
209 friend ::mongocxx::v_noabi::change_stream;
210
211 enum class iter_type { k_tracking, k_default_constructed, k_end };
212
213 explicit iterator(iter_type type, const change_stream* change_stream);
214
215 bool is_exhausted() const;
216
217 // iter_type==k_default_constructed is equivalent to _change_stream==nullptr
218 iter_type _type;
219 const change_stream* _change_stream;
220};
221
222} // namespace v_noabi
223} // namespace mongocxx
224
226
Declares mongocxx::v_noabi::change_stream.
A read-only, non-owning view of a BSON document.
Definition view.hpp:35
Class representing a MongoDB change stream iterator.
Definition change_stream.hpp:129
Class representing a MongoDB change stream.
Definition change_stream.hpp:35
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view > get_resume_token() const
Returns a resume token for this change stream.
iterator end() const
A change_stream::iterator indicating stream exhaustion, meaning that no notifications are available f...
iterator begin() const
A change_stream::iterator points to the beginning of any available notifications. Each call to begin(...
Class representing a client connection to MongoDB.
Definition client.hpp:62
Class representing server side document groupings within a MongoDB database.
Definition collection.hpp:87
Class representing a MongoDB database.
Definition database.hpp:47
Declares mongocxx::v_noabi::client.
Declares mongocxx::v_noabi::collection.
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:222
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.