MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
bucket.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/options/gridfs/bucket-fwd.hpp> // IWYU pragma: export
18
19//
20
21#include <mongocxx/v1/gridfs/bucket.hpp> // IWYU pragma: export
22
23#include <cstdint>
24#include <string>
25#include <utility>
26
28
32
34
35namespace mongocxx {
36namespace v_noabi {
37namespace options {
38namespace gridfs {
39
43class bucket {
44 public:
48 bucket() = default;
49
53 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() bucket(v1::gridfs::bucket::options opts);
54
58 explicit operator v1::gridfs::bucket::options() const {
60
62
63 if (_bucket_name) {
64 ret.bucket_name(*_bucket_name);
65 }
66
67 if (_chunk_size_bytes) {
68 ret.chunk_size_bytes(*_chunk_size_bytes);
69 }
70
71 if (_read_concern) {
72 ret.read_concern(v_noabi::to_v1(*_read_concern));
73 }
74
75 if (_read_preference) {
76 ret.read_preference(v_noabi::to_v1(*_read_preference));
77 }
78
79 if (_write_concern) {
80 ret.write_concern(v_noabi::to_v1(*_write_concern));
81 }
82
83 return ret;
84 }
85
97 _bucket_name = std::move(bucket_name);
98 return *this;
99 }
100
108 return _bucket_name;
109 }
110
123 _chunk_size_bytes = chunk_size_bytes;
124 return *this;
125 }
126
134 return _chunk_size_bytes;
135 }
136
149 _read_concern = std::move(read_concern);
150 return *this;
151 }
152
160 return _read_concern;
161 }
162
181 _read_preference = std::move(read_preference);
182 return *this;
183 }
184
192 return _read_preference;
193 }
194
207 _write_concern = std::move(write_concern);
208 return *this;
209 }
210
218 return _write_concern;
219 }
220
221 private:
227};
228
229} // namespace gridfs
230} // namespace options
231} // namespace v_noabi
232} // namespace mongocxx
233
234namespace mongocxx {
235namespace v_noabi {
236
241 return {std::move(v)};
242}
243
250
251} // namespace v_noabi
252} // namespace mongocxx
253
255
A polyfill for std::optional<T>.
Definition optional.hpp:799
bucket()=default
Default initialization.
Options for mongocxx::v1::gridfs::bucket.
Definition bucket.hpp:345
options & read_concern(v1::read_concern v)
Set the "readConcern" field.
options & chunk_size_bytes(std::int32_t v)
Set the "chunkSizeBytes" field.
options & bucket_name(std::string v)
Set the "bucketName" field.
options & write_concern(v1::write_concern v)
Set the "writeConcern" field.
options & read_preference(v1::read_preference v)
Set the "readPreference" field.
Used by mongocxx::v_noabi::gridfs::bucket.
Definition bucket.hpp:43
bsoncxx::v_noabi::stdx::optional< v_noabi::read_concern > const & read_concern() const
Gets the read concern of the bucket.
Definition bucket.hpp:159
bucket & read_concern(v_noabi::read_concern read_concern)
Sets the read concern to be used when reading from the bucket. Defaults to the read concern of the da...
Definition bucket.hpp:148
bsoncxx::v_noabi::stdx::optional< v_noabi::read_preference > const & read_preference() const
Gets the read preference of the bucket.
Definition bucket.hpp:191
bucket & read_preference(v_noabi::read_preference read_preference)
Sets the read preference to be used when reading from the GridFS bucket. Defaults to the read prefere...
Definition bucket.hpp:180
bucket & write_concern(v_noabi::write_concern write_concern)
Sets the write concern to be used when writing to the GridFS bucket. Defaults to the write concern of...
Definition bucket.hpp:206
bsoncxx::v_noabi::stdx::optional< std::string > const & bucket_name() const
Gets the name of the bucket.
Definition bucket.hpp:107
operator v1::gridfs::bucket::options() const
Convert to the mongocxx::v1 equivalent.
Definition bucket.hpp:58
bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const & write_concern() const
Gets the write concern of the bucket.
Definition bucket.hpp:217
bucket & chunk_size_bytes(std::int32_t chunk_size_bytes)
Sets the size of the chunks in the bucket. This will be used as the chunk size for files uploaded thr...
Definition bucket.hpp:122
bucket()=default
Default initialization.
bucket & bucket_name(std::string bucket_name)
Sets the name of the bucket. Defaults to 'fs'.
Definition bucket.hpp:96
bsoncxx::v_noabi::stdx::optional< std::int32_t > const & chunk_size_bytes() const
Gets the size of the chunks in the bucket.
Definition bucket.hpp:133
Controls the consistency and isolation properties of data read from replica sets and sharded clusters...
Definition read_concern.hpp:54
Describes how MongoDB clients route read operations to the members of a replica set or sharded cluste...
Definition read_preference.hpp:59
The level of acknowledgment requested for write operations to a MongoDB server.
Definition write_concern.hpp:54
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v_noabi macro guard postlude header.
The mongocxx v_noabi macro guard prelude header.
v1::element::view to_v1(v_noabi::array::element const &v)
Convert to the bsoncxx::v1 equivalent of v.
Definition element.hpp:132
Declares entities whose ABI stability is guaranteed for documented symbols.
Declares entities representing options specific to GridFS.
Declares entities representing options to use with various commands.
Declares entities whose ABI stability is NOT guaranteed.
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
The top-level namespace within which all mongocxx library entities are declared.
Provides mongocxx::v1::gridfs::bucket.
Provides std::optional-related polyfills for library API usage.
Declares mongocxx::v_noabi::options::gridfs::bucket.
Provides mongocxx::v_noabi::read_concern.
Provides mongocxx::v_noabi::read_preference.
Provides mongocxx::v_noabi::write_concern.