MongoDB C++ Driver 4.5.1
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
142
149 MONGOCXX_ABI_EXPORT_CDECL(v1::database) operator[](bsoncxx::v1::stdx::string_view name);
150
162
164
166
168 v1::client_session const& session,
169 bsoncxx::v1::document::view opts);
172
183 MONGOCXX_ABI_EXPORT_CDECL(std::vector<std::string>) list_database_names(bsoncxx::v1::document::view filter);
184
186 v1::client_session const& session,
187 bsoncxx::v1::document::view filter);
188
190
191 MONGOCXX_ABI_EXPORT_CDECL(std::vector<std::string>) list_database_names(v1::client_session const& session);
194
209
213
222
224
226 v1::client_session const& session,
227 v1::change_stream::options const& opts);
228
232
241 v1::pipeline const& pipeline,
242 v1::change_stream::options const& opts);
243
245 watch(v1::client_session const& session, v1::pipeline const& pipeline, v1::change_stream::options const& opts);
246
248
252
258
262
284 bsoncxx::v1::stdx::string_view name,
285 bsoncxx::v1::stdx::optional<bsoncxx::v1::stdx::string_view> version = {},
287
303
314
318 static MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
319
323 friend std::error_code make_error_code(errc v) {
324 return {static_cast<int>(v), error_category()};
325 }
326
327 class internal;
328
329 private:
330 /* explicit(false) */ client(void* impl);
331};
332
442
443} // namespace v1
444} // namespace mongocxx
445
446namespace std {
447
448template <>
449struct is_error_code_enum<mongocxx::v1::client::errc> : true_type {};
450
451} // namespace std
452
454
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:343
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:307
@ tls_not_supported
TLS is not supported by the mongoc library.
Definition client.hpp:310
@ append_metadata_failure
Failed to append client metadata.
Definition client.hpp:311
@ tls_not_enabled
TLS is not enabled by URI options.
Definition client.hpp:309
@ zero
Zero.
Definition client.hpp:308
@ invalid_database_name
The database name is not valid.
Definition client.hpp:312
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:323
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.