MongoDB C++ Driver  mongocxx-3.9.0
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
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 inline namespace v_noabi {
27 class client;
28 class pool;
29 
30 namespace options {
31 
35 class MONGOCXX_API server_api {
36  public:
40  enum class version { k_version_1 };
41 
54 
66  static std::string version_to_string(version version);
67 
79  static version version_from_string(stdx::string_view version);
80 
91  server_api& strict(bool strict);
92 
99  const stdx::optional<bool>& strict() const;
100 
111  server_api& deprecation_errors(bool deprecation_errors);
112 
119  const stdx::optional<bool>& deprecation_errors() const;
120 
128 
129  private:
130  friend class mongocxx::client;
131  friend class mongocxx::pool;
132 
133  version _version;
134  stdx::optional<bool> _strict;
135  stdx::optional<bool> _deprecation_errors;
136 };
137 
138 } // namespace options
139 } // namespace v_noabi
140 } // namespace mongocxx
141 
142 #include <mongocxx/config/postlude.hpp>
Class representing a client connection to MongoDB.
Definition: client.hpp:54
Class representing options for server API.
Definition: server_api.hpp:35
static std::string version_to_string(version version)
Converts a version enum value to its string value.
const stdx::optional< bool > & strict() const
Gets the current value of the strict option.
version
Enum representing the possible values for server API version.
Definition: server_api.hpp:40
static version version_from_string(stdx::string_view version)
Converts a version string to its enum value.
version get_version() const
Gets the declared server api version.
server_api & deprecation_errors(bool deprecation_errors)
Sets the deprecation errors option, specifying whether the server should return errors for features t...
server_api & strict(bool strict)
Sets the strict option, specifying whether the server should return errors for features that are not ...
server_api(version version)
Constructs a new server_api object.
const stdx::optional< bool > & deprecation_errors() const
Gets the current value of the deprecation errors option.
A pool of client objects associated with a MongoDB deployment.
Definition: pool.hpp:46
The top-level namespace for mongocxx library entities.
Definition: bulk_write.hpp:24