MongoDB C++ Driver 4.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
uri.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <memory>
18#include <string>
19#include <vector>
20
22#include <mongocxx/pool-fwd.hpp>
23#include <mongocxx/uri-fwd.hpp>
24
27
31
33
34namespace mongocxx {
35namespace v_noabi {
36
43class uri {
44 public:
48 struct host {
49 std::string name;
50 std::uint16_t port;
51 std::int32_t family;
52 };
53
57 static MONGOCXX_ABI_EXPORT const std::string k_default_uri;
58
70 uri(bsoncxx::v_noabi::string::view_or_value uri_string = k_default_uri);
71
76
80 MONGOCXX_ABI_EXPORT_CDECL(uri&) operator=(uri&&) noexcept;
81
86
87 uri(uri const&) = delete;
88 uri& operator=(uri const&) = delete;
89
96
103
109 MONGOCXX_ABI_EXPORT_CDECL(std::vector<host>) hosts() const;
110
117
128
135
142
149
156
165
172
179
186
193
199 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::stdx::string_view>)
200 appname() const;
201
207 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view>)
209
215 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view>)
217
223 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::int32_t>) srv_max_hosts() const;
224
231 MONGOCXX_ABI_EXPORT_CDECL(std::vector<bsoncxx::v_noabi::stdx::string_view>) compressors() const;
232
238 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::int32_t>)
240
247
253 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::int32_t>)
255
261 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::int32_t>)
263
269 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::int32_t>) max_pool_size() const;
270
276 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bool>) retry_reads() const;
277
283 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bool>) retry_writes() const;
284
290 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::int32_t>)
292
298 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bool>)
300
310
316 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::int32_t>)
318
324 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bool>)
326
332 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bool>)
334
340 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::stdx::string_view>)
341 tls_ca_file() const;
342
348 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::stdx::string_view>)
350
356 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::stdx::string_view>)
358
365 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bool>)
367
373 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bool>)
375
381 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bool>) tls_insecure() const;
382
388 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::int32_t>)
390
396 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::int32_t>)
398
399 private:
400 friend ::mongocxx::v_noabi::client;
401 friend ::mongocxx::v_noabi::pool;
402
403 class impl;
404
405 uri(std::unique_ptr<impl>&& implementation);
406
407 std::unique_ptr<impl> _impl;
408};
409
410} // namespace v_noabi
411} // namespace mongocxx
412
413#include <mongocxx/config/postlude.hpp>
414
uri(bsoncxx::v_noabi::string::view_or_value uri_string=k_default_uri)
Constructs a uri from an optional MongoDB URI string. If no URI string is specified,...
A client connection to a MongoDB server.
Definition client.hpp:61
A pool of reusable client objects connected to the same MongoDB topology.
Definition pool.hpp:54
uri(bsoncxx::v_noabi::string::view_or_value uri_string=k_default_uri)
Constructs a uri from an optional MongoDB URI string. If no URI string is specified,...
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< bool > server_selection_try_once() const
Returns the value of the option "serverSelectionTryOnce" 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.
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.
bool ssl() const
Returns the ssl parameter from the uri.
std::vector< host > hosts() const
Returns the hosts from the uri.
std::string auth_mechanism() const
Returns the authentication mechanism from 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.
bsoncxx::v_noabi::stdx::optional< std::int32_t > max_pool_size() const
Returns the value of the option "maxPoolSize" if present in the uri.
bsoncxx::v_noabi::stdx::optional< std::int32_t > connect_timeout_ms() const
Returns the value of the option "connectTimeoutMS" if present in the uri.
mongocxx::v_noabi::read_preference read_preference() const
Returns the read preference 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.
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.
bsoncxx::v_noabi::stdx::optional< bool > tls_allow_invalid_certificates() const
Returns the value of the option "tlsAllowInvalidCertificates" if present in the uri.
std::string database() const
Returns the database from the 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.
bool tls() const
Returns the tls parameter from the uri.
mongocxx::v_noabi::read_concern read_concern() const
Returns the read concern 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< bsoncxx::v_noabi::document::view > credentials()
Returns the value of the option credentials if present in the uri.
std::string auth_source() const
Returns the authentication source from the uri.
std::string to_string() const
Returns the uri in a string format.
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< std::int32_t > heartbeat_frequency_ms() const
Returns the value of the option "heartbeatFrequencyMS" if present in the uri.
bsoncxx::v_noabi::document::view options() const
Returns other uri options.
static const std::string k_default_uri
The default URI string: "mongodb://localhost:27017".
Definition uri.hpp:57
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< 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_certificate_key_file_password() const
Returns the value of the option "tlsCertificateKeyFilePassword" if present in 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 ...
std::string username() const
Returns the supplied username from 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< std::int32_t > srv_max_hosts() const
Returns the value of the option "srvMaxHosts" if present 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.
std::string password() const
Returns the password from the uri.
bsoncxx::v_noabi::stdx::optional< bool > direct_connection() const
Returns the value of the option "directConnection" if present in the uri.
mongocxx::v_noabi::write_concern write_concern() const
Returns the write concern specified in 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 > tls_disable_ocsp_endpoint_check() const
Returns the value of the option "tlsDisableOCSPEndpointCheck" if present in the uri.
Declares mongocxx::v_noabi::client.
Provides bsoncxx::v_noabi::document::view.
#define MONGOCXX_DEPRECATED
Declares the associated entity as deprecated.
Definition export.hpp:25
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
#define MONGOCXX_ABI_EXPORT
Exports the associated entity as part of the ABI.
Definition export.hpp:15
The mongocxx v_noabi macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities whose ABI stability is NOT guaranteed.
The top-level namespace within which all mongocxx library entities are declared.
Declares mongocxx::v_noabi::pool.
Provides mongocxx::v_noabi::read_concern.
Provides mongocxx::v_noabi::read_preference.
Provides bsoncxx::v_noabi::string::view_or_value.
A host.
Definition uri.hpp:48
A host.
Definition uri.hpp:48
std::int32_t family
The address family.
Definition uri.hpp:51
std::uint16_t port
The port number.
Definition uri.hpp:50
std::string name
The host name.
Definition uri.hpp:49
Declares mongocxx::v_noabi::uri.
Provides mongocxx::v_noabi::write_concern.