MongoDB C++ Driver 4.2.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 <mongocxx/options/change_stream-fwd.hpp> // IWYU pragma: export
18
19//
20
22
23#include <mongocxx/v1/change_stream.hpp> // IWYU pragma: export
24
25#include <chrono>
26#include <cstdint>
27#include <string>
28#include <utility>
29
30#include <mongocxx/client-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
31#include <mongocxx/collection-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
32#include <mongocxx/database-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
33
39#include <bsoncxx/types.hpp>
42
44
45namespace mongocxx {
46namespace v_noabi {
47namespace options {
48
53 public:
57 change_stream() = default;
58
63
67 explicit operator v1::change_stream::options() const {
69
71
72 if (_full_document) {
73 ret.full_document(std::string{_full_document->view()});
74 }
75
76 if (_full_document_before_change) {
77 ret.full_document_before_change(std::string{_full_document_before_change->view()});
78 }
79
80 if (_batch_size) {
81 ret.batch_size(*_batch_size);
82 }
83
84 if (_comment) {
85 ret.comment(bsoncxx::v1::types::value{{to_v1(_comment->view())}});
86 }
87
88 if (_collation) {
89 ret.collation(bsoncxx::v1::document::value{to_v1(_collation->view())});
90 }
91
92 if (_resume_after) {
93 ret.resume_after(bsoncxx::v1::document::value{to_v1(_resume_after->view())});
94 }
95
96 if (_start_after) {
97 ret.start_after(bsoncxx::v1::document::value{to_v1(_start_after->view())});
98 }
99
100 if (_max_await_time) {
101 ret.max_await_time(*_max_await_time);
102 }
103
104 if (_start_at_operation_time) {
105 ret.start_at_operation_time(to_v1(*_start_at_operation_time));
106 }
107
108 return ret;
109 }
110
139 _full_document = std::move(full_doc);
140 return *this;
141 }
142
152
173 _full_document_before_change = std::move(full_doc_before_change);
174 return *this;
175 }
176
184 const {
185 return _full_document_before_change;
186 }
187
199 _batch_size = batch_size;
200 return *this;
201 }
202
210 return _batch_size;
211 }
212
224 _comment = std::move(comment);
225 return *this;
226 }
227
237
254 _resume_after = std::move(resume_after);
255 return *this;
256 }
257
267
286 _start_after = std::move(token);
287 return *this;
288 }
289
299
311 _collation = std::move(collation);
312 return *this;
313 }
314
324
336 change_stream& max_await_time(std::chrono::milliseconds max_time) {
337 _max_await_time = max_time;
338 return *this;
339 }
340
348 return _max_await_time;
349 }
350
366 _start_at_operation_time = std::move(timestamp);
367 return *this;
368 }
369
377 return _start_at_operation_time;
378 }
379
380 class internal;
381
382 private:
392};
393
394} // namespace options
395} // namespace v_noabi
396} // namespace mongocxx
397
398namespace mongocxx {
399namespace v_noabi {
400
405 return {std::move(v)};
406}
407
414
415} // namespace v_noabi
416} // namespace mongocxx
417
419
A BSON document.
Definition value.hpp:46
A polyfill for std::optional<T>.
Definition optional.hpp:799
A union of BSON type values.
Definition value.hpp:54
A view-or-value variant type for strings.
Definition view_or_value.hpp:41
change_stream()=default
Default initialization.
Options for mongocxx::v1::change_stream.
Definition change_stream.hpp:174
options & collation(bsoncxx::v1::document::value v)
Set the "collation" option.
options & batch_size(std::int32_t v)
Set the "batchSize" option.
options & start_at_operation_time(bsoncxx::v1::types::b_timestamp v)
Set the "startAtOperationTime" option.
options & resume_after(bsoncxx::v1::document::value v)
Set the "resumeAfter" option.
options & start_after(bsoncxx::v1::document::value v)
Set the "startAfter" option.
options & max_await_time(std::chrono::milliseconds v)
Set the "maxAwaitTimeMS" option.
options & comment(bsoncxx::v1::types::value v)
Set the "comment" option.
options & full_document_before_change(std::string v)
Set the "fullDocumentBeforeChange" option.
options & full_document(std::string v)
Set the "fullDocument" option.
Used by change streams.
Definition change_stream.hpp:52
bsoncxx::v_noabi::stdx::optional< std::chrono::milliseconds > const & max_await_time() const
The current max_time setting.
Definition change_stream.hpp:347
change_stream & resume_after(bsoncxx::v_noabi::document::view_or_value resume_after)
Specifies the logical starting point for the new change stream.
Definition change_stream.hpp:253
change_stream & batch_size(std::int32_t batch_size)
Sets the number of documents to return per batch.
Definition change_stream.hpp:198
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::types::bson_value::view_or_value > const & comment() const
Gets the current value of the comment option.
Definition change_stream.hpp:234
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::string::view_or_value > const & full_document() const
Gets the current fullDocument option.
Definition change_stream.hpp:149
change_stream & start_after(bsoncxx::v_noabi::document::view_or_value token)
Specifies the logical starting point of the new change stream. The new stream will return the first n...
Definition change_stream.hpp:285
bsoncxx::v_noabi::stdx::optional< std::int32_t > const & batch_size() const
The current batch size setting.
Definition change_stream.hpp:209
change_stream & start_at_operation_time(bsoncxx::v_noabi::types::b_timestamp timestamp)
Specifies the logical starting point for the new change stream. Changes are returned at or after the ...
Definition change_stream.hpp:365
change_stream & max_await_time(std::chrono::milliseconds max_time)
Sets the maximum amount of time for for the server to wait on new documents to satisfy a change strea...
Definition change_stream.hpp:336
change_stream & full_document(bsoncxx::v_noabi::string::view_or_value full_doc)
Sets the fullDocument option for the $changeStream.
Definition change_stream.hpp:138
change_stream & collation(bsoncxx::v_noabi::document::view_or_value collation)
Sets the collation for this operation.
Definition change_stream.hpp:310
change_stream & full_document_before_change(bsoncxx::v_noabi::string::view_or_value full_doc_before_change)
Sets the fullDocumentBeforeChange option for the $changeStream.
Definition change_stream.hpp:172
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & collation() const
Retrieves the current collation for this operation.
Definition change_stream.hpp:321
operator v1::change_stream::options() const
Convert to the mongocxx::v1 equivalent.
Definition change_stream.hpp:67
change_stream()=default
Default initialization.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::string::view_or_value > const & full_document_before_change() const
Gets the current fullDocumentBeforeChange option.
Definition change_stream.hpp:183
change_stream & comment(bsoncxx::v_noabi::types::bson_value::view_or_value comment)
Sets the current value of the comment option.
Definition change_stream.hpp:223
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & start_after() const
Retrieves the current startAfter token for this change stream.
Definition change_stream.hpp:296
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & resume_after() const
Retrieves the current resumeToken for this change stream.
Definition change_stream.hpp:264
bsoncxx::stdx::optional< bsoncxx::v_noabi::types::b_timestamp > const & start_at_operation_time() const
The current start_at_operation_time setting.
Definition change_stream.hpp:376
Provides bsoncxx::v_noabi::document::view_or_value.
#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.
v_noabi::view_or_value< v_noabi::document::view, v_noabi::document::value > view_or_value
Equivalent to v_noabi::view_or_value<v_noabi::document::view, v_noabi::document::value>.
Definition view_or_value.hpp:30
v_noabi::view_or_value< view, value > view_or_value
Equivalent to v_noabi::view_or_value<view, value>.
Definition view_or_value.hpp:31
v1::element::view to_v1(v_noabi::array::element const &v)
Convert to the bsoncxx::v1 equivalent of v.
Definition element.hpp:132
Declares entities whose ABI stability is guaranteed for documented symbols.
Declares entities representing options to use with various commands.
Declares entities whose ABI stability is NOT guaranteed.
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
The top-level namespace within which all mongocxx library entities are declared.
Provides bsoncxx::v_noabi::string::view_or_value.
A BSON replication timestamp value.
Definition types.hpp:601
Provides bsoncxx::v_noabi::types::bson_value::view_or_value.
Provides entities used to represent BSON types.
Provides mongocxx::v1::change_stream.
Provides bsoncxx::v1::types::value.
Provides bsoncxx::v_noabi::document::value.
Provides bsoncxx::v_noabi::document::view.
Provides std::optional-related polyfills for library API usage.
Provides bsoncxx::v_noabi::types::bson_value::view.
Declares mongocxx::v_noabi::client.
Declares mongocxx::v_noabi::collection.
Declares mongocxx::v_noabi::database.
Declares mongocxx::v_noabi::options::change_stream.