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/v1/gridfs/uploader-fwd.hpp> // IWYU pragma: export
18
19//
20
22
24
26
27#include <cstddef>
28#include <cstdint>
29#include <system_error>
30#include <type_traits>
31
32namespace mongocxx {
33namespace v1 {
34namespace gridfs {
35
44class uploader {
45 private:
46 class impl;
47 void* _impl;
48
49 public:
59
67
74 MONGOCXX_ABI_EXPORT_CDECL(uploader&) operator=(uploader&& other) noexcept;
75
79 uploader(uploader const& other) = delete;
80
84 uploader& operator=(uploader const& other) = delete;
85
93
97 explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
98
103
116
132
137
158 MONGOCXX_ABI_EXPORT_CDECL(void) write(std::uint8_t const* data, std::size_t length);
159
172
183
189 static MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
190
196 friend std::error_code make_error_code(errc v) {
197 return {static_cast<int>(v), error_category()};
198 }
199
200 class internal;
201
202 private:
203 /* explicit(false) */ uploader(void* impl);
204
205 void save_chunk();
206};
207
208} // namespace gridfs
209} // namespace v1
210} // namespace mongocxx
211
212namespace std {
213
214template <>
215struct is_error_code_enum<mongocxx::v1::gridfs::uploader::errc> : true_type {};
216
217} // namespace std
218
220
Result of uploading a file to a GridFS bucket.
Definition upload_result.hpp:42
void abort()
Abort uploading this GridFS file.
v1::gridfs::upload_result close()
Complete the upload of this GridFS file.
static std::error_category const & error_category()
The error category for mongocxx::v1::gridfs::uploader::errc.
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition uploader.hpp:196
uploader(uploader &&other) noexcept
Move constructor.
~uploader()
Destroy this object.
std::int32_t chunk_size() const
Return the chunk size (in bytes) of the associated GridFS file.
uploader()
Default initialization.
void write(std::uint8_t const *data, std::size_t length)
Write length bytes of the associated GridFS file.
bool is_open() const
Return true when the underlying GridFS file stream is open for writing.
void flush()
Flush the internal buffer.
errc
Errors codes which may be returned by mongocxx::v1::gridfs::uploader.
Definition uploader.hpp:178
@ is_closed
The GridFS file upload stream is not open.
Definition uploader.hpp:180
@ zero
Zero.
Definition uploader.hpp:179
@ too_many_chunks
The total number of chunks must be less than INT32_MAX.
Definition uploader.hpp:181
Provides macros to control the set of symbols exported in the ABI.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v1 macro guard postlude header.
The mongocxx v1 macro guard prelude header.
Declares entities related to GridFS.
Declares entities whose ABI stability is guaranteed for documented symbols.
@ mongocxx
From the mongocxx library.
Definition exception.hpp:42
The top-level namespace within which all mongocxx library entities are declared.
Declares mongocxx::v1::gridfs::upload_result.
Declares mongocxx::v1::gridfs::uploader.