MongoDB C++ Driver  mongocxx-3.1.0
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. More...
 
 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. More...
 
std::string auth_source () const
 Returns the authentication source from the uri. More...
 
std::vector< hosthosts () const
 Returns the hosts from the uri. More...
 
std::string database () const
 Returns the database from the uri. More...
 
bsoncxx::document::view options () const
 Returns other uri options. More...
 
std::string password () const
 Returns the password from the uri. More...
 
class read_concern read_concern () const
 Returns the read concern from the uri. More...
 
class read_preference read_preference () const
 Returns the read preference from the uri. More...
 
std::string replica_set () const
 Returns the replica set specified in the uri. More...
 
bool ssl () const
 Returns the ssl parameter from the uri. More...
 
std::string to_string () const
 Returns the uri in a string format. More...
 
std::string username () const
 Returns the supplied username from the uri. More...
 
class write_concern write_concern () const
 Returns the write concern specified in the uri. More...
 

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
https://docs.mongodb.com/master/reference/connection-string/

Constructor & Destructor Documentation

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

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

Returns the authentication mechanism from the uri.

Returns
A string representing the authentication mechanism.
std::string mongocxx::uri::auth_source ( ) const

Returns the authentication source from the uri.

Returns
A string representing the authentication source.
std::string mongocxx::uri::database ( ) const

Returns the database from the uri.

Returns
A string with the name of the database.
std::vector<host> mongocxx::uri::hosts ( ) const

Returns the hosts from the uri.

Returns
A vector of hosts.
bsoncxx::document::view mongocxx::uri::options ( ) const

Returns other uri options.

Returns
A document view containing other options.
std::string mongocxx::uri::password ( ) const

Returns the password from the uri.

Returns
A string containing the supplied password.
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.
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.
std::string mongocxx::uri::replica_set ( ) const

Returns the replica set specified in the uri.

Returns
A string representing the supplied replica set name.
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.
std::string mongocxx::uri::to_string ( ) const

Returns the uri in a string format.

Returns
A string with the uri.
std::string mongocxx::uri::username ( ) const

Returns the supplied username from the uri.

Returns
A string with the username specified in the uri.
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: