Loading...
Searching...
No Matches
upload.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/upload-fwd.hpp> // IWYU pragma: export
//
#include <bsoncxx/v1/document/value.hpp>
#include <mongocxx/v1/gridfs/upload_options.hpp> // IWYU pragma: export
#include <cstdint>
#include <utility>
#include <bsoncxx/document/view.hpp>
#include <bsoncxx/document/view_or_value.hpp>
#include <bsoncxx/stdx/optional.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
namespace options {
namespace gridfs {
class upload {
public:
upload() = default;
/* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() upload(v1::gridfs::upload_options opts);
explicit operator v1::gridfs::upload_options() const {
using bsoncxx::v_noabi::to_v1;
v1::gridfs::upload_options ret;
if (_chunk_size_bytes) {
ret.chunk_size_bytes(*_chunk_size_bytes);
}
if (_metadata) {
ret.metadata(bsoncxx::v1::document::value{to_v1(_metadata->view())});
}
return ret;
}
upload& 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;
}
upload& metadata(bsoncxx::v_noabi::document::view_or_value metadata) {
_metadata = std::move(metadata);
return *this;
}
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> const& metadata() const {
return _metadata;
}
private:
bsoncxx::v_noabi::stdx::optional<std::int32_t> _chunk_size_bytes;
bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> _metadata;
};
} // namespace gridfs
} // namespace options
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::options::gridfs::upload from_v1(v1::gridfs::upload_options v) {
return {std::move(v)};
}
inline v1::gridfs::upload_options to_v1(v_noabi::options::gridfs::upload const& v) {
return v1::gridfs::upload_options{v};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
bsoncxx::v1::document::value
A BSON document.
Definition value.hpp:44
bsoncxx::v1::stdx::optional
A polyfill for std::optional<T>.
Definition optional.hpp:799
mongocxx::options::gridfs::upload::upload
upload()=default
Default initialization.
mongocxx::v1::gridfs::upload_options
Options related to uploading a file to a GridFS bucket.
Definition upload_options.hpp:46
mongocxx::v1::gridfs::upload_options::chunk_size_bytes
upload_options & chunk_size_bytes(std::int32_t v)
Set the "chunkSizeBytes" field.
mongocxx::v1::gridfs::upload_options::metadata
upload_options & metadata(bsoncxx::v1::document::value v)
Set the "metadata" field.
mongocxx::v_noabi::options::gridfs::upload
Used by mongocxx::v_noabi::gridfs::bucket.
Definition upload.hpp:42
mongocxx::v_noabi::options::gridfs::upload::chunk_size_bytes
bsoncxx::v_noabi::stdx::optional< std::int32_t > const & chunk_size_bytes() const
Gets the chunk size of the GridFS file being uploaded.
Definition upload.hpp:95
mongocxx::v_noabi::options::gridfs::upload::metadata
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & metadata() const
Gets the metadata of the GridFS file being uploaded.
Definition upload.hpp:121
mongocxx::v_noabi::options::gridfs::upload::metadata
upload & metadata(bsoncxx::v_noabi::document::view_or_value metadata)
Sets the metadata field of the GridFS file being uploaded. A GridFS file can store arbitrary metadata...
Definition upload.hpp:110
mongocxx::v_noabi::options::gridfs::upload::upload
upload()=default
Default initialization.
mongocxx::v_noabi::options::gridfs::upload::upload_options
operator v1::gridfs::upload_options() const
Convert to the mongocxx::v1 equivalent.
Definition upload.hpp:57
mongocxx::v_noabi::options::gridfs::upload::chunk_size_bytes
upload & chunk_size_bytes(std::int32_t chunk_size_bytes)
Sets the chunk size of the GridFS file being uploaded. Defaults to the chunk size specified in option...
Definition upload.hpp:84
view_or_value.hpp
Provides bsoncxx::v_noabi::document::view_or_value.
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::document::view_or_value
v_noabi::view_or_value< v_noabi::document::view, v_noabi::document::value > view_or_value
Equivalent to v_noabi::view_or_value<v_noabi::document::view, v_noabi::document::value>.
Definition view_or_value.hpp:30
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.
upload-fwd.hpp
Declares mongocxx::v_noabi::options::gridfs::upload.
upload_options.hpp
Provides mongocxx::v1::gridfs::upload_options.
value.hpp
Provides bsoncxx::v1::document::value.
view.hpp
Provides bsoncxx::v_noabi::document::view.
optional.hpp
Provides std::optional-related polyfills for library API usage.