MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
uploader.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/gridfs/uploader-fwd.hpp> // IWYU pragma: export
18
19//
20
21#include <mongocxx/v1/gridfs/uploader.hpp> // IWYU pragma: export
22
23#include <cstddef>
24#include <cstdint>
25#include <memory> // IWYU pragma: keep: backward compatibility, to be removed.
26#include <utility>
27
28#include <mongocxx/gridfs/bucket-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
29
30#include <bsoncxx/document/value.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
31#include <bsoncxx/stdx/optional.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
32#include <bsoncxx/stdx/string_view.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
33#include <bsoncxx/types/bson_value/view.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
34#include <bsoncxx/view_or_value.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
35
36#include <mongocxx/client_session.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
37#include <mongocxx/collection.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
39
41
42namespace mongocxx {
43namespace v_noabi {
44namespace gridfs {
45
49class uploader {
50 private:
51 v1::gridfs::uploader _uploader;
52
53 public:
59 uploader() noexcept {}
60
64 uploader(uploader&&) noexcept = default;
65
69 uploader& operator=(uploader&&) noexcept = default;
70
71 uploader(uploader const& other) = delete;
72 uploader& operator=(uploader const& other) = delete;
73
77 ~uploader() = default;
78
82 /* explicit(false) */ uploader(v1::gridfs::uploader uploader) : _uploader{std::move(uploader)} {}
83
92 explicit operator v1::gridfs::uploader() && {
93 return std::move(_uploader);
94 }
95
99 explicit operator v1::gridfs::uploader() const& = delete;
100
104 explicit operator bool() const noexcept {
105 return _uploader.operator bool();
106 }
107
126 MONGOCXX_ABI_EXPORT_CDECL(void) write(std::uint8_t const* bytes, std::size_t length);
127
141
151
159
160 class internal;
161};
162
163} // namespace gridfs
164} // namespace v_noabi
165} // namespace mongocxx
166
167namespace mongocxx {
168namespace v_noabi {
169
174 return {std::move(v)};
175}
176
183
184} // namespace v_noabi
185} // namespace mongocxx
186
188
uploader() noexcept
Default constructs an uploader object. The uploader is equivalent to the state of a moved from upload...
Definition uploader.hpp:59
Support for uploading files to a GridFS bucket.
Definition uploader.hpp:44
Used to upload a GridFS file.
Definition uploader.hpp:49
void abort()
Aborts uploading the file.
uploader() noexcept
Default constructs an uploader object. The uploader is equivalent to the state of a moved from upload...
Definition uploader.hpp:59
std::int32_t chunk_size() const
Gets the chunk size of the file being uploaded.
uploader(uploader &&) noexcept=default
Move constructs an uploader.
void write(std::uint8_t const *bytes, std::size_t length)
Writes a specified number of bytes to a GridFS file.
result::gridfs::upload close()
Closes the uploader stream.
The result of a GridFS upload operation.
Definition upload.hpp:35
#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.
Declares entities whose ABI stability is guaranteed for documented symbols.
Declares entities related to GridFS.
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::v_noabi::result::gridfs::upload.
Provides mongocxx::v1::gridfs::uploader.
Provides bsoncxx::v_noabi::document::value.
Provides std::optional-related polyfills for library API usage.
Provides std::string_view-related polyfills for library API usage.
Provides bsoncxx::v_noabi::types::bson_value::view.
Provides mongocxx::v_noabi::client_session.
Provides mongocxx::v_noabi::collection.
Declares mongocxx::v_noabi::gridfs::bucket.
Declares utilities to upload GridFS files.
Provides bsoncxx::v_noabi::view_or_value.