MongoDB C++ Driver 4.4.0
Loading...
Searching...
No Matches
downloader.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/downloader-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
43 private:
44 class impl;
45 void* _impl;
46
47 public:
54
62
69 MONGOCXX_ABI_EXPORT_CDECL(downloader&) operator=(downloader&& other) noexcept;
70
74 downloader(downloader const& other) = delete;
75
79 downloader& operator=(downloader const& other) = delete;
80
88
92 explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
93
98
103
108
113
118
134 MONGOCXX_ABI_EXPORT_CDECL(std::size_t) read(std::uint8_t* data, std::size_t length);
135
144
148 static MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
149
153 friend std::error_code make_error_code(errc v) {
154 return {static_cast<int>(v), error_category()};
155 }
156
157 class internal;
158
159 private:
160 /* explicit(false) */ downloader(void* impl);
161
162 void download_next_chunk();
163};
164
165} // namespace gridfs
166} // namespace v1
167} // namespace mongocxx
168
169namespace std {
170
171template <>
172struct is_error_code_enum<mongocxx::v1::gridfs::downloader::errc> : true_type {};
173
174} // namespace std
175
177
bool is_open() const
Return true when the underlying GridFS file stream is open for reading.
std::int64_t file_length() const
Return the length of the associated GridFS file.
downloader(downloader &&other) noexcept
Move constructor.
std::int32_t chunk_size() const
Return the chunk size (in bytes) of the associated GridFS file.
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition downloader.hpp:153
std::size_t read(std::uint8_t *data, std::size_t length)
Read up to length bytes of the associated GridFS file.
errc
Errors codes which may be returned by mongocxx::v1::gridfs::downloader.
Definition downloader.hpp:139
@ is_closed
The GridFS file download stream is not open.
Definition downloader.hpp:141
@ corrupt_data
The GridFS file is in an invalid or inconsistent state.
Definition downloader.hpp:142
@ zero
Zero.
Definition downloader.hpp:140
bsoncxx::v1::document::view files_document() const
Return the files collection document for the associated GridFS file.
void close()
Close the underlying GridFS download stream.
downloader()
Default initialization.
static std::error_category const & error_category()
The error category for mongocxx::v1::gridfs::downloader::errc.
~downloader()
Destroy this object.
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.
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities related to GridFS.
Declares entities whose ABI stability is guaranteed for documented symbols.
@ mongocxx
From the mongocxx library.
Definition exception.hpp:40
The top-level namespace within which all mongocxx library entities are declared.
Declares bsoncxx::v1::document::view.
Declares mongocxx::v1::gridfs::downloader.