MongoDB C++ Driver mongocxx-3.10.1
Loading...
Searching...
No Matches
Public Member Functions | List of all members
mongocxx::v_noabi::gridfs::downloader Class Reference

Class used to download a GridFS file. More...

#include <downloader.hpp>

Public Member Functions

 downloader () noexcept
 Default constructs a downloader object.
 
 downloader (downloader &&) noexcept
 Move constructs a downloader.
 
downloaderoperator= (downloader &&) noexcept
 Move assigns a downloader.
 
 ~downloader ()
 Destroys a downloader.
 
 operator bool () const noexcept
 Returns true if the downloader is valid, meaning it was not default constructed or moved from.
 
std::size_t read (std::uint8_t *buffer, std::size_t length)
 Reads a specified number of bytes from the GridFS file being downloaded.
 
void close ()
 Closes the downloader stream.
 
std::int32_t chunk_size () const
 Gets the chunk size of the file being downloaded.
 
std::int64_t file_length () const
 Gets the length of the file being downloaded.
 
bsoncxx::v_noabi::document::view files_document () const
 Gets the files collection document of the file being downloaded.
 

Detailed Description

Class used to download a GridFS file.

Constructor & Destructor Documentation

◆ downloader()

mongocxx::v_noabi::gridfs::downloader::downloader ( )
noexcept

Default constructs a downloader object.

The downloader is equivalent to the state of a moved from downloader. The only valid actions to take with a default constructed downloader are to assign to it, or destroy it.

Member Function Documentation

◆ chunk_size()

std::int32_t mongocxx::v_noabi::gridfs::downloader::chunk_size ( ) const

Gets the chunk size of the file being downloaded.

Returns
The chunk size in bytes.

◆ close()

void mongocxx::v_noabi::gridfs::downloader::close ( )

Closes the downloader stream.

Exceptions
mongocxx::v_noabi::logic_errorif the download stream was already closed.

◆ file_length()

std::int64_t mongocxx::v_noabi::gridfs::downloader::file_length ( ) const

Gets the length of the file being downloaded.

Returns
The length in bytes.

◆ files_document()

bsoncxx::v_noabi::document::view mongocxx::v_noabi::gridfs::downloader::files_document ( ) const

Gets the files collection document of the file being downloaded.

Returns
A view to the files collection document of the file being downloaded.

◆ read()

std::size_t mongocxx::v_noabi::gridfs::downloader::read ( std::uint8_t *  buffer,
std::size_t  length 
)

Reads a specified number of bytes from the GridFS file being downloaded.

Parameters
bufferA pointer to a buffer to store the bytes read from the file.
lengthThe number of bytes to read from the file.
Returns
The number of bytes actually read. If zero, the downloader has reached the end of the file.
Exceptions
mongocxx::v_noabi::logic_errorif the download stream was already closed.
mongocxx::v_noabi::gridfs_exceptionif the requested file has been corrupted.
mongocxx::v_noabi::query_exceptionif an error occurs when reading chunk data from the database for the requested file.

The documentation for this class was generated from the following file: