MongoDB C++ Driver  mongocxx-3.7.0
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 MONGOCXX_INLINE_NAMESPACE_BEGIN
31 
43 class MONGOCXX_API uri {
44  public:
46  struct host {
47  std::string name;
48  std::uint16_t port;
49  std::int32_t family;
50  };
51 
52  static const std::string k_default_uri;
53 
65  uri(bsoncxx::string::view_or_value uri_string = k_default_uri);
66 
70  uri(uri&&) noexcept;
71 
75  uri& operator=(uri&&) noexcept;
76 
80  ~uri();
81 
87  std::string auth_mechanism() const;
88 
94  std::string auth_source() const;
95 
101  std::vector<host> hosts() const;
102 
108  std::string database() const;
109 
119  bsoncxx::document::view options() const;
120 
126  std::string password() const;
127 
133  class read_concern read_concern() const;
134 
140  class read_preference read_preference() const;
141 
147  std::string replica_set() const;
148 
156  MONGOCXX_DEPRECATED bool ssl() const;
157 
163  bool tls() const;
164 
170  std::string to_string() const;
171 
177  std::string username() const;
178 
184  class write_concern write_concern() const;
185 
191  stdx::optional<stdx::string_view> appname() const;
192 
198  stdx::optional<bsoncxx::document::view> auth_mechanism_properties() const;
199 
206  std::vector<stdx::string_view> compressors() const;
207 
213  stdx::optional<std::int32_t> connect_timeout_ms() const;
214 
220  stdx::optional<bool> direct_connection() const;
221 
227  stdx::optional<std::int32_t> heartbeat_frequency_ms() const;
228 
234  stdx::optional<std::int32_t> local_threshold_ms() const;
235 
241  stdx::optional<std::int32_t> max_pool_size() const;
242 
248  stdx::optional<bool> retry_reads() const;
249 
255  stdx::optional<bool> retry_writes() const;
256 
262  stdx::optional<std::int32_t> server_selection_timeout_ms() const;
263 
269  stdx::optional<bool> server_selection_try_once() const;
270 
276  stdx::optional<std::int32_t> socket_timeout_ms() const;
277 
283  stdx::optional<bool> tls_allow_invalid_certificates() const;
284 
290  stdx::optional<bool> tls_allow_invalid_hostnames() const;
291 
297  stdx::optional<stdx::string_view> tls_ca_file() const;
298 
304  stdx::optional<stdx::string_view> tls_certificate_key_file() const;
305 
311  stdx::optional<stdx::string_view> tls_certificate_key_file_password() const;
312 
319  stdx::optional<bool> tls_disable_certificate_revocation_check() const;
320 
326  stdx::optional<bool> tls_disable_ocsp_endpoint_check() const;
327 
333  stdx::optional<bool> tls_insecure() const;
334 
340  stdx::optional<std::int32_t> wait_queue_timeout_ms() const;
341 
347  stdx::optional<std::int32_t> zlib_compression_level() const;
348 
349  private:
350  friend class client;
351  friend class pool;
352 
353  class MONGOCXX_PRIVATE impl;
354 
355  MONGOCXX_PRIVATE uri(std::unique_ptr<impl>&& implementation);
356 
357  std::unique_ptr<impl> _impl;
358 };
359 
360 MONGOCXX_INLINE_NAMESPACE_END
361 } // namespace mongocxx
362 
363 #include <mongocxx/config/postlude.hpp>
mongocxx::pool
A pool of client objects associated with a MongoDB deployment.
Definition: pool.hpp:47
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
bsoncxx
Top level namespace for MongoDB C++ BSON functionality.
Definition: element.hpp:24
mongocxx::write_concern
Class representing the server-side requirement for reporting the success of a write operation.
Definition: write_concern.hpp:56
mongocxx::to_string
stdx::string_view to_string(log_level level)
Returns a stringification of the given log level.
mongocxx::client
Class representing a client connection to MongoDB.
Definition: client.hpp:58
mongocxx::read_concern
A class to represent the read concern.
Definition: read_concern.hpp:54
mongocxx::read_preference
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition: read_preference.hpp:63
bsoncxx::string::view_or_value
Class representing a view-or-value variant type for strings.
Definition: view_or_value.hpp:36
mongocxx::uri
Class representing a MongoDB connection string URI.
Definition: uri.hpp:43
mongocxx::database
Class representing a MongoDB database.
Definition: database.hpp:43
mongocxx::uri::host
A host.
Definition: uri.hpp:46