MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
client.hpp
Go to the documentation of this file.
1// Copyright 2009-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 <mongocxx/v1/client-fwd.hpp> // IWYU pragma: export
18
19//
20
22
24
33
36
40
41#include <string>
42#include <system_error>
43#include <type_traits>
44#include <vector>
45
46namespace mongocxx {
47namespace v1 {
48
60class client {
61 private:
62 class impl;
63 void* _impl;
64
65 public:
66 class options;
67
74
82
89 MONGOCXX_ABI_EXPORT_CDECL(client&) operator=(client&& other) noexcept;
90
94 client(client const& other) = delete;
95
99 client& operator=(client const& other) = delete;
100
112
113 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() client(v1::uri uri);
116
124
128 explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
129
134
139
143 MONGOCXX_ABI_EXPORT_CDECL(v1::database) operator[](bsoncxx::v1::stdx::string_view name);
144
156
158
160
162 v1::client_session const& session,
163 bsoncxx::v1::document::view opts);
166
177 MONGOCXX_ABI_EXPORT_CDECL(std::vector<std::string>) list_database_names(bsoncxx::v1::document::view filter);
178
180 v1::client_session const& session,
181 bsoncxx::v1::document::view filter);
182
184
185 MONGOCXX_ABI_EXPORT_CDECL(std::vector<std::string>) list_database_names(v1::client_session const& session);
188
203
207
216
218
220 v1::client_session const& session,
221 v1::change_stream::options const& opts);
222
226
235 v1::pipeline const& pipeline,
236 v1::change_stream::options const& opts);
237
239 watch(v1::client_session const& session, v1::pipeline const& pipeline, v1::change_stream::options const& opts);
240
242
246
262
273
279 static MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
280
286 friend std::error_code make_error_code(errc v) {
287 return {static_cast<int>(v), error_category()};
288 }
289
290 class internal;
291
292 private:
293 /* explicit(false) */ client(void* impl);
294};
295
396
397} // namespace v1
398} // namespace mongocxx
399
400namespace std {
401
402template <>
403struct is_error_code_enum<mongocxx::v1::client::errc> : true_type {};
404
405} // namespace std
406
408
Declares mongocxx::v1::auto_encryption_options.
Options related to Application Performance Monitoring (APM) configuration.
Definition apm.hpp:51
Options related In-Use Encryption configuration.
Definition auto_encryption_options.hpp:58
A MongoDB change stream.
Definition change_stream.hpp:50
Options for mongocxx::v1::client.
Definition client.hpp:307
options & apm_opts(v1::apm v)
Set the "apm_opts" field.
options(options &&other) noexcept
Move constructor.
~options()
Destroy this object.
options & auto_encryption_opts(v1::auto_encryption_options v)
Set the "auto_encryption_opts" field.
options & tls_opts(v1::tls v)
Set the "tls_opts" field.
options & server_api_opts(v1::server_api v)
Set the "server_api_opts" field.
A MongoDB client session.
Definition client_session.hpp:48
~client()
Destroy this object.
void reset()
Invalidate this client object without invaliding existing cursors or sessions.
errc
Errors codes which may be returned by mongocxx::v1::client.
Definition client.hpp:268
@ tls_not_supported
TLS is not supported by the mongoc library.
Definition client.hpp:271
@ tls_not_enabled
TLS is not enabled by URI options.
Definition client.hpp:270
@ zero
Zero.
Definition client.hpp:269
v1::database database(bsoncxx::v1::stdx::string_view name)
Access the database with the given name.
client()
Default initialization.
v1::uri uri() const
Return the mongocxx::v1::uri used to initialize this client.
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition client.hpp:286
std::vector< std::string > list_database_names(bsoncxx::v1::document::view filter)
Return an unsorted list of the names of all existing databases.
client(client &&other) noexcept
Move constructor.
v1::client_session start_session(v1::client_session::options const &opts)
Create a new client session to use with subsequent operations.
v1::cursor list_databases()
Return an unsorted list of all existing databases.
v1::change_stream watch(v1::change_stream::options const &opts)
Return a change stream subscribed to this connection.
static std::error_category const & error_category()
The error category for mongocxx::v1::client::errc.
A MongoDB cursor.
Definition cursor.hpp:41
A MongoDB aggregation pipeline.
Definition pipeline.hpp:43
Options related to MongoDB Stable API configuration.
Definition server_api.hpp:46
Options related to TLS configuration.
Definition tls.hpp:48
Provides macros to control the set of symbols exported in the ABI.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v1 macro guard postlude header.
The mongocxx v1 macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities whose ABI stability is guaranteed for documented symbols.
The top-level namespace within which all mongocxx library entities are declared.
Declares mongocxx::v1::apm.
Provides mongocxx::v1::change_stream.
Declares mongocxx::v1::client.
Provides mongocxx::v1::client_session.
Declares mongocxx::v1::cursor.
Declares mongocxx::v1::database.
Declares bsoncxx::v1::document::view.
Declares mongocxx::v1::pipeline.
Declares mongocxx::v1::server_api.
Provides std::optional-related polyfills for library API usage.
Provides std::string_view-related polyfills for library API usage.
Declares mongocxx::v1::tls.
Declares mongocxx::v1::uri.