MongoDB C++ Driver 4.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
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;
133 using value_type = bsoncxx::v_noabi::document::view const;
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(bsoncxx::v_noabi::document::view const&) operator*() const;
152
159 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::document::view const*) operator->() const;
160
175
189 MONGOCXX_ABI_EXPORT_CDECL(void) operator++(int);
190
200 friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator==(
201 change_stream::iterator const&,
202 change_stream::iterator const&) noexcept;
203
204 friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator!=(
205 change_stream::iterator const&,
206 change_stream::iterator const&) noexcept;
209
210 private:
211 friend ::mongocxx::v_noabi::change_stream;
212
213 enum class iter_type { k_tracking, k_default_constructed, k_end };
214
215 explicit iterator(iter_type type, change_stream const* change_stream);
216
217 bool is_exhausted() const;
218
219 // iter_type==k_default_constructed is equivalent to _change_stream==nullptr
220 iter_type _type;
221 change_stream const* _change_stream;
222};
223
224} // namespace v_noabi
225} // namespace mongocxx
226
228
Declares mongocxx::v_noabi::change_stream.
A read-only, non-owning view of a BSON document.
Definition view.hpp:35
A MongoDB change stream iterator.
Definition change_stream.hpp:129
iterator()
Default-construct an iterator. Default-constucted iterators can be compared (all default-constructed ...
change_stream(change_stream &&other) noexcept
Move constructs a change_stream.
A MongoDB change stream iterator.
Definition change_stream.hpp:129
iterator()
Default-construct an iterator. Default-constucted iterators can be compared (all default-constructed ...
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(...
change_stream(change_stream &&other) noexcept
Move constructs a change_stream.
A client connection to a MongoDB server.
Definition client.hpp:61
A MongoDB collection.
Definition collection.hpp:87
A MongoDB database.
Definition database.hpp:46
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 export.hpp:52
The mongocxx v_noabi macro guard postlude header.
The mongocxx v_noabi macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities whose ABI stability is NOT guaranteed.
The top-level namespace within which all mongocxx library entities are declared.
Provides std::optional-related polyfills for library API usage.