MongoDB C++ Driver mongocxx-3.6.7
read_concern.hpp
1// Copyright 2015 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 <memory>
18
19#include <bsoncxx/document/value.hpp>
20#include <bsoncxx/stdx/optional.hpp>
21#include <bsoncxx/stdx/string_view.hpp>
22#include <mongocxx/options/transaction.hpp>
23#include <mongocxx/stdx.hpp>
24
25#include <mongocxx/config/prelude.hpp>
26
27namespace mongocxx {
28MONGOCXX_INLINE_NAMESPACE_BEGIN
29
30class client;
31class collection;
32class database;
33class uri;
34
54class MONGOCXX_API read_concern {
55 public:
61 enum class level {
62 k_local,
63 k_majority,
64 k_linearizable,
65 k_server_default,
66 k_unknown,
67 k_available,
68 k_snapshot
69 };
70
79
84
89
94
98 read_concern& operator=(read_concern&&) noexcept;
99
104
115 void acknowledge_level(level rc_level);
116
125 level acknowledge_level() const;
126
136 void acknowledge_string(stdx::string_view rc_string);
137
146 stdx::string_view acknowledge_string() const;
147
154 bsoncxx::document::value to_document() const;
155
156 private:
157 friend client;
158 friend collection;
159 friend database;
160 friend options::transaction;
161 friend uri;
162
170 friend MONGOCXX_API bool MONGOCXX_CALL operator==(const read_concern&, const read_concern&);
171 friend MONGOCXX_API bool MONGOCXX_CALL operator!=(const read_concern&, const read_concern&);
175
176 class MONGOCXX_PRIVATE impl;
177
178 MONGOCXX_PRIVATE read_concern(std::unique_ptr<impl>&& implementation);
179
180 std::unique_ptr<impl> _impl;
181};
182
183MONGOCXX_INLINE_NAMESPACE_END
184} // namespace mongocxx
185
186#include <mongocxx/config/postlude.hpp>
Class representing a client connection to MongoDB.
Definition: client.hpp:58
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:81
Class representing a MongoDB database.
Definition: database.hpp:43
A class to represent the read concern.
Definition: read_concern.hpp:54
read_concern & operator=(const read_concern &)
Copy assigns a read_concern.
level
A class to represent the read concern level.
Definition: read_concern.hpp:61
read_concern(read_concern &&) noexcept
Move constructs a read_concern.
read_concern(const read_concern &)
Copy constructs a read_concern.
read_concern()
Constructs a new read_concern with default acknowledge_level of k_server_default.
Class representing a MongoDB connection string URI.
Definition: uri.hpp:43
Top level namespace for MongoDB C++ BSON functionality.
Definition: element.hpp:24
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24