MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
read_concern.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/read_concern-fwd.hpp> // IWYU pragma: export
18
19//
20
21#include <mongocxx/v1/read_concern.hpp> // IWYU pragma: export
22
23#include <memory> // IWYU pragma: keep: backward compatibility, to be removed.
24#include <utility>
25
26#include <mongocxx/client-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
27#include <mongocxx/collection-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
28#include <mongocxx/database-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
29#include <mongocxx/options/transaction-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
30#include <mongocxx/uri-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
31
33#include <bsoncxx/stdx/optional.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
35
36#include <mongocxx/options/transaction.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
37
39
40namespace mongocxx {
41namespace v_noabi {
42
55 private:
57
58 public:
75
83 read_concern() = default;
84
88 /* explicit(false) */ read_concern(v1::read_concern rc) : _rc{std::move(rc)} {}
89
98 explicit operator v1::read_concern() && {
99 return std::move(_rc);
100 }
101
105 explicit operator v1::read_concern() const& {
106 return _rc;
107 }
108
120
130 return static_cast<level>(_rc.acknowledge_level());
131 }
132
143 _rc.acknowledge_string(rc_string);
144 }
145
155 auto ret = _rc.acknowledge_string();
156 if (ret.empty()) {
157 ret = "";
158 }
159 return ret;
160 }
161
169 return bsoncxx::v_noabi::from_v1(_rc.to_document());
170 }
171
178 friend bool operator==(read_concern const& lhs, read_concern const& rhs) {
179 return lhs.acknowledge_level() == rhs.acknowledge_level();
180 }
181
182 friend bool operator!=(read_concern const& lhs, read_concern const& rhs) {
183 return !(lhs == rhs);
184 }
185
187
188 class internal;
189};
190
195 return {std::move(v)};
196}
197
202 return v1::read_concern{std::move(v)};
203}
204
205} // namespace v_noabi
206} // namespace mongocxx
207
209
A polyfill for std::string_view.
Definition string_view.hpp:412
A read-only BSON document that owns its underlying buffer.
Definition value.hpp:48
read_concern()=default
Constructs a new read_concern with default acknowledge_level of k_server_default.
Options related to a MongoDB Read Concern.
Definition read_concern.hpp:44
Controls the consistency and isolation properties of data read from replica sets and sharded clusters...
Definition read_concern.hpp:54
level acknowledge_level() const
Gets the current read concern level.
Definition read_concern.hpp:129
bsoncxx::v1::stdx::string_view acknowledge_string() const
Gets the current read concern string.
Definition read_concern.hpp:154
level
A class to represent the read concern level for read operations.
Definition read_concern.hpp:66
@ k_unknown
Represent an unknown read concern level.
Definition read_concern.hpp:71
@ k_linearizable
Represent read concern level "linearizable".
Definition read_concern.hpp:69
@ k_server_default
Represent the server's default read concern level.
Definition read_concern.hpp:70
@ k_local
Represent read concern level "local".
Definition read_concern.hpp:67
@ k_snapshot
Represent read concern level "snapshot".
Definition read_concern.hpp:73
@ k_available
Represent read concern level "available".
Definition read_concern.hpp:72
@ k_majority
Represent read concern level "majority".
Definition read_concern.hpp:68
read_concern(v1::read_concern rc)
Construct with the mongocxx::v1 equivalent.
Definition read_concern.hpp:88
friend bool operator!=(read_concern const &lhs, read_concern const &rhs)
Compares two read_concern objects for (in)-equality.
Definition read_concern.hpp:182
void acknowledge_level(level rc_level)
Sets the read concern level.
void acknowledge_string(bsoncxx::v1::stdx::string_view rc_string)
Sets the read concern string. Any valid read concern string (e.g. "local", "majority",...
Definition read_concern.hpp:142
bsoncxx::v_noabi::document::value to_document() const
Gets the document form of this read_concern.
Definition read_concern.hpp:168
read_concern()=default
Constructs a new read_concern with default acknowledge_level of k_server_default.
friend bool operator==(read_concern const &lhs, read_concern const &rhs)
Compares two read_concern objects for (in)-equality.
Definition read_concern.hpp:178
#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::array::value from_v1(v1::array::value const &v)
Convert from the bsoncxx::v1 equivalent of v.
Definition value.hpp:267
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.
Declares mongocxx::v_noabi::options::transaction.
Provides mongocxx::v_noabi::options::transaction.
Provides mongocxx::v1::read_concern.
Provides bsoncxx::v_noabi::document::value.
Provides std::optional-related polyfills for library API usage.
Provides std::string_view-related polyfills for library API usage.
Declares mongocxx::v_noabi::client.
Declares mongocxx::v_noabi::collection.
Declares mongocxx::v_noabi::database.
Declares mongocxx::v_noabi::read_concern.
Declares mongocxx::v_noabi::uri.