MongoDB C++ Driver 4.5.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
34
37
42
43#include <string>
44#include <system_error>
45#include <type_traits>
46#include <vector>
47
48namespace mongocxx {
49namespace v1 {
50
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
252
256
278 bsoncxx::v1::stdx::string_view name,
279 bsoncxx::v1::stdx::optional<bsoncxx::v1::stdx::string_view> version = {},
281
297
307
311 static MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
312
316 friend std::error_code make_error_code(errc v) {
317 return {static_cast<int>(v), error_category()};
318 }
319
320 class internal;
321
322 private:
323 /* explicit(false) */ client(void* impl);
324};
325
435
436} // namespace v1
437} // namespace mongocxx
438
439namespace std {
440
441template <>
442struct is_error_code_enum<mongocxx::v1::client::errc> : true_type {};
443
444} // namespace std
445
447
Declares mongocxx::v1::auto_encryption_options.
A polyfill for std::optional<T>.
Definition optional.hpp:799
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:48
Options for mongocxx::v1::client.
Definition client.hpp:336
options & apm_opts(v1::apm v)
Set the "apm_opts" field.
options(options &&other) noexcept
Move constructor.
~options()
Destroy this object.
options & oidc_callback(v1::oidc_callback v)
Set the "oidc_callback" field.
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 list of bulk write operations. Unlike mongocxx::v1::bulk_write, this supports writes across more th...
Definition client_bulk_write.hpp:58
A MongoDB client session.
Definition client_session.hpp:46
~client()
Destroy this object.
void reset()
Invalidate this client object without invaliding existing cursors or sessions.
v1::client_bulk_write create_bulk_write()
Return a new client-level bulk write operation for use with this client.
errc
Errors codes which may be returned by mongocxx::v1::client.
Definition client.hpp:301
@ tls_not_supported
TLS is not supported by the mongoc library.
Definition client.hpp:304
@ append_metadata_failure
Failed to append client metadata.
Definition client.hpp:305
@ tls_not_enabled
TLS is not enabled by URI options.
Definition client.hpp:303
@ zero
Zero.
Definition client.hpp:302
v1::database database(bsoncxx::v1::stdx::string_view name)
Access the database with the given name.
client()
Default initialization.
void append_metadata(bsoncxx::v1::stdx::string_view name, bsoncxx::v1::stdx::optional< bsoncxx::v1::stdx::string_view > version={}, bsoncxx::v1::stdx::optional< bsoncxx::v1::stdx::string_view > platform={})
Append client metadata to the handshake command sent as part of the initial connection handshake.
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:316
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:39
A MongoDB aggregation pipeline.
Definition pipeline.hpp:41
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.
Declares mongocxx::v1::client_bulk_write.
Provides mongocxx::v1::client_session.
Declares mongocxx::v1::cursor.
Declares mongocxx::v1::database.
Declares bsoncxx::v1::document::view.
Provides mongocxx::v1::oidc_callback.
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.