Loading...
Searching...
No Matches
mongocxx::v_noabi::uri Class Reference

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

## Description

A MongoDB connection string URI.

See also
  - Connection Strings (MongoDB Manual)

## Public Member Functions

| uri ()
| Constructs a uri from the default MongoDB URI string: "mongodb://localhost:27017".
| uri (uri &&other) noexcept=default
| Move constructs a uri.
| uri (v1::uri uri)
| Construct with the mongocxx::v1 equivalent.
| ~uri ()=default
| Destroys a uri.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::stdx::string_view > | appname () const
| Returns the value of the option "appname" if present in the uri.
std::string | auth_mechanism () const
| Returns the authentication mechanism from the uri.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view > | auth_mechanism_properties () const
| Returns the value of the option "authMechanismProperties" if present in the uri.
std::string | auth_source () const
| Returns the authentication source from the uri.
std::vector< bsoncxx::v_noabi::stdx::string_view > | compressors () const
| Returns the list of compressors present in the uri or an empty list if "compressors" was not present or contained no valid compressors.
bsoncxx::v_noabi::stdx::optional< std::int32_t > | connect_timeout_ms () const
| Returns the value of the option "connectTimeoutMS" if present in the uri.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view > | credentials ()
| Returns the value of the option credentials if present in the uri.
std::string | database () const
| Returns the database from the uri.
bsoncxx::v_noabi::stdx::optional< bool > | direct_connection () const
| Returns the value of the option "directConnection" if present in the uri.
bsoncxx::v_noabi::stdx::optional< bool > | enable_overload_retargeting () const
| Returns the value of the option "enableOverloadRetargeting" if present in the uri.
bsoncxx::v_noabi::stdx::optional< std::int32_t > | heartbeat_frequency_ms () const
| Returns the value of the option "heartbeatFrequencyMS" if present in the uri.
std::vector< host > | hosts () const
| Returns the hosts from the uri.
bsoncxx::v_noabi::stdx::optional< std::int32_t > | local_threshold_ms () const
| Returns the value of the option "localThresholdMS" if present in the uri.
bsoncxx::v_noabi::stdx::optional< std::int32_t > | max_adaptive_retries () const
| Returns the value of the option "maxAdaptiveRetries" if present in the uri.
bsoncxx::v_noabi::stdx::optional< std::int32_t > | max_pool_size () const
| Returns the value of the option "maxPoolSize" if present in the uri.
| operator v1::uri () &&
| Convert to the mongocxx::v1 equivalent.
| operator v1::uri () const &
| Convert to the mongocxx::v1 equivalent.
uri & | operator= (uri &&other) noexcept=default
| Move assigns a uri.
bsoncxx::v_noabi::document::view | options () const
| Returns other uri options.
std::string | password () const
| Returns the password from the uri.
v_noabi::read_concern | read_concern () const
| Returns the read concern from the uri.
v_noabi::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.
bsoncxx::v_noabi::stdx::optional< bool > | retry_reads () const
| Returns the value of the option "retryReads" if present in the uri.
bsoncxx::v_noabi::stdx::optional< bool > | retry_writes () const
| Returns the value of the option "retryWrites" if present in the uri.
bsoncxx::v_noabi::stdx::optional< std::int32_t > | server_selection_timeout_ms () const
| Returns the value of the option "serverSelectionTimeoutMS" if present in the uri.
bsoncxx::v_noabi::stdx::optional< bool > | server_selection_try_once () const
| Returns the value of the option "serverSelectionTryOnce" if present in the uri.
void | server_selection_try_once (bool val)
| Sets the value of the option "serverSelectionTryOnce" in the uri.
bsoncxx::v_noabi::stdx::optional< std::int32_t > | socket_timeout_ms () const
| Returns the value of the option "socketTimeoutMS" if present in the uri.
bsoncxx::v_noabi::stdx::optional< std::int32_t > | srv_max_hosts () const
| Returns the value of the option "srvMaxHosts" if present in the uri.
bool | ssl () const
| Returns the ssl parameter from the uri.
bool | tls () const
| Returns the tls parameter from the uri.
bsoncxx::v_noabi::stdx::optional< bool > | tls_allow_invalid_certificates () const
| Returns the value of the option "tlsAllowInvalidCertificates" if present in the uri.
bsoncxx::v_noabi::stdx::optional< bool > | tls_allow_invalid_hostnames () const
| Returns the value of the option "tlsAllowInvalidHostnames" if present in the uri.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::stdx::string_view > | tls_ca_file () const
| Returns the value of the option "tlsCAFile" if present in the uri.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::stdx::string_view > | tls_certificate_key_file () const
| Returns the value of the option "tlsCertificateKeyFile" if present in the uri.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::stdx::string_view > | tls_certificate_key_file_password () const
| Returns the value of the option "tlsCertificateKeyFilePassword" if present in the uri.
bsoncxx::v_noabi::stdx::optional< bool > | tls_disable_certificate_revocation_check () const
| Returns the value of the option "tlsDisableCertificateRevocationCheck" if present in the uri.
bsoncxx::v_noabi::stdx::optional< bool > | tls_disable_ocsp_endpoint_check () const
| Returns the value of the option "tlsDisableOCSPEndpointCheck" if present in the uri.
bsoncxx::v_noabi::stdx::optional< bool > | tls_insecure () const
| Returns the value of the option "tlsInsecure" if present in 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.
bsoncxx::v_noabi::stdx::optional< std::int32_t > | wait_queue_timeout_ms () const
| Returns the value of the option "waitQueueTimeoutMS" if present in the uri.
v_noabi::write_concern | write_concern () const
| Returns the write concern specified in the uri.
bsoncxx::v_noabi::stdx::optional< std::int32_t > | zlib_compression_level () const
| Returns the value of the option "zlibCompressionLevel" if present in the uri.
| uri (bsoncxx::v_noabi::string::view_or_value uri_string)
| Constructs a uri from the provided MongoDB URI string.
template<typename T, bsoncxx::detail::enable_if_t< std::is_convertible< T, bsoncxx::v_noabi::string::view_or_value >::value > * = nullptr>
| uri (T t)
| Constructs a uri from the provided MongoDB URI string.

## Static Public Attributes

static const std::string | k_default_uri
| The default URI string: "mongodb://localhost:27017".

## Constructor & Destructor Documentation

## uri() [1/5]

mongocxx::v_noabi::uri::uri | ( | bsoncxx::v_noabi::string::view_or_value | uri_string | ) |

Constructs a uri from the provided MongoDB URI string.

See also
  - https://mongoc.org/libmongoc/current/mongoc_uri_t.html

## uri() [2/5]

template<typename T, bsoncxx::detail::enable_if_t< std::is_convertible< T, bsoncxx::v_noabi::string::view_or_value >::value > * = nullptr>

mongocxx::v_noabi::uri::uri | ( | T | t | ) |

inline

Constructs a uri from the provided MongoDB URI string.

See also
  - https://mongoc.org/libmongoc/current/mongoc_uri_t.html

## uri() [3/5]

mongocxx::v_noabi::uri::uri | ( |  | ) |

inline

Constructs a uri from the default MongoDB URI string: "mongodb://localhost:27017".

See also
  - https://mongoc.org/libmongoc/current/mongoc_uri_t.html

## uri() [4/5]

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

default noexcept

Move constructs a uri.

## ~uri()

mongocxx::v_noabi::uri::~uri | ( |  | ) |

default

Destroys a uri.

## uri() [5/5]

mongocxx::v_noabi::uri::uri | ( | v1::uri | uri | ) |

inline

Construct with the mongocxx::v1 equivalent.

## Member Function Documentation

## appname()

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::stdx::string_view > mongocxx::v_noabi::uri::appname | ( |  | ) | const

inline

Returns the value of the option "appname" if present in the uri.

Returns
  An optional bsoncxx::v_noabi::stdx::string_view

## auth_mechanism()

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

inline

Returns the authentication mechanism from the uri.

Returns
  A string representing the authentication mechanism.

## auth_mechanism_properties()

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view > mongocxx::v_noabi::uri::auth_mechanism_properties | ( |  | ) | const

inline

Returns the value of the option "authMechanismProperties" if present in the uri.

Returns
  An optional bsoncxx::v_noabi::document::view

## auth_source()

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

inline

Returns the authentication source from the uri.

Returns
  A string representing the authentication source.

## compressors()

std::vector< bsoncxx::v_noabi::stdx::string_view > mongocxx::v_noabi::uri::compressors | ( |  | ) | const

inline

Returns the list of compressors present in the uri or an empty list if "compressors" was not present or contained no valid compressors.

Returns
  A std::vector of bsoncxx::v_noabi::stdx::string_view.

## connect_timeout_ms()

bsoncxx::v_noabi::stdx::optional< std::int32_t > mongocxx::v_noabi::uri::connect_timeout_ms | ( |  | ) | const

inline

Returns the value of the option "connectTimeoutMS" if present in the uri.

Returns
  An optional std::int32_t

## credentials()

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view > mongocxx::v_noabi::uri::credentials | ( |  | ) |

Returns the value of the option credentials if present in the uri.

Returns
  An optional bsoncxx::v_noabi::document::view

## database()

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

inline

Returns the database from the uri.

Returns
  A string with the name of the database.

## direct_connection()

bsoncxx::v_noabi::stdx::optional< bool > mongocxx::v_noabi::uri::direct_connection | ( |  | ) | const

inline

Returns the value of the option "directConnection" if present in the uri.

Returns
  An optional bool

## enable_overload_retargeting()

bsoncxx::v_noabi::stdx::optional< bool > mongocxx::v_noabi::uri::enable_overload_retargeting | ( |  | ) | const

inline

Returns the value of the option "enableOverloadRetargeting" if present in the uri.

Returns
  An optional bool

## heartbeat_frequency_ms()

bsoncxx::v_noabi::stdx::optional< std::int32_t > mongocxx::v_noabi::uri::heartbeat_frequency_ms | ( |  | ) | const

inline

Returns the value of the option "heartbeatFrequencyMS" if present in the uri.

Returns
  An optional std::int32_t

## hosts()

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

inline

Returns the hosts from the uri.

Returns
  A vector of hosts.

## local_threshold_ms()

bsoncxx::v_noabi::stdx::optional< std::int32_t > mongocxx::v_noabi::uri::local_threshold_ms | ( |  | ) | const

inline

Returns the value of the option "localThresholdMS" if present in the uri.

Returns
  An optional std::int32_t

## max_adaptive_retries()

bsoncxx::v_noabi::stdx::optional< std::int32_t > mongocxx::v_noabi::uri::max_adaptive_retries | ( |  | ) | const

inline

Returns the value of the option "maxAdaptiveRetries" if present in the uri.

Returns
  An optional std::int32_t

## max_pool_size()

bsoncxx::v_noabi::stdx::optional< std::int32_t > mongocxx::v_noabi::uri::max_pool_size | ( |  | ) | const

inline

Returns the value of the option "maxPoolSize" if present in the uri.

Returns
  An optional std::int32_t

## operator v1::uri() [1/2]

mongocxx::v_noabi::uri::operator v1::uri | ( |  | ) | &&

inline explicit

Convert to the mongocxx::v1 equivalent.

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

Warning
  Invalidates all associated views.

## operator v1::uri() [2/2]

mongocxx::v_noabi::uri::operator v1::uri | ( |  | ) | const &

inline explicit

Convert to the mongocxx::v1 equivalent.

## operator=()

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

default noexcept

Move assigns a uri.

## options()

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

inline

Returns other uri options.

Note, options are returned in the case they were presented. The URI mongodb://localhost/?appName=abc will return { "appName": "abc" } The URI mongodb://localhost/?appname=abc will return { "appname": "abc" }

Returns
  A document view containing other options.

## password()

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

inline

Returns the password from the uri.

Returns
  A string containing the supplied password.

## read_concern()

v_noabi::read_concern mongocxx::v_noabi::uri::read_concern | ( |  | ) | const

inline

Returns the read concern from the uri.

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

## read_preference()

v_noabi::read_preference mongocxx::v_noabi::uri::read_preference | ( |  | ) | const

inline

Returns the read preference from the uri.

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

## replica_set()

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

inline

Returns the replica set specified in the uri.

Returns
  A string representing the supplied replica set name.

## retry_reads()

bsoncxx::v_noabi::stdx::optional< bool > mongocxx::v_noabi::uri::retry_reads | ( |  | ) | const

inline

Returns the value of the option "retryReads" if present in the uri.

Returns
  An optional bool

## retry_writes()

bsoncxx::v_noabi::stdx::optional< bool > mongocxx::v_noabi::uri::retry_writes | ( |  | ) | const

inline

Returns the value of the option "retryWrites" if present in the uri.

Returns
  An optional bool

## server_selection_timeout_ms()

bsoncxx::v_noabi::stdx::optional< std::int32_t > mongocxx::v_noabi::uri::server_selection_timeout_ms | ( |  | ) | const

inline

Returns the value of the option "serverSelectionTimeoutMS" if present in the uri.

Returns
  An optional std::int32_t

## server_selection_try_once() [1/2]

bsoncxx::v_noabi::stdx::optional< bool > mongocxx::v_noabi::uri::server_selection_try_once | ( |  | ) | const

inline

Returns the value of the option "serverSelectionTryOnce" if present in the uri.

Returns
  An optional bool

## server_selection_try_once() [2/2]

void mongocxx::v_noabi::uri::server_selection_try_once | ( | bool | val | ) |

Sets the value of the option "serverSelectionTryOnce" in the uri.

Parameters

  val | The new value to apply to as "serverSelectionTryOnce".

Exceptions

  mongocxx::v_noabi::exception | if there is an error setting the option.

## socket_timeout_ms()

bsoncxx::v_noabi::stdx::optional< std::int32_t > mongocxx::v_noabi::uri::socket_timeout_ms | ( |  | ) | const

inline

Returns the value of the option "socketTimeoutMS" if present in the uri.

Returns
  An optional std::int32_t

## srv_max_hosts()

bsoncxx::v_noabi::stdx::optional< std::int32_t > mongocxx::v_noabi::uri::srv_max_hosts | ( |  | ) | const

inline

Returns the value of the option "srvMaxHosts" if present in the uri.

Returns
  An optional std::int32_t

## ssl()

bool mongocxx::v_noabi::uri::ssl | ( |  | ) | const

inline

Returns the ssl parameter from the uri.

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

Deprecated
  The tls() method should be used instead of this method.

## tls()

bool mongocxx::v_noabi::uri::tls | ( |  | ) | const

inline

Returns the tls parameter from the uri.

Returns
  Boolean that is `true` if tls is enabled and `false` if not.

## tls_allow_invalid_certificates()

bsoncxx::v_noabi::stdx::optional< bool > mongocxx::v_noabi::uri::tls_allow_invalid_certificates | ( |  | ) | const

inline

Returns the value of the option "tlsAllowInvalidCertificates" if present in the uri.

Returns
  An optional bool

## tls_allow_invalid_hostnames()

bsoncxx::v_noabi::stdx::optional< bool > mongocxx::v_noabi::uri::tls_allow_invalid_hostnames | ( |  | ) | const

inline

Returns the value of the option "tlsAllowInvalidHostnames" if present in the uri.

Returns
  An optional bool

## tls_ca_file()

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::stdx::string_view > mongocxx::v_noabi::uri::tls_ca_file | ( |  | ) | const

inline

Returns the value of the option "tlsCAFile" if present in the uri.

Returns
  An optional bsoncxx::v_noabi::stdx::string_view

## tls_certificate_key_file()

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::stdx::string_view > mongocxx::v_noabi::uri::tls_certificate_key_file | ( |  | ) | const

inline

Returns the value of the option "tlsCertificateKeyFile" if present in the uri.

Returns
  An optional bsoncxx::v_noabi::stdx::string_view

## tls_certificate_key_file_password()

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::stdx::string_view > mongocxx::v_noabi::uri::tls_certificate_key_file_password | ( |  | ) | const

inline

Returns the value of the option "tlsCertificateKeyFilePassword" if present in the uri.

Returns
  An optional bsoncxx::v_noabi::stdx::string_view

## tls_disable_certificate_revocation_check()

bsoncxx::v_noabi::stdx::optional< bool > mongocxx::v_noabi::uri::tls_disable_certificate_revocation_check | ( |  | ) | const

inline

Returns the value of the option "tlsDisableCertificateRevocationCheck" if present in the uri.

Returns
  An optional bool

## tls_disable_ocsp_endpoint_check()

bsoncxx::v_noabi::stdx::optional< bool > mongocxx::v_noabi::uri::tls_disable_ocsp_endpoint_check | ( |  | ) | const

inline

Returns the value of the option "tlsDisableOCSPEndpointCheck" if present in the uri.

Returns
  An optional bool

## tls_insecure()

bsoncxx::v_noabi::stdx::optional< bool > mongocxx::v_noabi::uri::tls_insecure | ( |  | ) | const

inline

Returns the value of the option "tlsInsecure" if present in the uri.

Returns
  An optional bool

## to_string()

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

inline

Returns the uri in a string format.

Returns
  A string with the uri.

## username()

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

inline

Returns the supplied username from the uri.

Returns
  A string with the username specified in the uri.

## wait_queue_timeout_ms()

bsoncxx::v_noabi::stdx::optional< std::int32_t > mongocxx::v_noabi::uri::wait_queue_timeout_ms | ( |  | ) | const

inline

Returns the value of the option "waitQueueTimeoutMS" if present in the uri.

Returns
  An optional std::int32_t

## write_concern()

v_noabi::write_concern mongocxx::v_noabi::uri::write_concern | ( |  | ) | const

inline

Returns the write concern specified in the uri.

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

## zlib_compression_level()

bsoncxx::v_noabi::stdx::optional< std::int32_t > mongocxx::v_noabi::uri::zlib_compression_level | ( |  | ) | const

inline

Returns the value of the option "zlibCompressionLevel" if present in the uri.

Returns
  An optional std::int32_t

## Member Data Documentation

## k_default_uri

const std::string mongocxx::v_noabi::uri::k_default_uri

static

The default URI string: "mongodb://localhost:27017".

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

- mongocxx/v_noabi/mongocxx/uri.hpp