MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
mongocxx::v1::instance Class Reference

#include <mongocxx/v1/instance.hpp>

Description

An instance of the MongoDB C++ Driver.

Attention
This feature is experimental! It is not ready for use!

All mongocxx API MUST be used within the lifetime of the instance object, with special exemptions listed below. Only ONE instance object may exist for the lifetime of a given process. It is undefined behavior to use the mongocxx API before the instance object is initialized or after the instance object is destroyed. It is undefined behavior to create more than one instance object.

int main() {
// ...
// MUST NOT call mongocxx API before this point.
{
// MAY call mongocxx API at this point.
// ...
}
// MUST NOT call mongocxx API after this point.
// ...
}
An instance of the MongoDB C++ Driver.
Definition instance.hpp:66
instance(instance &&)=delete
This class is not moveable.
Special exemptions
Only the following API are permitted to be used outside the lifetime of an instance object:
See also

Public Types

enum class  errc
 Errors codes which may be returned by mongocxx::v1::instance. More...

Public Member Functions

 instance ()
 Initialize the mongoc library with unstructured log messages disabled.
 instance (instance &&)=delete
 This class is not moveable.
 instance (instance const &)=delete
 This class is not copyable.
 instance (std::unique_ptr< v1::logger > handler)
 Initialize the mongoc library with the custom unstructured log message handler.
 instance (v1::default_logger tag)
 Initialize the mongoc library with its default unstructured log handler.
 ~instance ()
 Cleanup the mongocxx (and mongoc) library.
instanceoperator= (instance &&)=delete
 This class is not moveable.
instanceoperator= (instance const &)=delete
 This class is not copyable.

Static Public Member Functions

static std::error_category const & error_category ()
 The error category for mongocxx::v1::instance::errc.

Friends

std::error_code make_error_code (errc v)
 Support implicit conversion to std::error_code.

Member Enumeration Documentation

◆ errc

enum class mongocxx::v1::instance::errc
strong

Errors codes which may be returned by mongocxx::v1::instance.

Attention
This feature is experimental! It is not ready for use!
Enumerator
zero 

Zero.

multiple_instances 

Cannot construct multiple instance objects in a given process.

Constructor & Destructor Documentation

◆ ~instance()

mongocxx::v1::instance::~instance ( )

Cleanup the mongocxx (and mongoc) library.

Calls mongoc_cleanup().

◆ instance() [1/5]

mongocxx::v1::instance::instance ( instance && )
delete

This class is not moveable.

◆ instance() [2/5]

mongocxx::v1::instance::instance ( instance const & )
delete

This class is not copyable.

◆ instance() [3/5]

mongocxx::v1::instance::instance ( )

Initialize the mongoc library with unstructured log messages disabled.

Calls mongoc_init() after disabling unstructured log messages by calling mongoc_log_set_handler(nullptr, nullptr).

Important
To use mongoc's default log message handler, construct this object with instance(v1::default_logger tag) instead.
Exceptions
mongocxx::v1::exceptionwith mongocxx::v1::instance::errc::multiple_instances if an instance object has already been created.
See also

◆ instance() [4/5]

mongocxx::v1::instance::instance ( std::unique_ptr< v1::logger > handler)
explicit

Initialize the mongoc library with the custom unstructured log message handler.

Calls mongoc_init after registering the custom unstructured log handler by calling mongoc_log_set_handler().

Parameters
handlerDisable unstructured logging when null.
Exceptions
mongocxx::v1::exceptionwith mongocxx::v1::instance::errc::multiple_instances if an instance object has already been created.
See also

◆ instance() [5/5]

mongocxx::v1::instance::instance ( v1::default_logger tag)
explicit

Initialize the mongoc library with its default unstructured log handler.

Calls mongoc_init without registering any custom unstructured log handler.

Parameters
tagUnused: only for overload resolution.
Exceptions
mongocxx::v1::exceptionwith mongocxx::v1::instance::errc::multiple_instances if an instance object has already been created.

Member Function Documentation

◆ error_category()

std::error_category const & mongocxx::v1::instance::error_category ( )
static

The error category for mongocxx::v1::instance::errc.

Attention
This feature is experimental! It is not ready for use!

◆ operator=() [1/2]

instance & mongocxx::v1::instance::operator= ( instance && )
delete

This class is not moveable.

◆ operator=() [2/2]

instance & mongocxx::v1::instance::operator= ( instance const & )
delete

This class is not copyable.

◆ make_error_code

std::error_code make_error_code ( errc v)
friend

Support implicit conversion to std::error_code.

Attention
This feature is experimental! It is not ready for use!

The documentation for this class was generated from the following file: