Loading...
Searching...
No Matches
bucket.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/options/gridfs/bucket-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/gridfs/bucket.hpp> // IWYU pragma: export
#include <cstdint>
#include <string>
#include <utility>
#include <bsoncxx/stdx/optional.hpp>
#include <mongocxx/read_concern.hpp>
#include <mongocxx/read_preference.hpp>
#include <mongocxx/write_concern.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
namespace options {
namespace gridfs {
class bucket {
public:
bucket() = default;
/* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() bucket(v1::gridfs::bucket::options opts);
explicit operator v1::gridfs::bucket::options() const {
using bsoncxx::v_noabi::to_v1;
v1::gridfs::bucket::options ret;
if (_bucket_name) {
ret.bucket_name(*_bucket_name);
}
if (_chunk_size_bytes) {
ret.chunk_size_bytes(*_chunk_size_bytes);
}
if (_read_concern) {
ret.read_concern(v_noabi::to_v1(*_read_concern));
}
if (_read_preference) {
ret.read_preference(v_noabi::to_v1(*_read_preference));
}
if (_write_concern) {
ret.write_concern(v_noabi::to_v1(*_write_concern));
}
return ret;
}
bucket& bucket_name(std::string bucket_name) {
_bucket_name = std::move(bucket_name);
return *this;
}
bsoncxx::v_noabi::stdx::optional<std::string> const& bucket_name() const {
return _bucket_name;
}
bucket& chunk_size_bytes(std::int32_t chunk_size_bytes) {
_chunk_size_bytes = chunk_size_bytes;
return *this;
}
bsoncxx::v_noabi::stdx::optional<std::int32_t> const& chunk_size_bytes() const {
return _chunk_size_bytes;
}
bucket& read_concern(v_noabi::read_concern read_concern) {
_read_concern = std::move(read_concern);
return *this;
}
bsoncxx::v_noabi::stdx::optional<v_noabi::read_concern> const& read_concern() const {
return _read_concern;
}
bucket& read_preference(v_noabi::read_preference read_preference) {
_read_preference = std::move(read_preference);
return *this;
}
bsoncxx::v_noabi::stdx::optional<v_noabi::read_preference> const& read_preference() const {
return _read_preference;
}
bucket& write_concern(v_noabi::write_concern write_concern) {
_write_concern = std::move(write_concern);
return *this;
}
bsoncxx::v_noabi::stdx::optional<v_noabi::write_concern> const& write_concern() const {
return _write_concern;
}
private:
bsoncxx::v_noabi::stdx::optional<std::string> _bucket_name;
bsoncxx::v_noabi::stdx::optional<std::int32_t> _chunk_size_bytes;
bsoncxx::v_noabi::stdx::optional<v_noabi::read_concern> _read_concern;
bsoncxx::v_noabi::stdx::optional<v_noabi::read_preference> _read_preference;
bsoncxx::v_noabi::stdx::optional<v_noabi::write_concern> _write_concern;
};
} // namespace gridfs
} // namespace options
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::options::gridfs::bucket from_v1(v1::gridfs::bucket::options v) {
return {std::move(v)};
}
inline v1::gridfs::bucket::options to_v1(v_noabi::options::gridfs::bucket const& v) {
return v1::gridfs::bucket::options{v};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
bsoncxx::v1::stdx::optional
A polyfill for std::optional<T>.
Definition optional.hpp:799
mongocxx::options::gridfs::bucket::bucket
bucket()=default
Default initialization.
mongocxx::v1::gridfs::bucket::options
Options for mongocxx::v1::gridfs::bucket.
Definition bucket.hpp:335
mongocxx::v1::gridfs::bucket::options::read_concern
options & read_concern(v1::read_concern v)
Set the "readConcern" field.
mongocxx::v1::gridfs::bucket::options::chunk_size_bytes
options & chunk_size_bytes(std::int32_t v)
Set the "chunkSizeBytes" field.
mongocxx::v1::gridfs::bucket::options::bucket_name
options & bucket_name(std::string v)
Set the "bucketName" field.
mongocxx::v1::gridfs::bucket::options::write_concern
options & write_concern(v1::write_concern v)
Set the "writeConcern" field.
mongocxx::v1::gridfs::bucket::options::read_preference
options & read_preference(v1::read_preference v)
Set the "readPreference" field.
mongocxx::v_noabi::options::gridfs::bucket
Used by mongocxx::v_noabi::gridfs::bucket.
Definition bucket.hpp:43
mongocxx::v_noabi::options::gridfs::bucket::read_concern
bsoncxx::v_noabi::stdx::optional< v_noabi::read_concern > const & read_concern() const
Gets the read concern of the bucket.
Definition bucket.hpp:159
mongocxx::v_noabi::options::gridfs::bucket::read_concern
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
mongocxx::v_noabi::options::gridfs::bucket::read_preference
bsoncxx::v_noabi::stdx::optional< v_noabi::read_preference > const & read_preference() const
Gets the read preference of the bucket.
Definition bucket.hpp:191
mongocxx::v_noabi::options::gridfs::bucket::read_preference
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
mongocxx::v_noabi::options::gridfs::bucket::write_concern
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
mongocxx::v_noabi::options::gridfs::bucket::bucket_name
bsoncxx::v_noabi::stdx::optional< std::string > const & bucket_name() const
Gets the name of the bucket.
Definition bucket.hpp:107
mongocxx::v_noabi::options::gridfs::bucket::options
operator v1::gridfs::bucket::options() const
Convert to the mongocxx::v1 equivalent.
Definition bucket.hpp:58
mongocxx::v_noabi::options::gridfs::bucket::write_concern
bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const & write_concern() const
Gets the write concern of the bucket.
Definition bucket.hpp:217
mongocxx::v_noabi::options::gridfs::bucket::chunk_size_bytes
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
mongocxx::v_noabi::options::gridfs::bucket::bucket
bucket()=default
Default initialization.
mongocxx::v_noabi::options::gridfs::bucket::bucket_name
bucket & bucket_name(std::string bucket_name)
Sets the name of the bucket. Defaults to 'fs'.
Definition bucket.hpp:96
mongocxx::v_noabi::options::gridfs::bucket::chunk_size_bytes
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
mongocxx::v_noabi::read_concern
Controls the consistency and isolation properties of data read from replica sets and sharded clusters...
Definition read_concern.hpp:54
mongocxx::v_noabi::read_preference
Describes how MongoDB clients route read operations to the members of a replica set or sharded cluste...
Definition read_preference.hpp:59
mongocxx::v_noabi::write_concern
The level of acknowledgment requested for write operations to a MongoDB server.
Definition write_concern.hpp:54
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE
#define MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to MONGOCXX_ABI_EXPORT_UNSTABLE with MONGOCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The mongocxx v_noabi macro guard postlude header.
prelude.hpp
The mongocxx v_noabi macro guard prelude header.
bsoncxx::v_noabi::to_v1
v1::element::view to_v1(v_noabi::array::element const &v)
Convert to the bsoncxx::v1 equivalent of v.
Definition element.hpp:132
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx::v_noabi::options::gridfs
Declares entities representing options specific to GridFS.
mongocxx::v_noabi::options
Declares entities representing options to use with various commands.
mongocxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
mongocxx::v_noabi::to_v1
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
mongocxx::v_noabi::from_v1
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
bucket.hpp
Provides mongocxx::v1::gridfs::bucket.
optional.hpp
Provides std::optional-related polyfills for library API usage.
bucket-fwd.hpp
Declares mongocxx::v_noabi::options::gridfs::bucket.
read_concern.hpp
Provides mongocxx::v_noabi::read_concern.
read_preference.hpp
Provides mongocxx::v_noabi::read_preference.
write_concern.hpp
Provides mongocxx::v_noabi::write_concern.