MongoDB C++ Driver 4.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 <chrono>
18#include <cstdint>
19#include <memory>
20#include <stdexcept>
21#include <string>
22
28#include <mongocxx/uri-fwd.hpp>
30
34
36
38
39namespace mongocxx {
40namespace v_noabi {
41
49 public:
64
69
74
79
84
89
94
104
120 MONGOCXX_ABI_EXPORT_CDECL(void) nodes(std::int32_t confirm_from);
121
147
158 MONGOCXX_ABI_EXPORT_CDECL(void) majority(std::chrono::milliseconds timeout);
159
169 MONGOCXX_ABI_EXPORT_CDECL(void) tag(bsoncxx::v_noabi::stdx::string_view tag);
170
181 MONGOCXX_ABI_EXPORT_CDECL(void) timeout(std::chrono::milliseconds timeout);
182
189
201 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::int32_t>) nodes() const;
202
212
218 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::string>) tag() const;
219
226
232 MONGOCXX_ABI_EXPORT_CDECL(std::chrono::milliseconds) timeout() const;
233
240
248
255 friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator==(write_concern const&, write_concern const&);
256 friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator!=(write_concern const&, write_concern const&);
259
260 private:
261 friend ::mongocxx::v_noabi::bulk_write;
262 friend ::mongocxx::v_noabi::client;
263 friend ::mongocxx::v_noabi::collection;
264 friend ::mongocxx::v_noabi::database;
265 friend ::mongocxx::v_noabi::options::transaction;
266 friend ::mongocxx::v_noabi::uri;
267
268 class impl;
269
270 write_concern(std::unique_ptr<impl>&& implementation);
271
272 std::unique_ptr<impl> _impl;
273};
274
275} // namespace v_noabi
276} // namespace mongocxx
277
278#include <mongocxx/config/postlude.hpp>
279
Declares mongocxx::v_noabi::bulk_write.
A batch of write operations that can be sent to the server as a group.
Definition bulk_write.hpp:45
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
A MongoDB connection string URI.
Definition uri.hpp:43
bool is_acknowledged() const
Gets whether this write_concern requires an acknowledged write.
void majority(std::chrono::milliseconds timeout)
Requires that a majority of the nodes in a replica set acknowledge a write operation before it is con...
void timeout(std::chrono::milliseconds timeout)
Sets an upper bound on the time a write concern can take to be satisfied. If the write concern cannot...
level
A class to represent the write concern level for write operations.
Definition write_concern.hpp:57
@ k_unacknowledged
Represent write concern with w: 0.
Definition write_concern.hpp:61
@ k_tag
Represent write concern with w: <custom write concern name>.
Definition write_concern.hpp:60
@ k_acknowledged
Represent write concern with w: 1.
Definition write_concern.hpp:62
@ k_majority
Represent write concern with w: "majority".
Definition write_concern.hpp:59
@ k_default
Represent the implicit default write concern.
Definition write_concern.hpp:58
void journal(bool journal)
Sets the journal parameter for this write concern.
void acknowledge_level(level confirm_level)
Sets the acknowledge level.
void nodes(std::int32_t confirm_from)
Sets the number of nodes that are required to acknowledge the write before the operation is considere...
bsoncxx::v_noabi::document::value to_document() const
Gets the document form of this write_concern.
void tag(bsoncxx::v_noabi::stdx::string_view tag)
Sets the name representing the server-side getLastErrorMode entry containing the list of nodes that m...
write_concern()
Constructs a new write_concern.
Declares mongocxx::v_noabi::client.
Declares mongocxx::v_noabi::collection.
Declares mongocxx::v_noabi::database.
Provides bsoncxx::v_noabi::document::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 prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities representing options to use with various commands.
Declares entities whose ABI stability is NOT guaranteed.
The top-level namespace within which all mongocxx library entities are declared.
Declares mongocxx::v_noabi::options::transaction.
Provides mongocxx::v_noabi::options::transaction.
Declares mongocxx::v_noabi::uri.
Provides std::optional-related polyfills for library API usage.
Provides std::string_view-related polyfills for library API usage.
Declares mongocxx::v_noabi::write_concern.