Loading...
Searching...
No Matches
mongocxx::instance Class Reference

`#include <mongocxx/v_noabi/mongocxx/instance.hpp>`

## Description

An instance of the MongoDB C++ Driver.

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.
{
mongocxx::v1::instance instance;
// MAY call mongocxx API at this point.
// ...
}
// MUST NOT call mongocxx API after this point.
// ...
}
mongocxx::instance::instance
instance()
Creates an instance of the driver.
mongocxx::v1::instance
An instance of the MongoDB C++ Driver.
Definition instance.hpp:64

Special exemptions
  Only the following API are permitted to be used outside the lifetime of an instance object:
  - mongocxx::v1::logger
  - mongocxx::v1::default_logger

See also
  - Initialization and Cleanup (mongoc)

## Public Member Functions

| instance ()
| Creates an instance of the driver.
| instance (instance &&other) noexcept
| Move constructs an instance of the driver.
| instance (instance const &)=delete
| This class is not copyable.
| instance (std::unique_ptr< v_noabi::logger > logger)
| Creates an instance of the driver with a user provided log handler.
| ~instance ()
| Destroys an instance of the driver.
instance & | operator= (instance &&other) noexcept
| Move assigns an instance of the driver.
instance & | operator= (instance const &)=delete
| This class is not copyable.

## Static Public Member Functions

static instance & | current ()

## Constructor & Destructor Documentation

## instance() [1/4]

mongocxx::v_noabi::instance::instance | ( |  | ) |

Creates an instance of the driver.

## instance() [2/4]

mongocxx::v_noabi::instance::instance | ( | std::unique_ptr< v_noabi::logger > | logger | ) |

Creates an instance of the driver with a user provided log handler.

Parameters

  logger | The logger that the driver will direct log messages to.

Exceptions

  mongocxx::v_noabi::logic_error | if an instance already exists.

## instance() [3/4]

mongocxx::v_noabi::instance::instance | ( | instance && | other | ) |

noexcept

Move constructs an instance of the driver.

Postconditions:
  - other is in an assign-or-destroy-only state.

## instance() [4/4]

mongocxx::v_noabi::instance::instance | ( | instance const & |  | ) |

delete

This class is not copyable.

## ~instance()

mongocxx::v_noabi::instance::~instance | ( |  | ) |

Destroys an instance of the driver.

## Member Function Documentation

## current()

instance & mongocxx::v_noabi::instance::current | ( |  | ) |

static

Warning
  For internal use only!

## operator=() [1/2]

instance & mongocxx::v_noabi::instance::operator= | ( | instance && | other | ) |

noexcept

Move assigns an instance of the driver.

Postconditions:
  - other is in an assign-or-destroy-only state.

## operator=() [2/2]

instance & mongocxx::v_noabi::instance::operator= | ( | instance const & |  | ) |

delete

This class is not copyable.

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

- mongocxx/v_noabi/mongocxx/instance.hpp