MongoDB C++ Driver mongocxx-3.0.3
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
mongocxx::uri Class Reference

Class representing a MongoDB connection string URI. More...

#include <uri.hpp>

Classes

struct  host
 

Public Member Functions

 uri (bsoncxx::string::view_or_value uri_string=k_default_uri)
 Constructs a uri from an optional MongoDB uri string.
 
 uri (uri &&) noexcept
 Move constructs a uri.
 
urioperator= (uri &&) noexcept
 Move assigns a uri.
 
 ~uri ()
 Destroys a uri.
 
std::string auth_mechanism () const
 Returns the authentication mechanism from the uri.
 
std::string auth_source () const
 Returns the authentication source from the uri.
 
std::vector< hosthosts () const
 Returns the hosts from the uri.
 
std::string database () const
 Returns the database from the uri.
 
bsoncxx::document::view options () const
 Returns other uri options.
 
std::string password () const
 Returns the password from the uri.
 
class read_concern read_concern () const
 Returns the read concern from the uri.
 
class read_preference read_preference () const
 Returns the read preference from the uri.
 
std::string replica_set () const
 Returns the replica set specified in the uri.
 
bool ssl () const
 Returns the ssl parameter from the uri.
 
std::string to_string () const
 Returns the uri in a string format.
 
std::string username () const
 Returns the supplied username from the uri.
 
class write_concern write_concern () const
 Returns the write concern specified in the uri.
 

Detailed Description

Class representing a MongoDB connection string URI.

Todo:

return const char* instead or stringview

harmonize with C library (options, credentials, etc...)

See also
http://docs.mongodb.org/manual/reference/connection-string/

Constructor & Destructor Documentation

◆ uri()

mongocxx::uri::uri ( bsoncxx::string::view_or_value  uri_string = k_default_uri)

Constructs a uri from an optional MongoDB uri string.

If no uri string is specified, uses the default uri string, 'mongodb://localhost:27017'.

Parameters
uri_stringString representing a MongoDB connection string uri, defaults to k_default_uri.

Member Function Documentation

◆ auth_mechanism()

std::string mongocxx::uri::auth_mechanism ( ) const

Returns the authentication mechanism from the uri.

Returns
A string representing the authentication mechanism.

◆ auth_source()

std::string mongocxx::uri::auth_source ( ) const

Returns the authentication source from the uri.

Returns
A string representing the authentication source.

◆ database()

std::string mongocxx::uri::database ( ) const

Returns the database from the uri.

Returns
A string with the name of the database.

◆ hosts()

std::vector< host > mongocxx::uri::hosts ( ) const

Returns the hosts from the uri.

Returns
A vector of hosts.

◆ options()

bsoncxx::document::view mongocxx::uri::options ( ) const

Returns other uri options.

Returns
A document view containing other options.

◆ password()

std::string mongocxx::uri::password ( ) const

Returns the password from the uri.

Returns
A string containing the supplied password.

◆ read_concern()

class read_concern mongocxx::uri::read_concern ( ) const

Returns the read concern from the uri.

Returns
A read_concern that represents what was specified in the uri.

◆ read_preference()

class read_preference mongocxx::uri::read_preference ( ) const

Returns the read preference from the uri.

Returns
A read_preference that represents what was specified in the uri.

◆ replica_set()

std::string mongocxx::uri::replica_set ( ) const

Returns the replica set specified in the uri.

Returns
A string representing the supplied replica set name.

◆ ssl()

bool mongocxx::uri::ssl ( ) const

Returns the ssl parameter from the uri.

Returns
Boolean that is true if ssl is enabled and false if not.

◆ to_string()

std::string mongocxx::uri::to_string ( ) const

Returns the uri in a string format.

Returns
A string with the uri.

◆ username()

std::string mongocxx::uri::username ( ) const

Returns the supplied username from the uri.

Returns
A string with the username specified in the uri.

◆ write_concern()

class write_concern mongocxx::uri::write_concern ( ) const

Returns the write concern specified in the uri.

Returns
A write_concern that represents what was specified in the uri.

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