libcdoc 0.1.8
libcdoc::VectorSource Struct Reference

#include <Io.h>

Inherits libcdoc::DataSource.

Public Member Functions

 VectorSource (const std::vector< uint8_t > &data)
 
result_t seek (size_t pos) override
 set stream input pointer
 
result_t read (uint8_t *dst, size_t size) override
 read bytes from input object
 
bool isError () override
 check whether DataConsumer is in error state
 
bool isEof () override
 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

const std::vector< uint8_t > & _data
 
size_t _ptr
 

Constructor & Destructor Documentation

◆ VectorSource()

libcdoc::VectorSource::VectorSource ( const std::vector< uint8_t > &  data)
inline

Member Function Documentation

◆ isEof()

bool libcdoc::VectorSource::isEof ( )
inlineoverridevirtual

check whether DataConsumer is reached to the end of data

Returns
true if end of stream

Reimplemented from libcdoc::DataSource.

◆ isError()

bool libcdoc::VectorSource::isError ( )
inlineoverridevirtual

check whether DataConsumer is in error state

Returns
true if error state

Reimplemented from libcdoc::DataSource.

◆ read()

result_t libcdoc::VectorSource::read ( uint8_t *  dst,
size_t  size 
)
inlineoverridevirtual

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.

◆ seek()

result_t libcdoc::VectorSource::seek ( size_t  pos)
inlineoverridevirtual

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

◆ _data

const std::vector<uint8_t>& libcdoc::VectorSource::_data
protected

◆ _ptr

size_t libcdoc::VectorSource::_ptr
protected

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