Loading...
Searching...
No Matches
client.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/client-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/detail/prelude.hpp>
#include <bsoncxx/v1/document/view-fwd.hpp>
#include <mongocxx/v1/apm-fwd.hpp>
#include <mongocxx/v1/auto_encryption_options-fwd.hpp>
#include <mongocxx/v1/client_bulk_write-fwd.hpp>
#include <mongocxx/v1/cursor-fwd.hpp>
#include <mongocxx/v1/database-fwd.hpp>
#include <mongocxx/v1/pipeline-fwd.hpp>
#include <mongocxx/v1/server_api-fwd.hpp>
#include <mongocxx/v1/tls-fwd.hpp>
#include <mongocxx/v1/uri-fwd.hpp>
#include <bsoncxx/v1/stdx/optional.hpp>
#include <bsoncxx/v1/stdx/string_view.hpp>
#include <mongocxx/v1/change_stream.hpp>
#include <mongocxx/v1/client_session.hpp>
#include <mongocxx/v1/config/export.hpp>
#include <mongocxx/v1/oidc_callback.hpp>
#include <string>
#include <system_error>
#include <type_traits>
#include <vector>
namespace mongocxx {
namespace v1 {
class client {
private:
class impl;
void* _impl;
public:
class options;
MONGOCXX_ABI_EXPORT_CDECL() ~client();
MONGOCXX_ABI_EXPORT_CDECL() client(client&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(client&) operator=(client&& other) noexcept;
client(client const& other) = delete;
client& operator=(client const& other) = delete;
MONGOCXX_ABI_EXPORT_CDECL() client(v1::uri uri, options opts);
/* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() client(v1::uri uri);
MONGOCXX_ABI_EXPORT_CDECL() client();
explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
MONGOCXX_ABI_EXPORT_CDECL(v1::uri) uri() const;
MONGOCXX_ABI_EXPORT_CDECL(v1::database) database(bsoncxx::v1::stdx::string_view name);
MONGOCXX_ABI_EXPORT_CDECL(v1::database) operator[](bsoncxx::v1::stdx::string_view name);
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor) list_databases();
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor) list_databases(v1::client_session const& session);
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor) list_databases(bsoncxx::v1::document::view opts);
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor) list_databases(
v1::client_session const& session,
bsoncxx::v1::document::view opts);
MONGOCXX_ABI_EXPORT_CDECL(std::vector<std::string>) list_database_names(bsoncxx::v1::document::view filter);
MONGOCXX_ABI_EXPORT_CDECL(std::vector<std::string>) list_database_names(
v1::client_session const& session,
bsoncxx::v1::document::view filter);
MONGOCXX_ABI_EXPORT_CDECL(std::vector<std::string>) list_database_names();
MONGOCXX_ABI_EXPORT_CDECL(std::vector<std::string>) list_database_names(v1::client_session const& session);
MONGOCXX_ABI_EXPORT_CDECL(v1::client_session) start_session(v1::client_session::options const& opts);
MONGOCXX_ABI_EXPORT_CDECL(v1::client_session) start_session();
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream) watch(v1::change_stream::options const& opts);
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream) watch();
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream) watch(
v1::client_session const& session,
v1::change_stream::options const& opts);
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream) watch(v1::client_session const& session);
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream) watch(
v1::pipeline const& pipeline,
v1::change_stream::options const& opts);
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream)
watch(v1::client_session const& session, v1::pipeline const& pipeline, v1::change_stream::options const& opts);
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream) watch(v1::pipeline const& pipeline);
MONGOCXX_ABI_EXPORT_CDECL(v1::change_stream) watch(v1::client_session const& session, v1::pipeline const& pipeline);
MONGOCXX_ABI_EXPORT_CDECL(v1::client_bulk_write) create_bulk_write();
MONGOCXX_ABI_EXPORT_CDECL(v1::client_bulk_write) create_bulk_write(v1::client_session& session);
MONGOCXX_ABI_EXPORT_CDECL(void) reset();
enum class errc {
zero,
tls_not_enabled,
tls_not_supported,
};
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;
private:
/* explicit(false) */ client(void* impl);
};
class client::options {
private:
class impl;
void* _impl;
public:
MONGOCXX_ABI_EXPORT_CDECL() ~options();
MONGOCXX_ABI_EXPORT_CDECL() options(options&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL() options(options const& other);
MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options const& other);
MONGOCXX_ABI_EXPORT_CDECL() options();
MONGOCXX_ABI_EXPORT_CDECL(options&) tls_opts(v1::tls v);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::tls>) tls_opts() const;
MONGOCXX_ABI_EXPORT_CDECL(options&) auto_encryption_opts(v1::auto_encryption_options v);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::auto_encryption_options>) auto_encryption_opts() const;
MONGOCXX_ABI_EXPORT_CDECL(options&) apm_opts(v1::apm v);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::apm>) apm_opts() const;
MONGOCXX_ABI_EXPORT_CDECL(options&) oidc_callback(v1::oidc_callback v);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::oidc_callback>) oidc_callback() const;
MONGOCXX_ABI_EXPORT_CDECL(options&) server_api_opts(v1::server_api v);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::server_api>) server_api_opts() const;
class internal;
};
} // namespace v1
} // namespace mongocxx
namespace std {
template <>
struct is_error_code_enum<mongocxx::v1::client::errc> : true_type {};
} // namespace std
#include <mongocxx/v1/detail/postlude.hpp>
auto_encryption_options-fwd.hpp
Declares mongocxx::v1::auto_encryption_options.
mongocxx::v1::apm
Options related to Application Performance Monitoring (APM) configuration.
Definition apm.hpp:51
mongocxx::v1::auto_encryption_options
Options related In-Use Encryption configuration.
Definition auto_encryption_options.hpp:58
mongocxx::v1::change_stream
A MongoDB change stream.
Definition change_stream.hpp:48
mongocxx::v1::client::options
Options for mongocxx::v1::client.
Definition client.hpp:310
mongocxx::v1::client::options::apm_opts
options & apm_opts(v1::apm v)
Set the "apm_opts" field.
mongocxx::v1::client::options::options
options(options &&other) noexcept
Move constructor.
mongocxx::v1::client::options::~options
~options()
Destroy this object.
mongocxx::v1::client::options::oidc_callback
options & oidc_callback(v1::oidc_callback v)
Set the "oidc_callback" field.
mongocxx::v1::client::options::auto_encryption_opts
options & auto_encryption_opts(v1::auto_encryption_options v)
Set the "auto_encryption_opts" field.
mongocxx::v1::client::options::tls_opts
options & tls_opts(v1::tls v)
Set the "tls_opts" field.
mongocxx::v1::client::options::server_api_opts
options & server_api_opts(v1::server_api v)
Set the "server_api_opts" field.
mongocxx::v1::client_bulk_write
A list of bulk write operations. Unlike mongocxx::v1::bulk_write, this supports writes across more th...
Definition client_bulk_write.hpp:58
mongocxx::v1::client_session
A MongoDB client session.
Definition client_session.hpp:46
mongocxx::v1::client::~client
~client()
Destroy this object.
mongocxx::v1::client::reset
void reset()
Invalidate this client object without invaliding existing cursors or sessions.
mongocxx::v1::client::create_bulk_write
v1::client_bulk_write create_bulk_write()
Return a new client-level bulk write operation for use with this client.
mongocxx::v1::client::errc
errc
Errors codes which may be returned by mongocxx::v1::client.
Definition client.hpp:276
mongocxx::v1::client::errc::tls_not_supported
@ tls_not_supported
TLS is not supported by the mongoc library.
Definition client.hpp:279
mongocxx::v1::client::errc::tls_not_enabled
@ tls_not_enabled
TLS is not enabled by URI options.
Definition client.hpp:278
mongocxx::v1::client::errc::zero
@ zero
Zero.
Definition client.hpp:277
mongocxx::v1::client::database
v1::database database(bsoncxx::v1::stdx::string_view name)
Access the database with the given name.
mongocxx::v1::client::client
client()
Default initialization.
mongocxx::v1::client::uri
v1::uri uri() const
Return the mongocxx::v1::uri used to initialize this client.
mongocxx::v1::client::make_error_code
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition client.hpp:290
mongocxx::v1::client::list_database_names
std::vector< std::string > list_database_names(bsoncxx::v1::document::view filter)
Return an unsorted list of the names of all existing databases.
mongocxx::v1::client::client
client(client &&other) noexcept
Move constructor.
mongocxx::v1::client::start_session
v1::client_session start_session(v1::client_session::options const &opts)
Create a new client session to use with subsequent operations.
mongocxx::v1::client::list_databases
v1::cursor list_databases()
Return an unsorted list of all existing databases.
mongocxx::v1::client::watch
v1::change_stream watch(v1::change_stream::options const &opts)
Return a change stream subscribed to this connection.
mongocxx::v1::client::error_category
static std::error_category const & error_category()
The error category for mongocxx::v1::client::errc.
mongocxx::v1::cursor
A MongoDB cursor.
Definition cursor.hpp:39
mongocxx::v1::pipeline
A MongoDB aggregation pipeline.
Definition pipeline.hpp:41
mongocxx::v1::server_api
Options related to MongoDB Stable API configuration.
Definition server_api.hpp:46
mongocxx::v1::tls
Options related to TLS configuration.
Definition tls.hpp:48
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
The top-level namespace within which all mongocxx library entities are declared.
apm-fwd.hpp
Declares mongocxx::v1::apm.
change_stream.hpp
Provides mongocxx::v1::change_stream.
client-fwd.hpp
Declares mongocxx::v1::client.
client_bulk_write-fwd.hpp
Declares mongocxx::v1::client_bulk_write.
client_session.hpp
Provides mongocxx::v1::client_session.
cursor-fwd.hpp
Declares mongocxx::v1::cursor.
database-fwd.hpp
Declares mongocxx::v1::database.
view-fwd.hpp
Declares bsoncxx::v1::document::view.
oidc_callback.hpp
Provides mongocxx::v1::oidc_callback.
pipeline-fwd.hpp
Declares mongocxx::v1::pipeline.
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.
tls-fwd.hpp
Declares mongocxx::v1::tls.
uri-fwd.hpp
Declares mongocxx::v1::uri.