MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
server_api.hpp
Go to the documentation of this file.
1// Copyright 2009-present 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 <mongocxx/options/server_api-fwd.hpp> // IWYU pragma: export
18
19//
20
21#include <mongocxx/v1/server_api.hpp> // IWYU pragma: export
22
23#include <string>
24
25#include <mongocxx/client-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
26#include <mongocxx/pool-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
27
30
32
33namespace mongocxx {
34namespace v_noabi {
35namespace options {
36
44 public:
49
61 /* explicit(false) */ server_api(version version) : _version{version} {}
62
66 /* explicit(false) */ server_api(v1::server_api const& opts)
67 : _version{opts.get_version()}, _strict{opts.strict()}, _deprecation_errors{opts.deprecation_errors()} {}
68
72 explicit operator v1::server_api() const {
73 v1::server_api ret{_version};
74
75 if (_strict) {
76 ret.strict(*_strict);
77 }
78
79 if (_deprecation_errors) {
80 ret.deprecation_errors(*_deprecation_errors);
81 }
82
83 return ret;
84 }
85
98
111
123 _strict = strict;
124 return *this;
125 }
126
134 return _strict;
135 }
136
148 _deprecation_errors = deprecation_errors;
149 return *this;
150 }
151
159 return _deprecation_errors;
160 }
161
169 return _version;
170 }
171
172 class internal;
173
174 private:
175 version _version;
177 bsoncxx::v_noabi::stdx::optional<bool> _deprecation_errors;
178};
179
180} // namespace options
181} // namespace v_noabi
182} // namespace mongocxx
183
184namespace mongocxx {
185namespace v_noabi {
186
191 return {v};
192}
193
200
201} // namespace v_noabi
202} // namespace mongocxx
203
205
A polyfill for std::optional<T>.
Definition optional.hpp:799
A polyfill for std::string_view.
Definition string_view.hpp:412
server_api(version version)
Constructs a new server_api object.
Definition server_api.hpp:61
Options related to MongoDB Stable API configuration.
Definition server_api.hpp:46
server_api & deprecation_errors(bool v)
Set the "deprecationErrors" field.
server_api & strict(bool strict)
Set the "strict" field.
version
The server API version.
Definition server_api.hpp:60
Used by mongocxx::v_noabi::options::client::server_api_opts.
Definition server_api.hpp:43
static version version_from_string(bsoncxx::v_noabi::stdx::string_view version)
Converts a version string to its enum value.
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...
Definition server_api.hpp:147
bsoncxx::v_noabi::stdx::optional< bool > const & deprecation_errors() const
Gets the current value of the deprecation errors option.
Definition server_api.hpp:158
server_api & strict(bool strict)
Sets the strict option, specifying whether the server should return errors for features that are not ...
Definition server_api.hpp:122
bsoncxx::v_noabi::stdx::optional< bool > const & strict() const
Gets the current value of the strict option.
Definition server_api.hpp:133
version get_version() const
Gets the declared server api version.
Definition server_api.hpp:168
v1::server_api::version version
Enum representing the possible values for server API version.
Definition server_api.hpp:48
server_api(v1::server_api const &opts)
Construct with the mongocxx::v1 equivalent.
Definition server_api.hpp:66
server_api(version version)
Constructs a new server_api object.
Definition server_api.hpp:61
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v_noabi macro guard postlude header.
The mongocxx v_noabi macro guard prelude header.
Declares entities representing options to use with various commands.
Declares entities whose ABI stability is NOT guaranteed.
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
The top-level namespace within which all mongocxx library entities are declared.
Provides mongocxx::v1::server_api.
Provides std::optional-related polyfills for library API usage.
Provides std::string_view-related polyfills for library API usage.
Declares mongocxx::v_noabi::client.
Declares mongocxx::v_noabi::options::server_api.
Declares mongocxx::v_noabi::pool.