MongoDB C++ Driver mongocxx-3.6.7
uri.hpp
1// Copyright 2014 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
21#include <bsoncxx/document/view.hpp>
22#include <bsoncxx/string/view_or_value.hpp>
23#include <mongocxx/read_concern.hpp>
24#include <mongocxx/read_preference.hpp>
25#include <mongocxx/write_concern.hpp>
26
27#include <mongocxx/config/prelude.hpp>
28
29namespace mongocxx {
30MONGOCXX_INLINE_NAMESPACE_BEGIN
31
43class MONGOCXX_API uri {
44 public:
45 struct host {
46 std::string name;
47 std::uint16_t port;
48 std::int32_t family;
49 };
50
51 static const std::string k_default_uri;
52
64 uri(bsoncxx::string::view_or_value uri_string = k_default_uri);
65
69 uri(uri&&) noexcept;
70
74 uri& operator=(uri&&) noexcept;
75
79 ~uri();
80
86 std::string auth_mechanism() const;
87
93 std::string auth_source() const;
94
100 std::vector<host> hosts() const;
101
107 std::string database() const;
108
118 bsoncxx::document::view options() const;
119
125 std::string password() const;
126
133
140
146 std::string replica_set() const;
147
155 MONGOCXX_DEPRECATED bool ssl() const;
156
162 bool tls() const;
163
169 std::string to_string() const;
170
176 std::string username() const;
177
184
190 stdx::optional<stdx::string_view> appname() const;
191
197 stdx::optional<bsoncxx::document::view> auth_mechanism_properties() const;
198
205 std::vector<stdx::string_view> compressors() const;
206
212 stdx::optional<std::int32_t> connect_timeout_ms() const;
213
219 stdx::optional<bool> direct_connection() const;
220
226 stdx::optional<std::int32_t> heartbeat_frequency_ms() const;
227
233 stdx::optional<std::int32_t> local_threshold_ms() const;
234
240 stdx::optional<std::int32_t> max_pool_size() const;
241
247 stdx::optional<bool> retry_reads() const;
248
254 stdx::optional<bool> retry_writes() const;
255
261 stdx::optional<std::int32_t> server_selection_timeout_ms() const;
262
268 stdx::optional<bool> server_selection_try_once() const;
269
275 stdx::optional<std::int32_t> socket_timeout_ms() const;
276
282 stdx::optional<bool> tls_allow_invalid_certificates() const;
283
289 stdx::optional<bool> tls_allow_invalid_hostnames() const;
290
296 stdx::optional<stdx::string_view> tls_ca_file() const;
297
303 stdx::optional<stdx::string_view> tls_certificate_key_file() const;
304
310 stdx::optional<stdx::string_view> tls_certificate_key_file_password() const;
311
318 stdx::optional<bool> tls_disable_certificate_revocation_check() const;
319
325 stdx::optional<bool> tls_disable_ocsp_endpoint_check() const;
326
332 stdx::optional<bool> tls_insecure() const;
333
339 stdx::optional<std::int32_t> wait_queue_timeout_ms() const;
340
346 stdx::optional<std::int32_t> zlib_compression_level() const;
347
348 private:
349 friend class client;
350 friend class pool;
351
352 class MONGOCXX_PRIVATE impl;
353
354 MONGOCXX_PRIVATE uri(std::unique_ptr<impl>&& implementation);
355
356 std::unique_ptr<impl> _impl;
357};
358
359MONGOCXX_INLINE_NAMESPACE_END
360} // namespace mongocxx
361
362#include <mongocxx/config/postlude.hpp>
Class representing a view-or-value variant type for strings.
Definition: view_or_value.hpp:36
Class representing a client connection to MongoDB.
Definition: client.hpp:58
Class representing a MongoDB database.
Definition: database.hpp:43
A pool of client objects associated with a MongoDB deployment.
Definition: pool.hpp:47
A class to represent the read concern.
Definition: read_concern.hpp:54
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition: read_preference.hpp:62
Class representing a MongoDB connection string URI.
Definition: uri.hpp:43
uri(uri &&) noexcept
Move constructs a uri.
uri(bsoncxx::string::view_or_value uri_string=k_default_uri)
Constructs a uri from an optional MongoDB URI string.
Class representing the server-side requirement for reporting the success of a write operation.
Definition: write_concern.hpp:56
Top level namespace for MongoDB C++ BSON functionality.
Definition: element.hpp:24
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
stdx::string_view to_string(log_level level)
Returns a stringification of the given log level.
Definition: uri.hpp:45