MongoDB C++ Driver mongocxx-3.1.1
Loading...
Searching...
No Matches
client.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
19#include <bsoncxx/string/view_or_value.hpp>
20#include <mongocxx/database.hpp>
21#include <mongocxx/options/client.hpp>
22#include <mongocxx/read_concern.hpp>
23#include <mongocxx/read_preference.hpp>
24#include <mongocxx/stdx.hpp>
25#include <mongocxx/uri.hpp>
26#include <mongocxx/write_concern.hpp>
27
28#include <mongocxx/config/prelude.hpp>
29
33namespace mongocxx {
34MONGOCXX_INLINE_NAMESPACE_BEGIN
35
52class MONGOCXX_API client {
53 public:
59 client() noexcept;
60
72 client(const class uri& mongodb_uri, const options::client& options = options::client());
73
77 client(client&&) noexcept;
78
82 client& operator=(client&&) noexcept;
83
88
93 explicit operator bool() const noexcept;
94
108
115
129
138
144 class uri uri() const;
145
157
163
174 class database database(bsoncxx::string::view_or_value name) const&;
175 class database database(bsoncxx::string::view_or_value name) const&& = delete;
176
188 MONGOCXX_INLINE class database operator[](bsoncxx::string::view_or_value name) const&;
189 MONGOCXX_INLINE class database operator[](bsoncxx::string::view_or_value name) const&& = delete;
190
204 cursor list_databases() const;
205
206 private:
207 friend class collection;
208 friend class database;
209 friend class pool;
210
211 MONGOCXX_PRIVATE explicit client(void* implementation);
212
213 class MONGOCXX_PRIVATE impl;
214
215 MONGOCXX_PRIVATE impl& _get_impl();
216 MONGOCXX_PRIVATE const impl& _get_impl() const;
217
218 std::unique_ptr<impl> _impl;
219};
220
221MONGOCXX_INLINE database client::operator[](bsoncxx::string::view_or_value name) const & {
222 return database(name);
223}
224
225MONGOCXX_INLINE_NAMESPACE_END
226} // namespace mongocxx
227
228#include <mongocxx/config/postlude.hpp>
Class representing a client connection to MongoDB.
Definition client.hpp:52
client() noexcept
Default constructs a new client.
Class representing server side document groupings within a MongoDB database.
Definition collection.hpp:74
Class representing a pointer to the result set of a query on a MongoDB server.
Definition cursor.hpp:35
Class representing a MongoDB database.
Definition database.hpp:44
A pool of client objects associated with a MongoDB deployment.
Definition pool.hpp:49
A class to represent the read concern.
Definition read_concern.hpp:52
Class representing a preference for how the driver routes read operations to members of a replica set...
Definition read_preference.hpp:57
Class representing a MongoDB connection string URI.
Definition uri.hpp:40
Class representing the server-side requirement for reporting the success of a write operation.
Definition write_concern.hpp:54
Top level namespace for MongoDB C++ BSON functionality.
Definition element.hpp:24
Top level namespace for the MongoDB C++ driver.
Definition bulk_write.hpp:22