MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
write_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/v1/write_concern-fwd.hpp> // IWYU pragma: export
18
19//
20
22
24
27
29
30#include <chrono>
31#include <cstdint>
32
33namespace mongocxx {
34namespace v1 {
35
50 private:
51 void* _impl; // mongoc_write_concern_t
52
53 public:
96
101
109
117
122
127
135
146
159
166
170 write_concern& majority(std::chrono::milliseconds v) {
172 }
173
179 MONGOCXX_ABI_EXPORT_CDECL(write_concern&) timeout(std::chrono::milliseconds v);
180
186 MONGOCXX_ABI_EXPORT_CDECL(std::chrono::milliseconds) timeout() const;
187
196
204
209
216
221
226
231
239
245
246 friend bool operator!=(write_concern const& lhs, write_concern const& rhs) {
247 return !(lhs == rhs);
248 }
249
251
252 class internal;
253
254 private:
255 /* explicit(false) */ write_concern(void* impl);
256};
257
258} // namespace v1
259} // namespace mongocxx
260
262
A BSON document.
Definition value.hpp:46
A polyfill for std::optional<T>.
Definition optional.hpp:799
A polyfill for std::string_view.
Definition string_view.hpp:412
write_concern & acknowledge_level(level v)
Set the "w" field as to acknowledgement level.
std::chrono::milliseconds timeout() const
Return the current "wtimeout" field.
friend bool operator!=(write_concern const &lhs, write_concern const &rhs)
Compare equal when all supported fields compare equal.
Definition write_concern.hpp:246
bsoncxx::v1::stdx::optional< bool > journal() const
Return the current "j" field.
level acknowledge_level() const
Return the current "w" field as an acknowledgement level.
write_concern & journal(bool j)
Set the "j" field.
write_concern(write_concern &&other) noexcept
Move constructor.
write_concern()
Default initialization.
bsoncxx::v1::document::value to_document() const
Return this write concern option as a document.
write_concern & tag(bsoncxx::v1::stdx::string_view v)
Set the "w" field to a custom write concern name.
write_concern & majority()
Equivalent to this->acknowledge_level(level::k_majority).
Definition write_concern.hpp:163
write_concern & timeout(std::chrono::milliseconds v)
Set the "wtimeout" field.
bsoncxx::v1::stdx::optional< bsoncxx::v1::stdx::string_view > tag() const
Return the current "w" value as a custom write concern name.
friend bool operator==(write_concern const &lhs, write_concern const &rhs)
Compare equal when all supported fields compare equal.
bool is_acknowledged() const
Return true when this write concern requires acknowledgement.
bsoncxx::v1::stdx::optional< std::int32_t > nodes() const
Return the current "w" field as an integer.
write_concern & majority(std::chrono::milliseconds v)
Equivalent to this->acknowledge_level(k_majority).timeout(timeout).
Definition write_concern.hpp:170
~write_concern()
Destroy this object.
write_concern & nodes(std::int32_t v)
Set the "w" field to an integer.
level
The write concern level.
Definition write_concern.hpp:62
@ k_unacknowledged
"w": 0
Definition write_concern.hpp:82
@ k_unknown
An unknown (unsupported) write concern level.
Definition write_concern.hpp:94
@ k_tag
"w": "<custom write concern name>"
Definition write_concern.hpp:77
@ k_acknowledged
"w": 1
Definition write_concern.hpp:87
@ k_majority
"w": "majority"
Definition write_concern.hpp:72
@ k_default
Default MongoDB Read Concerns/Write Concerns (MongoDB Manual)
Definition write_concern.hpp:67
Provides macros to control the set of symbols exported in the ABI.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v1 macro guard postlude header.
The mongocxx v1 macro guard prelude header.
Declares entities whose ABI stability is guaranteed for documented symbols.
The top-level namespace within which all mongocxx library entities are declared.
Declares bsoncxx::v1::document::value.
Provides std::optional-related polyfills for library API usage.
Provides std::string_view-related polyfills for library API usage.
Declares mongocxx::v1::write_concern.