Loading...
Searching...
No Matches
mongocxx::v1::gridfs::downloader Class Reference

`#include <mongocxx/v1/gridfs/downloader.hpp>`

## Description

Support for downloading files from a GridFS bucket.

See also
  - GridFS (MongoDB Manual)

## Public Types

enum class | errc
| Errors codes which may be returned by mongocxx::v1::gridfs::downloader. More...

## Public Member Functions

| downloader ()
| Default initialization.
| downloader (downloader &&other) noexcept
| Move constructor.
| downloader (downloader const &other)=delete
| This class is not copyable.
| ~downloader ()
| Destroy this object.
std::int32_t | chunk_size () const
| Return the chunk size (in bytes) of the associated GridFS file.
void | close ()
| Close the underlying GridFS download stream.
std::int64_t | file_length () const
| Return the length of the associated GridFS file.
bsoncxx::v1::document::view | files_document () const
| Return the files collection document for the associated GridFS file.
bool | is_open () const
| Return true when the underlying GridFS file stream is open for reading.
| operator bool () const
| Return true when *this is NOT in an assign-or-destroy-only state and this->is_open() == true.
downloader & | operator= (downloader &&other) noexcept
| Move assignment.
downloader & | operator= (downloader const &other)=delete
| This class is not copyable.
std::size_t | read (std::uint8_t *data, std::size_t length)
| Read up to length bytes of the associated GridFS file.

## Static Public Member Functions

static std::error_category const & | error_category ()
| The error category for mongocxx::v1::gridfs::downloader::errc.

## Friends

std::error_code | make_error_code (errc v)
| Support implicit conversion to std::error_code.

## Member Enumeration Documentation

## errc

enum class mongocxx::v1::gridfs::downloader::errc

strong

Errors codes which may be returned by mongocxx::v1::gridfs::downloader.

Enumerator
zero | Zero.
is_closed | The GridFS file download stream is not open.
corrupt_data | The GridFS file is in an invalid or inconsistent state.

## Constructor & Destructor Documentation

## ~downloader()

mongocxx::v1::gridfs::downloader::~downloader | ( |  | ) |

Destroy this object.

Warning
  Invalidates all associated views.

## downloader() [1/3]

mongocxx::v1::gridfs::downloader::downloader | ( | downloader && | other | ) |

noexcept

Move constructor.

Postconditions:
  - other is in an assign-or-destroy-only state.

## downloader() [2/3]

mongocxx::v1::gridfs::downloader::downloader | ( | downloader const & | other | ) |

delete

This class is not copyable.

## downloader() [3/3]

mongocxx::v1::gridfs::downloader::downloader | ( |  | ) |

Default initialization.

Postconditions:
  - *this is in an assign-or-destroy-only state.

## Member Function Documentation

## chunk_size()

std::int32_t mongocxx::v1::gridfs::downloader::chunk_size | ( |  | ) | const

Return the chunk size (in bytes) of the associated GridFS file.

## close()

void mongocxx::v1::gridfs::downloader::close | ( |  | ) |

Close the underlying GridFS download stream.

## error_category()

std::error_category const & mongocxx::v1::gridfs::downloader::error_category | ( |  | ) |

static

The error category for mongocxx::v1::gridfs::downloader::errc.

## file_length()

std::int64_t mongocxx::v1::gridfs::downloader::file_length | ( |  | ) | const

Return the length of the associated GridFS file.

## files_document()

bsoncxx::v1::document::view mongocxx::v1::gridfs::downloader::files_document | ( |  | ) | const

Return the files collection document for the associated GridFS file.

## is_open()

bool mongocxx::v1::gridfs::downloader::is_open | ( |  | ) | const

Return true when the underlying GridFS file stream is open for reading.

## operator bool()

mongocxx::v1::gridfs::downloader::operator bool | ( |  | ) | const

explicit

Return true when *this is NOT in an assign-or-destroy-only state and this->is_open() == true.

## operator=() [1/2]

downloader & mongocxx::v1::gridfs::downloader::operator= | ( | downloader && | other | ) |

noexcept

Move assignment.

Postconditions:
  - other is in an assign-or-destroy-only state.

## operator=() [2/2]

downloader & mongocxx::v1::gridfs::downloader::operator= | ( | downloader const & | other | ) |

delete

This class is not copyable.

## read()

std::size_t mongocxx::v1::gridfs::downloader::read | ( | std::uint8_t * | data,
|  | std::size_t | length )

Read up to length bytes of the associated GridFS file.

Preconditions:
  - data is not null.
  - The size of the storage region pointed to by data must be greater than or equal to length.

Returns
  The actual number of bytes read. 0 indicates the downloader has reached the end of the file.

Exceptions

  mongocxx::v1::exception | with mongocxx::v1::gridfs::downloader::errc::is_closed if the underlying GridFS download stream was already closed.
  mongocxx::v1::exception | with mongocxx::v1::gridfs::downloader::errc::corrupt_data if the GridFS file data is invalid or inconsistent.
  mongocxx::v1::server_error | when a server-side error is encountered and a raw server error is available.

## Friends And Related Symbol Documentation

## make_error_code

std::error_code make_error_code | ( | errc | v | ) |

friend

Support implicit conversion to std::error_code.

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

- mongocxx/v1/gridfs/downloader.hpp