MongoDB C++ Driver  mongocxx-3.10.2
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 <mongocxx/client-fwd.hpp>
20 #include <mongocxx/collection-fwd.hpp>
21 #include <mongocxx/database-fwd.hpp>
22 #include <mongocxx/options/transaction-fwd.hpp>
23 #include <mongocxx/read_concern-fwd.hpp>
24 #include <mongocxx/uri-fwd.hpp>
25 
26 #include <bsoncxx/document/value.hpp>
27 #include <bsoncxx/stdx/optional.hpp>
28 #include <bsoncxx/stdx/string_view.hpp>
29 #include <mongocxx/options/transaction.hpp>
30 #include <mongocxx/stdx.hpp>
31 
32 #include <mongocxx/config/prelude.hpp>
33 
34 namespace mongocxx {
35 namespace v_noabi {
36 
56 class read_concern {
57  public:
63  enum class level {
64  k_local,
65  k_majority,
66  k_linearizable,
67  k_server_default,
68  k_unknown,
69  k_available,
70  k_snapshot
71  };
72 
81 
86 
91 
96 
100  read_concern& operator=(read_concern&&) noexcept;
101 
106 
117  void acknowledge_level(level rc_level);
118 
128 
138  void acknowledge_string(stdx::string_view rc_string);
139 
148  stdx::string_view acknowledge_string() const;
149 
156  bsoncxx::v_noabi::document::value to_document() const;
157 
158  private:
159  friend ::mongocxx::v_noabi::client;
160  friend ::mongocxx::v_noabi::collection;
161  friend ::mongocxx::v_noabi::database;
162  friend ::mongocxx::v_noabi::options::transaction;
163  friend ::mongocxx::v_noabi::uri;
164 
172  friend MONGOCXX_API bool MONGOCXX_CALL operator==(const read_concern&, const read_concern&);
173  friend MONGOCXX_API bool MONGOCXX_CALL operator!=(const read_concern&, const read_concern&);
177 
178  class MONGOCXX_PRIVATE impl;
179 
180  MONGOCXX_PRIVATE read_concern(std::unique_ptr<impl>&& implementation);
181 
182  std::unique_ptr<impl> _impl;
183 };
184 
185 } // namespace v_noabi
186 } // namespace mongocxx
187 
188 #include <mongocxx/config/postlude.hpp>
Class representing a client connection to MongoDB.
Definition: client.hpp:61
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:86
Class representing a MongoDB database.
Definition: database.hpp:46
A class to represent the read concern.
Definition: read_concern.hpp:56
read_concern(read_concern &&) noexcept
Move constructs a read_concern.
level acknowledge_level() const
Gets the current read concern level.
read_concern & operator=(const read_concern &)
Copy assigns a read_concern.
level
A class to represent the read concern level.
Definition: read_concern.hpp:63
read_concern()
Constructs a new read_concern with default acknowledge_level of k_server_default.
stdx::string_view acknowledge_string() const
Gets the current read concern string.
bsoncxx::v_noabi::document::value to_document() const
Gets the document form of this read_concern.
read_concern(const read_concern &)
Copy constructs a read_concern.
Class representing a MongoDB connection string URI.
Definition: uri.hpp:47
The top-level namespace for bsoncxx library entities.
Definition: element-fwd.hpp:19
The top-level namespace for mongocxx library entities.
Definition: bulk_write-fwd.hpp:19