Loading...
Searching...
No Matches
server_api.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/options/server_api-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/server_api.hpp> // IWYU pragma: export
#include <string>
#include <mongocxx/client-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/pool-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/stdx/optional.hpp>
#include <bsoncxx/stdx/string_view.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
namespace options {
class server_api {
public:
using version = v1::server_api::version;
/* explicit(false) */ server_api(version version) : _version{version} {}
/* explicit(false) */ server_api(v1::server_api const& opts)
: _version{opts.get_version()}, _strict{opts.strict()}, _deprecation_errors{opts.deprecation_errors()} {}
explicit operator v1::server_api() const {
v1::server_api ret{_version};
if (_strict) {
ret.strict(*_strict);
}
if (_deprecation_errors) {
ret.deprecation_errors(*_deprecation_errors);
}
return ret;
}
static MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(std::string) version_to_string(version version);
static MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(version) version_from_string(bsoncxx::v_noabi::stdx::string_view version);
server_api& strict(bool strict) {
_strict = strict;
return *this;
}
bsoncxx::v_noabi::stdx::optional<bool> const& strict() const {
return _strict;
}
server_api& deprecation_errors(bool deprecation_errors) {
_deprecation_errors = deprecation_errors;
return *this;
}
bsoncxx::v_noabi::stdx::optional<bool> const& deprecation_errors() const {
return _deprecation_errors;
}
version get_version() const {
return _version;
}
class internal;
private:
version _version;
bsoncxx::v_noabi::stdx::optional<bool> _strict;
bsoncxx::v_noabi::stdx::optional<bool> _deprecation_errors;
};
} // namespace options
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::options::server_api from_v1(v1::server_api const& v) {
return {v};
}
inline v1::server_api to_v1(v_noabi::options::server_api const& v) {
return v1::server_api{v};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
bsoncxx::v1::stdx::optional
A polyfill for std::optional<T>.
Definition optional.hpp:799
bsoncxx::v1::stdx::string_view
A polyfill for std::string_view.
Definition string_view.hpp:412
mongocxx::options::server_api::server_api
server_api(version version)
Constructs a new server_api object.
Definition server_api.hpp:61
mongocxx::v1::server_api
Options related to MongoDB Stable API configuration.
Definition server_api.hpp:46
mongocxx::v1::server_api::deprecation_errors
server_api & deprecation_errors(bool v)
Set the "deprecationErrors" field.
mongocxx::v1::server_api::strict
server_api & strict(bool strict)
Set the "strict" field.
mongocxx::v1::server_api::version
version
The server API version.
Definition server_api.hpp:60
mongocxx::v_noabi::options::server_api
Used by mongocxx::v_noabi::options::client::server_api_opts.
Definition server_api.hpp:43
mongocxx::v_noabi::options::server_api::version_from_string
static version version_from_string(bsoncxx::v_noabi::stdx::string_view version)
Converts a version string to its enum value.
mongocxx::v_noabi::options::server_api::version_to_string
static std::string version_to_string(version version)
Converts a version enum value to its string value.
mongocxx::v_noabi::options::server_api::deprecation_errors
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
mongocxx::v_noabi::options::server_api::deprecation_errors
bsoncxx::v_noabi::stdx::optional< bool > const & deprecation_errors() const
Gets the current value of the deprecation errors option.
Definition server_api.hpp:158
mongocxx::v_noabi::options::server_api::strict
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
mongocxx::v_noabi::options::server_api::strict
bsoncxx::v_noabi::stdx::optional< bool > const & strict() const
Gets the current value of the strict option.
Definition server_api.hpp:133
mongocxx::v_noabi::options::server_api::get_version
version get_version() const
Gets the declared server api version.
Definition server_api.hpp:168
mongocxx::v_noabi::options::server_api::version
v1::server_api::version version
Enum representing the possible values for server API version.
Definition server_api.hpp:48
mongocxx::v_noabi::options::server_api::server_api
server_api(v1::server_api const &opts)
Construct with the mongocxx::v1 equivalent.
Definition server_api.hpp:66
mongocxx::v_noabi::options::server_api::server_api
server_api(version version)
Constructs a new server_api object.
Definition server_api.hpp:61
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE
#define MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to MONGOCXX_ABI_EXPORT_UNSTABLE with MONGOCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The mongocxx v_noabi macro guard postlude header.
prelude.hpp
The mongocxx v_noabi macro guard prelude header.
mongocxx::v_noabi::options
Declares entities representing options to use with various commands.
mongocxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
mongocxx::v_noabi::to_v1
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
mongocxx::v_noabi::from_v1
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
server_api.hpp
Provides mongocxx::v1::server_api.
optional.hpp
Provides std::optional-related polyfills for library API usage.
string_view.hpp
Provides std::string_view-related polyfills for library API usage.
client-fwd.hpp
Declares mongocxx::v_noabi::client.
server_api-fwd.hpp
Declares mongocxx::v_noabi::options::server_api.
pool-fwd.hpp
Declares mongocxx::v_noabi::pool.