MongoDB C++ Driver current
Loading...
Searching...
No Matches
write_concern.hpp
1// Copyright 2014 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
22#include <bsoncxx/document/value.hpp>
23#include <bsoncxx/stdx/optional.hpp>
24#include <bsoncxx/stdx/string_view.hpp>
25#include <mongocxx/options/transaction.hpp>
26#include <mongocxx/stdx.hpp>
27
28#include <mongocxx/config/prelude.hpp>
29
30namespace mongocxx {
31inline namespace v_noabi {
32class bulk_write;
33class client;
34class collection;
35class database;
36class uri;
37
38namespace options {
39class transaction;
40}
41
59class MONGOCXX_API write_concern {
60 public:
65 enum class level { k_default, k_majority, k_tag, k_unacknowledged, k_acknowledged };
66
71
76
81
86
90 write_concern& operator=(write_concern&&) noexcept;
91
96
105 void journal(bool journal);
106
122 void nodes(std::int32_t confirm_from);
123
146 void acknowledge_level(level confirm_level);
147
158 void majority(std::chrono::milliseconds timeout);
159
169 void tag(stdx::string_view tag);
170
181 void timeout(std::chrono::milliseconds timeout);
182
188 bool journal() const;
189
200 stdx::optional<std::int32_t> nodes() const;
201
209 level acknowledge_level() const;
210
216 stdx::optional<std::string> tag() const;
217
223 bool majority() const;
224
230 std::chrono::milliseconds timeout() const;
231
237 bool is_acknowledged() const;
238
245 bsoncxx::document::value to_document() const;
246
247 private:
248 friend class bulk_write;
249 friend class client;
250 friend class collection;
251 friend class database;
252 friend class uri;
253
254 friend class options::transaction;
255
263 friend MONGOCXX_API bool MONGOCXX_CALL operator==(const write_concern&, const write_concern&);
264 friend MONGOCXX_API bool MONGOCXX_CALL operator!=(const write_concern&, const write_concern&);
268
269 class MONGOCXX_PRIVATE impl;
270
271 MONGOCXX_PRIVATE write_concern(std::unique_ptr<impl>&& implementation);
272
273 std::unique_ptr<impl> _impl;
274};
275
276} // namespace v_noabi
277} // namespace mongocxx
278
279#include <mongocxx/config/postlude.hpp>
Class representing a batch of write operations that can be sent to the server as a group.
Definition bulk_write.hpp:42
Class representing a client connection to MongoDB.
Definition client.hpp:54
Class representing server side document groupings within a MongoDB database.
Definition collection.hpp:85
Class representing a MongoDB database.
Definition database.hpp:44
Class representing a MongoDB connection string URI.
Definition uri.hpp:42
Class representing the server-side requirement for reporting the success of a write operation.
Definition write_concern.hpp:59
write_concern & operator=(const write_concern &)
Copy assigns a write_concern.
write_concern(const write_concern &)
Copy constructs a write_concern.
level
A class to represent the special case values for write_concern::nodes.
Definition write_concern.hpp:65
write_concern(write_concern &&) noexcept
Move constructs a write_concern.
write_concern()
Constructs a new write_concern.
The top-level namespace for bsoncxx library entities.
Definition element.hpp:24
The top-level namespace for mongocxx library entities.
Definition bulk_write.hpp:24