MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
upload.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/upload-fwd.hpp> // IWYU pragma: export
18
19//
20
22
23#include <mongocxx/v1/gridfs/upload_options.hpp> // IWYU pragma: export
24
25#include <cstdint>
26#include <utility>
27
31
33
34namespace mongocxx {
35namespace v_noabi {
36namespace options {
37namespace gridfs {
38
42class upload {
43 public:
47 upload() = default;
48
52 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() upload(v1::gridfs::upload_options opts);
53
57 explicit operator v1::gridfs::upload_options() const {
59
61
62 if (_chunk_size_bytes) {
63 ret.chunk_size_bytes(*_chunk_size_bytes);
64 }
65
66 if (_metadata) {
67 ret.metadata(bsoncxx::v1::document::value{to_v1(_metadata->view())});
68 }
69
70 return ret;
71 }
72
85 _chunk_size_bytes = chunk_size_bytes;
86 return *this;
87 }
88
96 return _chunk_size_bytes;
97 }
98
111 _metadata = std::move(metadata);
112 return *this;
113 }
114
124
125 private:
128};
129
130} // namespace gridfs
131} // namespace options
132} // namespace v_noabi
133} // namespace mongocxx
134
135namespace mongocxx {
136namespace v_noabi {
137
142 return {std::move(v)};
143}
144
151
152} // namespace v_noabi
153} // namespace mongocxx
154
156
A BSON document.
Definition value.hpp:46
A polyfill for std::optional<T>.
Definition optional.hpp:799
upload()=default
Default initialization.
Options related to uploading a file to a GridFS bucket.
Definition upload_options.hpp:48
upload_options & metadata(bsoncxx::v1::document::value metadata)
Set the "metadata" field.
upload_options & chunk_size_bytes(std::int32_t chunk_size_bytes)
Set the "chunkSizeBytes" field.
Used by mongocxx::v_noabi::gridfs::bucket.
Definition upload.hpp:42
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
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
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
upload()=default
Default initialization.
operator v1::gridfs::upload_options() const
Convert to the mongocxx::v1 equivalent.
Definition upload.hpp:57
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
Provides bsoncxx::v_noabi::document::view_or_value.
#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.
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
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.
Declares mongocxx::v_noabi::options::gridfs::upload.
Provides mongocxx::v1::gridfs::upload_options.
Provides bsoncxx::v1::document::value.
Provides bsoncxx::v_noabi::document::view.
Provides std::optional-related polyfills for library API usage.