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/gridfs/downloader-fwd.hpp> // IWYU pragma: export
18
19//
20
21#include <mongocxx/v1/gridfs/downloader.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.
32#include <bsoncxx/stdx/optional.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
35#include <mongocxx/cursor.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
36
38
39namespace mongocxx {
40namespace v_noabi {
41namespace gridfs {
42
47 std::int32_t chunks_offset = 0;
48 std::int32_t bytes_offset = 0;
49};
50
55 private:
56 v1::gridfs::downloader _downloader;
57
58 public:
64 downloader() noexcept {}
65
69 downloader(downloader&& other) noexcept = default;
70
74 downloader& operator=(downloader&& other) noexcept = default;
75
76 downloader(downloader const& other) = delete;
77 downloader& operator=(downloader const& other) = delete;
78
82 ~downloader() = default;
83
87 /* explicit(false) */ downloader(v1::gridfs::downloader downloader) : _downloader{std::move(downloader)} {}
88
97 explicit operator v1::gridfs::downloader() && {
98 return std::move(_downloader);
99 }
100
104 explicit operator v1::gridfs::downloader() const& = delete;
105
110 explicit operator bool() const noexcept {
111 return _downloader.operator bool();
112 }
113
134 MONGOCXX_ABI_EXPORT_CDECL(std::size_t) read(std::uint8_t* buffer, std::size_t length);
135
142
150
158
166
167 class internal;
168};
169
170} // namespace gridfs
171} // namespace v_noabi
172} // namespace mongocxx
173
174namespace mongocxx {
175namespace v_noabi {
176
181 return {std::move(v)};
182}
183
190
191} // namespace v_noabi
192} // namespace mongocxx
193
195
A read-only, non-owning view of a BSON document.
Definition view.hpp:40
downloader() noexcept
Default constructs a downloader object. The downloader is equivalent to the state of a moved from dow...
Definition downloader.hpp:64
Support for downloading files from a GridFS bucket.
Definition downloader.hpp:44
Used to download a GridFS file.
Definition downloader.hpp:54
downloader & operator=(downloader &&other) noexcept=default
Move assigns a downloader.
downloader() noexcept
Default constructs a downloader object. The downloader is equivalent to the state of a moved from dow...
Definition downloader.hpp:64
bsoncxx::v_noabi::document::view files_document() const
Gets the files collection document of the file being downloaded.
downloader(downloader &&other) noexcept=default
Move constructs a downloader.
~downloader()=default
Destroys a downloader.
std::int32_t chunk_size() const
Gets the chunk size of the file being downloaded.
downloader(v1::gridfs::downloader downloader)
Construct with the mongocxx::v1 equivalent.
Definition downloader.hpp:87
void close()
Closes the downloader stream.
std::size_t read(std::uint8_t *buffer, std::size_t length)
Reads a specified number of bytes from the GridFS file being downloaded.
std::int64_t file_length() const
Gets the length of the file being downloaded.
#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 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.
Used to specify the offset from which to start reading the chunks of the file.
Definition downloader.hpp:46
Provides mongocxx::v1::gridfs::downloader.
Provides bsoncxx::v_noabi::document::value.
Provides bsoncxx::v_noabi::document::view.
Provides std::optional-related polyfills for library API usage.
Provides bsoncxx::v_noabi::types::bson_value::view.
Provides mongocxx::v_noabi::cursor.
Declares mongocxx::v_noabi::gridfs::bucket.
Declares utilities to download GridFS files.