libcdoc 0.5.0
libcdoc::OStreamConsumer Struct Reference

#include <Io.h>

Inherits libcdoc::DataConsumer.

Public Member Functions

 OStreamConsumer (std::ostream *ofs, bool take_ownership=false)
 OStreamConsumer (const std::string &path)
 ~OStreamConsumer ()
result_t write (const uint8_t *src, size_t size) noexcept override
 write write bytes to output object
result_t close () noexcept override
 informs DataConsumer that the writing is finished
bool isError () noexcept override
 checks whether DataSource is in error state
Public Member Functions inherited from libcdoc::DataConsumer
 DataConsumer ()=default
virtual ~DataConsumer ()=default
virtual std::string getLastErrorStr (result_t code) const
 get textual description of the last error
result_t write (const std::vector< uint8_t > &src) noexcept
 write all bytes in vector
result_t write (const std::string &src) noexcept
 write all bytes in string
result_t writeAll (DataSource &src) noexcept
 write all data from input object
 DataConsumer (const DataConsumer &)=delete
DataConsumeroperator= (const DataConsumer &)=delete

Static Public Attributes

static constexpr int STREAM_ERROR = -500

Protected Attributes

std::ostream * _ofs
bool _owned

Constructor & Destructor Documentation

◆ OStreamConsumer() [1/2]

libcdoc::OStreamConsumer::OStreamConsumer ( std::ostream * ofs,
bool take_ownership = false )
inline

References _ofs, and _owned.

◆ OStreamConsumer() [2/2]

libcdoc::OStreamConsumer::OStreamConsumer ( const std::string & path)

◆ ~OStreamConsumer()

libcdoc::OStreamConsumer::~OStreamConsumer ( )
inline

References _ofs, and _owned.

Member Function Documentation

◆ close()

result_t libcdoc::OStreamConsumer::close ( )
inlineoverridevirtualnoexcept

informs DataConsumer that the writing is finished

Returns
error code or OK

Implements libcdoc::DataConsumer.

References _ofs, libcdoc::OK, and libcdoc::OUTPUT_STREAM_ERROR.

◆ isError()

bool libcdoc::OStreamConsumer::isError ( )
inlineoverridevirtualnoexcept

checks whether DataSource is in error state

Returns
true if error state

Implements libcdoc::DataConsumer.

References _ofs.

◆ write()

result_t libcdoc::OStreamConsumer::write ( const uint8_t * src,
size_t size )
inlineoverridevirtualnoexcept

write write bytes to output object

The following invariant holds: If there was no error then result == size If there was an error then result < 0

Parameters
srcsource block
sizethe number of bytes to write
Returns
size or error code

Implements libcdoc::DataConsumer.

References _ofs, and libcdoc::OUTPUT_STREAM_ERROR.

Member Data Documentation

◆ _ofs

std::ostream* libcdoc::OStreamConsumer::_ofs
protected

◆ _owned

bool libcdoc::OStreamConsumer::_owned
protected

◆ STREAM_ERROR

int libcdoc::OStreamConsumer::STREAM_ERROR = -500
staticconstexpr

The documentation for this struct was generated from the following file:
  • Io.h