MongoDB C++ Driver mongocxx-3.0.0
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 <stdexcept>
20#include <memory>
21
22#include <bsoncxx/stdx/optional.hpp>
23#include <bsoncxx/stdx/string_view.hpp>
24#include <mongocxx/stdx.hpp>
25
26#include <mongocxx/config/prelude.hpp>
27
28namespace mongocxx {
29MONGOCXX_INLINE_NAMESPACE_BEGIN
30
31class bulk_write;
32class client;
33class collection;
34class database;
35class uri;
36
54class MONGOCXX_API write_concern {
55 public:
60 enum class level {
61 k_default,
62 k_majority,
63 k_tag,
64 k_unacknowledged,
65 k_unknown,
66 };
67
72
77
82
87
91 write_concern& operator=(write_concern&&) noexcept;
92
97
106 void journal(bool journal);
107
123 void nodes(std::int32_t confirm_from);
124
137 void acknowledge_level(level confirm_level);
138
147 void majority(std::chrono::milliseconds timeout);
148
158 void tag(stdx::string_view tag);
159
169 void timeout(std::chrono::milliseconds timeout);
170
176 bool journal() const;
177
187 stdx::optional<std::int32_t> nodes() const;
188
198 stdx::optional<level> acknowledge_level() const;
199
205 stdx::optional<std::string> tag() const;
206
212 bool majority() const;
213
219 std::chrono::milliseconds timeout() const;
220
221 private:
222 friend bulk_write;
223 friend client;
224 friend collection;
225 friend database;
226 friend uri;
227
228 class MONGOCXX_PRIVATE impl;
229
230 MONGOCXX_PRIVATE write_concern(std::unique_ptr<impl>&& implementation);
231
232 std::unique_ptr<impl> _impl;
233};
234
235MONGOCXX_INLINE_NAMESPACE_END
236} // namespace mongocxx
237
238#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:41
Class representing a client connection to MongoDB.
Definition client.hpp:49
Class representing server side document groupings within a MongoDB database.
Definition collection.hpp:74
Class representing a MongoDB database.
Definition database.hpp:43
Class representing a MongoDB connection string URI.
Definition uri.hpp:40
Class representing the server-side requirement for reporting the success of a write operation.
Definition write_concern.hpp:54
level
A class to represent the special case values for write_concern::nodes.
Definition write_concern.hpp:60
write_concern()
Constructs a new write_concern.
write_concern(const write_concern &)
Copy constructs a write_concern.
write_concern & operator=(const write_concern &)
Copy assigns a write_concern.
write_concern(write_concern &&) noexcept
Move constructs a write_concern.