MongoDB C++ Driver  mongocxx-3.0.3
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 
40 class MONGOCXX_API uri {
41  public:
42  struct host {
43  std::string name;
44  std::uint16_t port;
45  std::int32_t family;
46  };
47 
48  static const std::string k_default_uri;
49 
57  uri(bsoncxx::string::view_or_value uri_string = k_default_uri);
58 
62  uri(uri&&) noexcept;
63 
67  uri& operator=(uri&&) noexcept;
68 
72  ~uri();
73 
79  std::string auth_mechanism() const;
80 
86  std::string auth_source() const;
87 
93  std::vector<host> hosts() const;
94 
100  std::string database() const;
101 
107  bsoncxx::document::view options() const;
108 
114  std::string password() const;
115 
121  class read_concern read_concern() const;
122 
128  class read_preference read_preference() const;
129 
135  std::string replica_set() const;
136 
142  bool ssl() const;
143 
149  std::string to_string() const;
150 
156  std::string username() const;
157 
163  class write_concern write_concern() const;
164 
165  private:
166  friend class client;
167  friend class pool;
168 
169  class MONGOCXX_PRIVATE impl;
170 
171  MONGOCXX_PRIVATE uri(std::unique_ptr<impl>&& implementation);
172 
173  std::unique_ptr<impl> _impl;
174 };
175 
176 MONGOCXX_INLINE_NAMESPACE_END
177 } // namespace mongocxx
178 
179 #include <mongocxx/config/postlude.hpp>
Class representing a MongoDB connection string URI.
Definition: uri.hpp:40
Definition: bulk_write.hpp:22
Definition: error_code.hpp:69
Class representing a client connection to MongoDB.
Definition: client.hpp:49
A pool of client objects associated with a MongoDB deployment.
Definition: pool.hpp:49
Class representing a MongoDB database.
Definition: database.hpp:43
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition: read_preference.hpp:54
Class representing a view-or-value variant type for strings.
Definition: view_or_value.hpp:36
A class to represent the read concern.
Definition: read_concern.hpp:46
Definition: element.hpp:24
Class representing the server-side requirement for reporting the success of a write operation...
Definition: write_concern.hpp:54
Definition: uri.hpp:42