MongoDB C++ Driver  mongocxx-3.5.0
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 
27 namespace mongocxx {
28 MONGOCXX_INLINE_NAMESPACE_BEGIN
29 
30 class client;
31 class collection;
32 class database;
33 class uri;
34 
54 class 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 
78  read_concern();
79 
83  read_concern(const read_concern&);
84 
88  read_concern& operator=(const read_concern&);
89 
93  read_concern(read_concern&&) noexcept;
94 
98  read_concern& operator=(read_concern&&) noexcept;
99 
103  ~read_concern();
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 
183 MONGOCXX_INLINE_NAMESPACE_END
184 } // namespace mongocxx
185 
186 #include <mongocxx/config/postlude.hpp>
Class representing a MongoDB connection string URI.
Definition: uri.hpp:40
Class representing the optional arguments for a transaction.
Definition: transaction.hpp:38
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
level
A class to represent the read concern level.
Definition: read_concern.hpp:61
A read-only BSON document that owns its underlying buffer.
Definition: value.hpp:33
Class representing a client connection to MongoDB.
Definition: client.hpp:57
Class representing a MongoDB database.
Definition: database.hpp:43
A class to represent the read concern.
Definition: read_concern.hpp:54
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:85