MongoDB C++ Driver  mongocxx-3.9.0
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
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 
29 namespace mongocxx {
30 inline namespace v_noabi {
42 class MONGOCXX_API uri {
43  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 
132  class read_concern read_concern() const;
133 
139  class read_preference read_preference() const;
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 
183  class write_concern write_concern() const;
184 
190  stdx::optional<stdx::string_view> appname() const;
191 
197  stdx::optional<bsoncxx::document::view> auth_mechanism_properties() const;
198 
204  stdx::optional<bsoncxx::document::view> credentials();
205 
211  stdx::optional<std::int32_t> srv_max_hosts() const;
212 
219  std::vector<stdx::string_view> compressors() const;
220 
226  stdx::optional<std::int32_t> connect_timeout_ms() const;
227 
233  stdx::optional<bool> direct_connection() const;
234 
240  stdx::optional<std::int32_t> heartbeat_frequency_ms() const;
241 
247  stdx::optional<std::int32_t> local_threshold_ms() const;
248 
254  stdx::optional<std::int32_t> max_pool_size() const;
255 
261  stdx::optional<bool> retry_reads() const;
262 
268  stdx::optional<bool> retry_writes() const;
269 
275  stdx::optional<std::int32_t> server_selection_timeout_ms() const;
276 
282  stdx::optional<bool> server_selection_try_once() const;
283 
289  stdx::optional<std::int32_t> socket_timeout_ms() const;
290 
296  stdx::optional<bool> tls_allow_invalid_certificates() const;
297 
303  stdx::optional<bool> tls_allow_invalid_hostnames() const;
304 
310  stdx::optional<stdx::string_view> tls_ca_file() const;
311 
317  stdx::optional<stdx::string_view> tls_certificate_key_file() const;
318 
324  stdx::optional<stdx::string_view> tls_certificate_key_file_password() const;
325 
332  stdx::optional<bool> tls_disable_certificate_revocation_check() const;
333 
339  stdx::optional<bool> tls_disable_ocsp_endpoint_check() const;
340 
346  stdx::optional<bool> tls_insecure() const;
347 
353  stdx::optional<std::int32_t> wait_queue_timeout_ms() const;
354 
360  stdx::optional<std::int32_t> zlib_compression_level() const;
361 
362  private:
363  friend class client;
364  friend class pool;
365 
366  class MONGOCXX_PRIVATE impl;
367 
368  MONGOCXX_PRIVATE uri(std::unique_ptr<impl>&& implementation);
369 
370  std::unique_ptr<impl> _impl;
371 };
372 
373 } // namespace v_noabi
374 } // namespace mongocxx
375 
376 #include <mongocxx/config/postlude.hpp>
Class representing a client connection to MongoDB.
Definition: client.hpp:54
Class representing a MongoDB database.
Definition: database.hpp:44
A pool of client objects associated with a MongoDB deployment.
Definition: pool.hpp:46
A class to represent the read concern.
Definition: read_concern.hpp:57
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition: read_preference.hpp:67
Class representing a MongoDB connection string URI.
Definition: uri.hpp:42
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:59
The top-level namespace for bsoncxx library entities.
Definition: element.hpp:24
stdx::string_view to_string(log_level level)
Returns a stringification of the given log level.
The top-level namespace for mongocxx library entities.
Definition: bulk_write.hpp:24
A host.
Definition: uri.hpp:45