MongoDB C++ Driver 4.2.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
45 private:
46 class impl;
47 void* _impl;
48
49 public:
56
64
71 MONGOCXX_ABI_EXPORT_CDECL(downloader&) operator=(downloader&& other) noexcept;
72
76 downloader(downloader const& other) = delete;
77
81 downloader& operator=(downloader const& other) = delete;
82
90
94 explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
95
100
105
110
115
120
135 MONGOCXX_ABI_EXPORT_CDECL(std::size_t) read(std::uint8_t* data, std::size_t length);
136
147
153 static MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
154
160 friend std::error_code make_error_code(errc v) {
161 return {static_cast<int>(v), error_category()};
162 }
163
164 class internal;
165
166 private:
167 /* explicit(false) */ downloader(void* impl);
168
169 void download_next_chunk();
170};
171
172} // namespace gridfs
173} // namespace v1
174} // namespace mongocxx
175
176namespace std {
177
178template <>
179struct is_error_code_enum<mongocxx::v1::gridfs::downloader::errc> : true_type {};
180
181} // namespace std
182
184
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:160
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:142
@ is_closed
The GridFS file download stream is not open.
Definition downloader.hpp:144
@ corrupt_data
The GridFS file is in an invalid or inconsistent state.
Definition downloader.hpp:145
@ zero
Zero.
Definition downloader.hpp:143
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:42
The top-level namespace within which all mongocxx library entities are declared.
Declares bsoncxx::v1::document::view.
Declares mongocxx::v1::gridfs::downloader.