MongoDB C++ Driver  mongocxx-3.4.2
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
client.hpp
1 // Copyright 2014-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 
19 #include <mongocxx/client_session.hpp>
20 #include <mongocxx/database.hpp>
21 #include <mongocxx/options/client.hpp>
22 #include <mongocxx/options/client_session.hpp>
23 #include <mongocxx/read_concern.hpp>
24 #include <mongocxx/read_preference.hpp>
25 #include <mongocxx/stdx.hpp>
26 #include <mongocxx/uri.hpp>
27 #include <mongocxx/write_concern.hpp>
28 
29 #include <mongocxx/config/prelude.hpp>
30 
34 namespace mongocxx {
35 MONGOCXX_INLINE_NAMESPACE_BEGIN
36 
37 class client_session;
38 
57 class MONGOCXX_API client {
58  public:
64  client() noexcept;
65 
77  client(const class uri& mongodb_uri, const options::client& options = options::client());
78 
82  client(client&&) noexcept;
83 
87  client& operator=(client&&) noexcept;
88 
92  ~client();
93 
98  explicit operator bool() const noexcept;
99 
116  MONGOCXX_DEPRECATED void read_concern(class read_concern rc);
117  void read_concern_deprecated(class read_concern rc);
118 
124  class read_concern read_concern() const;
125 
142  MONGOCXX_DEPRECATED void read_preference(class read_preference rp);
143  void read_preference_deprecated(class read_preference rp);
144 
152  class read_preference read_preference() const;
153 
159  class uri uri() const;
160 
175  MONGOCXX_DEPRECATED void write_concern(class write_concern wc);
176  void write_concern_deprecated(class write_concern wc);
177 
182  class write_concern write_concern() const;
183 
194  class database database(bsoncxx::string::view_or_value name) const&;
195  class database database(bsoncxx::string::view_or_value name) const&& = delete;
196 
208  MONGOCXX_INLINE class database operator[](bsoncxx::string::view_or_value name) const&;
209  MONGOCXX_INLINE class database operator[](bsoncxx::string::view_or_value name) const&& = delete;
210 
226  cursor list_databases() const;
227 
244  cursor list_databases(const client_session& session) const;
245 
262  cursor list_databases(const bsoncxx::document::view_or_value filter) const;
263 
267 
277  client_session start_session(const options::client_session& options = {});
278 
293  change_stream watch(const options::change_stream& options = {});
294 
306  change_stream watch(const client_session& session, const options::change_stream& options = {});
307 
324  change_stream watch(const pipeline& pipe, const options::change_stream& options = {});
325 
341  change_stream watch(const client_session& session,
342  const pipeline& pipe,
343  const options::change_stream& options = {});
344 
348 
349  private:
350  friend class collection;
351  friend class database;
352  friend class pool;
353  friend class client_session;
354 
355  MONGOCXX_PRIVATE explicit client(void* implementation);
356 
357  MONGOCXX_PRIVATE change_stream _watch(const client_session* session,
358  const pipeline& pipe,
359  const options::change_stream& options);
360 
361  class MONGOCXX_PRIVATE impl;
362 
363  MONGOCXX_PRIVATE impl& _get_impl();
364  MONGOCXX_PRIVATE const impl& _get_impl() const;
365 
366  std::unique_ptr<impl> _impl;
367 };
368 
369 MONGOCXX_INLINE database client::operator[](bsoncxx::string::view_or_value name) const& {
370  return database(name);
371 }
372 
373 MONGOCXX_INLINE_NAMESPACE_END
374 } // namespace mongocxx
375 
376 #include <mongocxx/config/postlude.hpp>
Class representing a MongoDB connection string URI.
Definition: uri.hpp:40
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
Class representing the optional arguments to a MongoDB driver client object.
Definition: client.hpp:34
Class representing a pointer to the result set of a query on a MongoDB server.
Definition: cursor.hpp:36
Class representing a client connection to MongoDB.
Definition: client.hpp:57
A pool of client objects associated with a MongoDB deployment.
Definition: pool.hpp:47
Use a session for a sequence of operations, optionally with causal consistency.
Definition: client_session.hpp:38
Class representing a MongoDB database.
Definition: database.hpp:44
Definition: change_stream.hpp:31
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition: read_preference.hpp:62
A class to represent the read concern.
Definition: read_concern.hpp:53
Class representing the server-side requirement for reporting the success of a write operation...
Definition: write_concern.hpp:56
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:85