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/v1/server_api-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/detail/prelude.hpp>
#include <bsoncxx/v1/stdx/optional.hpp>
#include <bsoncxx/v1/stdx/string_view.hpp>
#include <mongocxx/v1/config/export.hpp>
#include <string>
#include <system_error>
#include <type_traits>
namespace mongocxx {
namespace v1 {
class server_api {
// This class implements `ServerApi`:
// - https://specifications.readthedocs.io/en/latest/versioned-api/versioned-api/
private:
class impl;
void* _impl;
public:
enum class version {
k_version_1,
};
MONGOCXX_ABI_EXPORT_CDECL() ~server_api();
MONGOCXX_ABI_EXPORT_CDECL() server_api(server_api&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(server_api&) operator=(server_api&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL() server_api(server_api const& other);
MONGOCXX_ABI_EXPORT_CDECL(server_api&) operator=(server_api const& other);
explicit MONGOCXX_ABI_EXPORT_CDECL() server_api(version v);
static MONGOCXX_ABI_EXPORT_CDECL(std::string) version_to_string(version v);
static MONGOCXX_ABI_EXPORT_CDECL(version) version_from_string(bsoncxx::v1::stdx::string_view v);
MONGOCXX_ABI_EXPORT_CDECL(server_api&) strict(bool strict);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bool>) strict() const;
MONGOCXX_ABI_EXPORT_CDECL(server_api&) deprecation_errors(bool v);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bool>) deprecation_errors() const;
MONGOCXX_ABI_EXPORT_CDECL(version) get_version() const;
enum class errc {
zero,
invalid_version,
};
static MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
friend std::error_code make_error_code(errc v) {
return {static_cast<int>(v), error_category()};
}
class internal;
};
} // namespace v1
} // namespace mongocxx
namespace std {
template <>
struct is_error_code_enum<mongocxx::v1::server_api::errc> : true_type {};
} // namespace std
#include <mongocxx/v1/detail/postlude.hpp>
mongocxx::v1::server_api::server_api
server_api(server_api &&other) noexcept
Move constructor.
mongocxx::v1::server_api::version_from_string
static version version_from_string(bsoncxx::v1::stdx::string_view v)
Return the given server API version as an enumerator.
mongocxx::v1::server_api::get_version
version get_version() const
Return the current "version" field.
mongocxx::v1::server_api::deprecation_errors
server_api & deprecation_errors(bool v)
Set the "deprecationErrors" field.
mongocxx::v1::server_api::errc
errc
Errors codes which may be returned by mongocxx::v1::server_api.
Definition server_api.hpp:153
mongocxx::v1::server_api::errc::invalid_version
@ invalid_version
The server API version is invalid.
Definition server_api.hpp:155
mongocxx::v1::server_api::errc::zero
@ zero
Zero.
Definition server_api.hpp:154
mongocxx::v1::server_api::~server_api
~server_api()
Destroy this object.
mongocxx::v1::server_api::make_error_code
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition server_api.hpp:166
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::v1::server_api::version::k_version_1
@ k_version_1
Stable API Version 1.
Definition server_api.hpp:64
mongocxx::v1::server_api::version_to_string
static std::string version_to_string(version v)
Return the given server API version as a string.
mongocxx::v1::server_api::error_category
static std::error_category const & error_category()
The error category for mongocxx::v1::server_api::errc.
export.hpp
Provides macros to control the set of symbols exported in the ABI.
MONGOCXX_ABI_EXPORT_CDECL
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
postlude.hpp
The mongocxx v1 macro guard postlude header.
prelude.hpp
The mongocxx v1 macro guard prelude header.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx::v1::source_errc::mongocxx
@ mongocxx
From the mongocxx library.
Definition exception.hpp:40
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
server_api-fwd.hpp
Declares 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.