MongoDB C++ Driver  mongocxx-3.7.0
server_api.hpp
1 // Copyright 2021 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 <string>
18 
19 #include <bsoncxx/stdx/optional.hpp>
20 #include <bsoncxx/stdx/string_view.hpp>
21 #include <mongocxx/stdx.hpp>
22 
23 #include <mongocxx/config/prelude.hpp>
24 
25 namespace mongocxx {
26 MONGOCXX_INLINE_NAMESPACE_BEGIN
27 
28 class client;
29 class pool;
30 
31 namespace options {
32 
36 class MONGOCXX_API server_api {
37  public:
41  enum class version { k_version_1 };
42 
54  server_api(version version);
55 
67  static std::string version_to_string(version version);
68 
80  static version version_from_string(stdx::string_view version);
81 
92  server_api& strict(bool strict);
93 
100  const stdx::optional<bool>& strict() const;
101 
112  server_api& deprecation_errors(bool deprecation_errors);
113 
120  const stdx::optional<bool>& deprecation_errors() const;
121 
128  version get_version() const;
129 
130  private:
131  friend class mongocxx::client;
132  friend class mongocxx::pool;
133 
134  version _version;
135  stdx::optional<bool> _strict;
136  stdx::optional<bool> _deprecation_errors;
137 };
138 
139 } // namespace options
140 MONGOCXX_INLINE_NAMESPACE_END
141 } // namespace mongocxx
142 
143 #include <mongocxx/config/postlude.hpp>
mongocxx::pool
A pool of client objects associated with a MongoDB deployment.
Definition: pool.hpp:47
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
mongocxx::client
Class representing a client connection to MongoDB.
Definition: client.hpp:58
mongocxx::options::server_api
Class representing options for server API.
Definition: server_api.hpp:36
mongocxx::options::server_api::version
version
Enum representing the possible values for server API version.
Definition: server_api.hpp:41