MongoDB C++ Driver current
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 {
26inline namespace v_noabi {
27class client;
28class pool;
29
30namespace options {
31
35class 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.
server_api & deprecation_errors(bool deprecation_errors)
Sets the deprecation errors option, specifying whether the server should return errors for features t...
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.
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.
const stdx::optional< bool > & deprecation_errors() const
Gets the current value of the deprecation errors option.
const stdx::optional< bool > & strict() const
Gets the current value of the strict option.
server_api(version version)
Constructs a new server_api object.
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