MongoDB C++ Driver  mongocxx-3.7.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;
161  friend mongocxx::options::transaction;
162  friend uri;
163 
171  friend MONGOCXX_API bool MONGOCXX_CALL operator==(const read_concern&, const read_concern&);
172  friend MONGOCXX_API bool MONGOCXX_CALL operator!=(const read_concern&, const read_concern&);
176 
177  class MONGOCXX_PRIVATE impl;
178 
179  MONGOCXX_PRIVATE read_concern(std::unique_ptr<impl>&& implementation);
180 
181  std::unique_ptr<impl> _impl;
182 };
183 
184 MONGOCXX_INLINE_NAMESPACE_END
185 } // namespace mongocxx
186 
187 #include <mongocxx/config/postlude.hpp>
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
bsoncxx
Top level namespace for MongoDB C++ BSON functionality.
Definition: element.hpp:24
mongocxx::client
Class representing a client connection to MongoDB.
Definition: client.hpp:58
mongocxx::read_concern::level
level
A class to represent the read concern level.
Definition: read_concern.hpp:61
mongocxx::read_concern
A class to represent the read concern.
Definition: read_concern.hpp:54
mongocxx::uri
Class representing a MongoDB connection string URI.
Definition: uri.hpp:43
mongocxx::database
Class representing a MongoDB database.
Definition: database.hpp:43
mongocxx::collection
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:83