MongoDB C++ Driver  mongocxx-3.10.2
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 <mongocxx/client-fwd.hpp>
20 #include <mongocxx/options/server_api-fwd.hpp>
21 #include <mongocxx/pool-fwd.hpp>
22 
23 #include <bsoncxx/stdx/optional.hpp>
24 #include <bsoncxx/stdx/string_view.hpp>
25 #include <mongocxx/stdx.hpp>
26 
27 #include <mongocxx/config/prelude.hpp>
28 
29 namespace mongocxx {
30 namespace v_noabi {
31 namespace options {
32 
36 class server_api {
37  public:
41  enum class version { k_version_1 };
42 
55 
67  static std::string version_to_string(version version);
68 
80  static version version_from_string(stdx::string_view version);
81 
93 
100  const stdx::optional<bool>& strict() const;
101 
113 
120  const stdx::optional<bool>& deprecation_errors() const;
121 
129 
130  private:
131  friend ::mongocxx::v_noabi::client;
132  friend ::mongocxx::v_noabi::pool;
133 
134  version _version;
135  stdx::optional<bool> _strict;
136  stdx::optional<bool> _deprecation_errors;
137 };
138 
139 } // namespace options
140 } // namespace v_noabi
141 } // namespace mongocxx
142 
143 #include <mongocxx/config/postlude.hpp>
Class representing options for server API.
Definition: server_api.hpp:36
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:41
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.
The top-level namespace for mongocxx library entities.
Definition: bulk_write-fwd.hpp:19