libcdoc 0.1.8
libcdoc::IStreamSource Struct Reference

#include <Io.h>

Inherits libcdoc::DataSource.

Public Member Functions

 IStreamSource (std::istream *ifs, bool take_ownership=false)
 
 IStreamSource (const std::string &path)
 
 ~IStreamSource ()
 
result_t seek (size_t pos)
 set stream input pointer
 
result_t read (uint8_t *dst, size_t size)
 read bytes from input object
 
bool isError ()
 check whether DataConsumer is in error state
 
bool isEof ()
 check whether DataConsumer is reached to the end of data
 
- Public Member Functions inherited from libcdoc::DataSource
 DataSource ()=default
 
virtual ~DataSource ()=default
 
virtual std::string getLastErrorStr (result_t code) const
 get textual description of the last error
 
result_t skip (size_t size)
 skip specified number of bytes
 
result_t readAll (DataConsumer &dst)
 read all data and writes to output object
 
 DataSource (const DataSource &)=delete
 
DataSourceoperator= (const DataSource &)=delete
 

Protected Attributes

std::istream * _ifs
 
bool _owned
 

Constructor & Destructor Documentation

◆ IStreamSource() [1/2]

libcdoc::IStreamSource::IStreamSource ( std::istream *  ifs,
bool  take_ownership = false 
)
inline

◆ IStreamSource() [2/2]

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

◆ ~IStreamSource()

libcdoc::IStreamSource::~IStreamSource ( )
inline

Member Function Documentation

◆ isEof()

bool libcdoc::IStreamSource::isEof ( )
inlinevirtual

check whether DataConsumer is reached to the end of data

Returns
true if end of stream

Reimplemented from libcdoc::DataSource.

◆ isError()

bool libcdoc::IStreamSource::isError ( )
inlinevirtual

check whether DataConsumer is in error state

Returns
true if error state

Reimplemented from libcdoc::DataSource.

◆ read()

result_t libcdoc::IStreamSource::read ( uint8_t *  dst,
size_t  size 
)
inlinevirtual

read bytes from input object

The following invariant holds:

  • if there is neither error nor eof then result == size
  • if there is no errors but end of stream is reached then 0 <= result <= size
  • if there is error then result < 0
    Parameters
    dstthe destination block
    sizethe number of bytes to read
    Returns
    the number of bytes read or error code

Reimplemented from libcdoc::DataSource.

References libcdoc::INPUT_STREAM_ERROR.

◆ seek()

result_t libcdoc::IStreamSource::seek ( size_t  pos)
inlinevirtual

set stream input pointer

Positions the read pointer at the specific distance from the stream start. If the stream does not support seeking NOT_IMPLEMENTED is returned.

Parameters
posthe position from the beggining of data
Returns
error code or OK

Reimplemented from libcdoc::DataSource.

References libcdoc::INPUT_STREAM_ERROR, and libcdoc::OK.

Member Data Documentation

◆ _ifs

std::istream* libcdoc::IStreamSource::_ifs
protected

◆ _owned

bool libcdoc::IStreamSource::_owned
protected

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