MongoDB C++ Driver mongocxx-3.7.0
Loading...
Searching...
No Matches
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
25namespace mongocxx {
26MONGOCXX_INLINE_NAMESPACE_BEGIN
27
28class client;
29class pool;
30
31namespace options {
32
36class MONGOCXX_API 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
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
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
140MONGOCXX_INLINE_NAMESPACE_END
141} // namespace mongocxx
142
143#include <mongocxx/config/postlude.hpp>
Class representing a client connection to MongoDB.
Definition client.hpp:58
Class representing options for server API.
Definition server_api.hpp:36
const stdx::optional< bool > & deprecation_errors() const
Gets the current value of the deprecation errors option.
server_api & deprecation_errors(bool deprecation_errors)
Sets the deprecation errors option, specifying whether the server should return errors for features t...
const stdx::optional< bool > & strict() const
Gets the current value of the strict option.
server_api & strict(bool strict)
Sets the strict option, specifying whether the server should return errors for features that are not ...
version get_version() const
Gets the declared server api version.
static std::string version_to_string(version version)
Converts a version enum value to its string value.
server_api(version version)
Constructs a new server_api object.
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.
A pool of client objects associated with a MongoDB deployment.
Definition pool.hpp:47
Top level namespace for the MongoDB C++ driver.
Definition bulk_write.hpp:24