Loading...
Searching...
No Matches
downloader.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/gridfs/downloader-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/gridfs/downloader.hpp> // IWYU pragma: export
#include <cstddef>
#include <cstdint>
#include <memory> // IWYU pragma: keep: backward compatibility, to be removed.
#include <utility>
#include <mongocxx/gridfs/bucket-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/document/value.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/document/view.hpp>
#include <bsoncxx/stdx/optional.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/types/bson_value/view.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/cursor.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
namespace gridfs {
struct chunks_and_bytes_offset {
std::int32_t chunks_offset = 0;
std::int32_t bytes_offset = 0;
};
class downloader {
private:
v1::gridfs::downloader _downloader;
public:
downloader() noexcept {}
downloader(downloader&& other) noexcept = default;
downloader& operator=(downloader&& other) noexcept = default;
downloader(downloader const& other) = delete;
downloader& operator=(downloader const& other) = delete;
~downloader() = default;
/* explicit(false) */ downloader(v1::gridfs::downloader downloader) : _downloader{std::move(downloader)} {}
explicit operator v1::gridfs::downloader() && {
return std::move(_downloader);
}
explicit operator v1::gridfs::downloader() const& = delete;
explicit operator bool() const noexcept {
return _downloader.operator bool();
}
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(std::size_t) read(std::uint8_t* buffer, std::size_t length);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void) close();
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(std::int32_t) chunk_size() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(std::int64_t) file_length() const;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::document::view) files_document() const;
class internal;
};
} // namespace gridfs
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::gridfs::downloader from_v1(v1::gridfs::downloader v) {
return {std::move(v)};
}
inline v1::gridfs::downloader to_v1(v_noabi::gridfs::downloader v) {
return v1::gridfs::downloader{std::move(v)};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
bsoncxx::v_noabi::document::view
A read-only, non-owning view of a BSON document.
Definition view.hpp:40
mongocxx::gridfs::downloader::downloader
downloader() noexcept
Default constructs a downloader object. The downloader is equivalent to the state of a moved from dow...
Definition downloader.hpp:64
mongocxx::v1::gridfs::downloader
Support for downloading files from a GridFS bucket.
Definition downloader.hpp:42
mongocxx::v_noabi::gridfs::downloader
Used to download a GridFS file.
Definition downloader.hpp:54
mongocxx::v_noabi::gridfs::downloader::operator=
downloader & operator=(downloader &&other) noexcept=default
Move assigns a downloader.
mongocxx::v_noabi::gridfs::downloader::downloader
downloader() noexcept
Default constructs a downloader object. The downloader is equivalent to the state of a moved from dow...
Definition downloader.hpp:64
mongocxx::v_noabi::gridfs::downloader::files_document
bsoncxx::v_noabi::document::view files_document() const
Gets the files collection document of the file being downloaded.
mongocxx::v_noabi::gridfs::downloader::downloader
downloader(downloader &&other) noexcept=default
Move constructs a downloader.
mongocxx::v_noabi::gridfs::downloader::~downloader
~downloader()=default
Destroys a downloader.
mongocxx::v_noabi::gridfs::downloader::chunk_size
std::int32_t chunk_size() const
Gets the chunk size of the file being downloaded.
mongocxx::v_noabi::gridfs::downloader::downloader
downloader(v1::gridfs::downloader downloader)
Construct with the mongocxx::v1 equivalent.
Definition downloader.hpp:87
mongocxx::v_noabi::gridfs::downloader::close
void close()
Closes the downloader stream.
mongocxx::v_noabi::gridfs::downloader::read
std::size_t read(std::uint8_t *buffer, std::size_t length)
Reads a specified number of bytes from the GridFS file being downloaded.
mongocxx::v_noabi::gridfs::downloader::file_length
std::int64_t file_length() const
Gets the length of the file being downloaded.
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE
#define MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to MONGOCXX_ABI_EXPORT_UNSTABLE with MONGOCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The mongocxx v_noabi macro guard postlude header.
prelude.hpp
The mongocxx v_noabi macro guard prelude header.
mongocxx::v_noabi::gridfs
Declares entities related to GridFS.
mongocxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
mongocxx::v_noabi::to_v1
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
mongocxx::v_noabi::from_v1
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
mongocxx::v_noabi::gridfs::chunks_and_bytes_offset
Used to specify the offset from which to start reading the chunks of the file.
Definition downloader.hpp:46
downloader.hpp
Provides mongocxx::v1::gridfs::downloader.
value.hpp
Provides bsoncxx::v_noabi::document::value.
view.hpp
Provides bsoncxx::v_noabi::document::view.
optional.hpp
Provides std::optional-related polyfills for library API usage.
view.hpp
Provides bsoncxx::v_noabi::types::bson_value::view.
cursor.hpp
Provides mongocxx::v_noabi::cursor.
bucket-fwd.hpp
Declares mongocxx::v_noabi::gridfs::bucket.
downloader-fwd.hpp
Declares utilities to download GridFS files.