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/v1/gridfs/downloader-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/detail/prelude.hpp>
#include <bsoncxx/v1/document/view-fwd.hpp>
#include <mongocxx/v1/config/export.hpp>
#include <cstddef>
#include <cstdint>
#include <system_error>
#include <type_traits>
namespace mongocxx {
namespace v1 {
namespace gridfs {
class downloader {
private:
class impl;
void* _impl;
public:
MONGOCXX_ABI_EXPORT_CDECL() ~downloader();
MONGOCXX_ABI_EXPORT_CDECL() downloader(downloader&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(downloader&) operator=(downloader&& other) noexcept;
downloader(downloader const& other) = delete;
downloader& operator=(downloader const& other) = delete;
MONGOCXX_ABI_EXPORT_CDECL() downloader();
explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
MONGOCXX_ABI_EXPORT_CDECL(bool) is_open() const;
MONGOCXX_ABI_EXPORT_CDECL(void) close();
MONGOCXX_ABI_EXPORT_CDECL(std::int32_t) chunk_size() const;
MONGOCXX_ABI_EXPORT_CDECL(std::int64_t) file_length() const;
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::document::view) files_document() const;
MONGOCXX_ABI_EXPORT_CDECL(std::size_t) read(std::uint8_t* data, std::size_t length);
enum class errc {
zero,
is_closed,
corrupt_data,
};
static MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
friend std::error_code make_error_code(errc v) {
return {static_cast<int>(v), error_category()};
}
class internal;
private:
/* explicit(false) */ downloader(void* impl);
void download_next_chunk();
};
} // namespace gridfs
} // namespace v1
} // namespace mongocxx
namespace std {
template <>
struct is_error_code_enum<mongocxx::v1::gridfs::downloader::errc> : true_type {};
} // namespace std
#include <mongocxx/v1/detail/postlude.hpp>
mongocxx::v1::gridfs::downloader::is_open
bool is_open() const
Return true when the underlying GridFS file stream is open for reading.
mongocxx::v1::gridfs::downloader::file_length
std::int64_t file_length() const
Return the length of the associated GridFS file.
mongocxx::v1::gridfs::downloader::downloader
downloader(downloader &&other) noexcept
Move constructor.
mongocxx::v1::gridfs::downloader::chunk_size
std::int32_t chunk_size() const
Return the chunk size (in bytes) of the associated GridFS file.
mongocxx::v1::gridfs::downloader::make_error_code
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition downloader.hpp:153
mongocxx::v1::gridfs::downloader::read
std::size_t read(std::uint8_t *data, std::size_t length)
Read up to length bytes of the associated GridFS file.
mongocxx::v1::gridfs::downloader::errc
errc
Errors codes which may be returned by mongocxx::v1::gridfs::downloader.
Definition downloader.hpp:139
mongocxx::v1::gridfs::downloader::errc::is_closed
@ is_closed
The GridFS file download stream is not open.
Definition downloader.hpp:141
mongocxx::v1::gridfs::downloader::errc::corrupt_data
@ corrupt_data
The GridFS file is in an invalid or inconsistent state.
Definition downloader.hpp:142
mongocxx::v1::gridfs::downloader::errc::zero
@ zero
Zero.
Definition downloader.hpp:140
mongocxx::v1::gridfs::downloader::files_document
bsoncxx::v1::document::view files_document() const
Return the files collection document for the associated GridFS file.
mongocxx::v1::gridfs::downloader::close
void close()
Close the underlying GridFS download stream.
mongocxx::v1::gridfs::downloader::downloader
downloader()
Default initialization.
mongocxx::v1::gridfs::downloader::error_category
static std::error_category const & error_category()
The error category for mongocxx::v1::gridfs::downloader::errc.
mongocxx::v1::gridfs::downloader::~downloader
~downloader()
Destroy this object.
export.hpp
Provides macros to control the set of symbols exported in the ABI.
MONGOCXX_ABI_EXPORT_CDECL
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
postlude.hpp
The mongocxx v1 macro guard postlude header.
prelude.hpp
The mongocxx v1 macro guard prelude header.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
mongocxx::v1::gridfs
Declares entities related to GridFS.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx::v1::source_errc::mongocxx
@ mongocxx
From the mongocxx library.
Definition exception.hpp:40
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
view-fwd.hpp
Declares bsoncxx::v1::document::view.
downloader-fwd.hpp
Declares mongocxx::v1::gridfs::downloader.