Loading...
Searching...
No Matches
change_stream.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/options/change_stream-fwd.hpp> // IWYU pragma: export
//
#include <bsoncxx/v1/types/value.hpp>
#include <mongocxx/v1/change_stream.hpp> // IWYU pragma: export
#include <chrono>
#include <cstdint>
#include <string>
#include <utility>
#include <mongocxx/client-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/collection-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/database-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/document/value.hpp>
#include <bsoncxx/document/view.hpp>
#include <bsoncxx/document/view_or_value.hpp>
#include <bsoncxx/stdx/optional.hpp>
#include <bsoncxx/string/view_or_value.hpp>
#include <bsoncxx/types.hpp>
#include <bsoncxx/types/bson_value/view.hpp>
#include <bsoncxx/types/bson_value/view_or_value.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
namespace options {
class change_stream {
public:
change_stream() = default;
/* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() change_stream(v1::change_stream::options opts);
explicit operator v1::change_stream::options() const {
using bsoncxx::v_noabi::to_v1;
v1::change_stream::options ret;
if (_full_document) {
ret.full_document(std::string{_full_document->view()});
}
if (_full_document_before_change) {
ret.full_document_before_change(std::string{_full_document_before_change->view()});
}
if (_batch_size) {
ret.batch_size(*_batch_size);
}
if (_comment) {
ret.comment(bsoncxx::v1::types::value{{to_v1(_comment->view())}});
}
if (_collation) {
ret.collation(bsoncxx::v1::document::value{to_v1(_collation->view())});
}
if (_resume_after) {
ret.resume_after(bsoncxx::v1::document::value{to_v1(_resume_after->view())});
}
if (_start_after) {
ret.start_after(bsoncxx::v1::document::value{to_v1(_start_after->view())});
}
if (_max_await_time) {
ret.max_await_time(*_max_await_time);
}
if (_start_at_operation_time) {
ret.start_at_operation_time(to_v1(*_start_at_operation_time));
}
return ret;
}
change_stream& full_document(bsoncxx::v_noabi::string::view_or_value full_doc) {
_full_document = std::move(full_doc);
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> const& full_document() const {
return _full_document;
}
change_stream& full_document_before_change(bsoncxx::v_noabi::string::view_or_value full_doc_before_change) {
_full_document_before_change = std::move(full_doc_before_change);
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> const& full_document_before_change()
const {
return _full_document_before_change;
}
change_stream& batch_size(std::int32_t batch_size) {
_batch_size = batch_size;
return *this;
}
bsoncxx::v_noabi::stdx::optional<std::int32_t> const& batch_size() const {
return _batch_size;
}
change_stream& comment(bsoncxx::v_noabi::types::bson_value::view_or_value comment) {
_comment = std::move(comment);
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const& comment() const {
return _comment;
}
change_stream& resume_after(bsoncxx::v_noabi::document::view_or_value resume_after) {
_resume_after = std::move(resume_after);
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> const& resume_after() const {
return _resume_after;
}
change_stream& start_after(bsoncxx::v_noabi::document::view_or_value token) {
_start_after = std::move(token);
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> const& start_after() const {
return _start_after;
}
change_stream& collation(bsoncxx::v_noabi::document::view_or_value collation) {
_collation = std::move(collation);
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> const& collation() const {
return _collation;
}
change_stream& max_await_time(std::chrono::milliseconds max_time) {
_max_await_time = max_time;
return *this;
}
bsoncxx::v_noabi::stdx::optional<std::chrono::milliseconds> const& max_await_time() const {
return _max_await_time;
}
change_stream& start_at_operation_time(bsoncxx::v_noabi::types::b_timestamp timestamp) {
_start_at_operation_time = std::move(timestamp);
return *this;
}
bsoncxx::stdx::optional<bsoncxx::v_noabi::types::b_timestamp> const& start_at_operation_time() const {
return _start_at_operation_time;
}
class internal;
private:
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> _full_document;
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> _full_document_before_change;
bsoncxx::v_noabi::stdx::optional<std::int32_t> _batch_size;
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> _comment;
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> _collation;
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> _resume_after;
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> _start_after;
bsoncxx::v_noabi::stdx::optional<std::chrono::milliseconds> _max_await_time;
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::b_timestamp> _start_at_operation_time;
};
} // namespace options
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::options::change_stream from_v1(v1::change_stream::options v) {
return {std::move(v)};
}
inline v1::change_stream::options to_v1(v_noabi::options::change_stream const& v) {
return v1::change_stream::options{v};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
bsoncxx::v1::document::value
A BSON document.
Definition value.hpp:44
bsoncxx::v1::stdx::optional
A polyfill for std::optional<T>.
Definition optional.hpp:799
bsoncxx::v1::types::value
A union of BSON type values.
Definition value.hpp:52
bsoncxx::v_noabi::string::view_or_value
A view-or-value variant type for strings.
Definition view_or_value.hpp:41
mongocxx::options::change_stream::change_stream
change_stream()=default
Default initialization.
mongocxx::v1::change_stream::options
Options for mongocxx::v1::change_stream.
Definition change_stream.hpp:170
mongocxx::v1::change_stream::options::collation
options & collation(bsoncxx::v1::document::value v)
Set the "collation" option.
mongocxx::v1::change_stream::options::batch_size
options & batch_size(std::int32_t v)
Set the "batchSize" option.
mongocxx::v1::change_stream::options::start_at_operation_time
options & start_at_operation_time(bsoncxx::v1::types::b_timestamp v)
Set the "startAtOperationTime" option.
mongocxx::v1::change_stream::options::resume_after
options & resume_after(bsoncxx::v1::document::value v)
Set the "resumeAfter" option.
mongocxx::v1::change_stream::options::start_after
options & start_after(bsoncxx::v1::document::value v)
Set the "startAfter" option.
mongocxx::v1::change_stream::options::max_await_time
options & max_await_time(std::chrono::milliseconds v)
Set the "maxAwaitTimeMS" option.
mongocxx::v1::change_stream::options::comment
options & comment(bsoncxx::v1::types::value v)
Set the "comment" option.
mongocxx::v1::change_stream::options::full_document_before_change
options & full_document_before_change(std::string v)
Set the "fullDocumentBeforeChange" option.
mongocxx::v1::change_stream::options::full_document
options & full_document(std::string v)
Set the "fullDocument" option.
mongocxx::v_noabi::options::change_stream
Used by change streams.
Definition change_stream.hpp:52
mongocxx::v_noabi::options::change_stream::max_await_time
bsoncxx::v_noabi::stdx::optional< std::chrono::milliseconds > const & max_await_time() const
The current max_time setting.
Definition change_stream.hpp:347
mongocxx::v_noabi::options::change_stream::resume_after
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
mongocxx::v_noabi::options::change_stream::batch_size
change_stream & batch_size(std::int32_t batch_size)
Sets the number of documents to return per batch.
Definition change_stream.hpp:198
mongocxx::v_noabi::options::change_stream::comment
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
mongocxx::v_noabi::options::change_stream::full_document
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
mongocxx::v_noabi::options::change_stream::start_after
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
mongocxx::v_noabi::options::change_stream::batch_size
bsoncxx::v_noabi::stdx::optional< std::int32_t > const & batch_size() const
The current batch size setting.
Definition change_stream.hpp:209
mongocxx::v_noabi::options::change_stream::start_at_operation_time
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
mongocxx::v_noabi::options::change_stream::max_await_time
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
mongocxx::v_noabi::options::change_stream::full_document
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
mongocxx::v_noabi::options::change_stream::collation
change_stream & collation(bsoncxx::v_noabi::document::view_or_value collation)
Sets the collation for this operation.
Definition change_stream.hpp:310
mongocxx::v_noabi::options::change_stream::full_document_before_change
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
mongocxx::v_noabi::options::change_stream::collation
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
mongocxx::v_noabi::options::change_stream::options
operator v1::change_stream::options() const
Convert to the mongocxx::v1 equivalent.
Definition change_stream.hpp:67
mongocxx::v_noabi::options::change_stream::change_stream
change_stream()=default
Default initialization.
mongocxx::v_noabi::options::change_stream::full_document_before_change
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
mongocxx::v_noabi::options::change_stream::comment
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
mongocxx::v_noabi::options::change_stream::start_after
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
mongocxx::v_noabi::options::change_stream::resume_after
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
mongocxx::v_noabi::options::change_stream::start_at_operation_time
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
view_or_value.hpp
Provides bsoncxx::v_noabi::document::view_or_value.
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE
#define MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to MONGOCXX_ABI_EXPORT_UNSTABLE with MONGOCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The mongocxx v_noabi macro guard postlude header.
prelude.hpp
The mongocxx v_noabi macro guard prelude header.
bsoncxx::v_noabi::document::view_or_value
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
bsoncxx::v_noabi::types::bson_value::view_or_value
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
bsoncxx::v_noabi::to_v1
v1::element::view to_v1(v_noabi::array::element const &v)
Convert to the bsoncxx::v1 equivalent of v.
Definition element.hpp:132
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx::v_noabi::options
Declares entities representing options to use with various commands.
mongocxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
mongocxx::v_noabi::to_v1
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
mongocxx::v_noabi::from_v1
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
view_or_value.hpp
Provides bsoncxx::v_noabi::string::view_or_value.
bsoncxx::v_noabi::types::b_timestamp
A BSON replication timestamp value.
Definition types.hpp:601
view_or_value.hpp
Provides bsoncxx::v_noabi::types::bson_value::view_or_value.
types.hpp
Provides entities used to represent BSON types.
change_stream.hpp
Provides mongocxx::v1::change_stream.
value.hpp
Provides bsoncxx::v1::types::value.
value.hpp
Provides bsoncxx::v_noabi::document::value.
view.hpp
Provides bsoncxx::v_noabi::document::view.
optional.hpp
Provides std::optional-related polyfills for library API usage.
view.hpp
Provides bsoncxx::v_noabi::types::bson_value::view.
client-fwd.hpp
Declares mongocxx::v_noabi::client.
collection-fwd.hpp
Declares mongocxx::v_noabi::collection.
database-fwd.hpp
Declares mongocxx::v_noabi::database.
change_stream-fwd.hpp
Declares mongocxx::v_noabi::options::change_stream.