OpenEnroth 73e68f7
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
BlobInputStream Class Reference

#include <BlobInputStream.h>

Inheritance diagram for BlobInputStream:
InputStream FFmpegBlobInputStream detail::MemoryFileSystemInputStream

Public Member Functions

 BlobInputStream ()=default
 
 BlobInputStream (Blob &&blob)
 
 BlobInputStream (const Blob &blob)
 
void open (Blob &&blob)
 
void open (const Blob &blob)
 
virtual size_t read (void *data, size_t size) override
 
virtual size_t skip (size_t size) override
 
virtual void close () override
 
virtual std::string displayPath () const override
 
void seek (ssize_t pos)
 
ssize_t position () const
 
ssize_t size () const
 
Blob tail () const
 
Blob readBlob (size_t size)
 
Blob readBlobOrFail (size_t size)
 
- Public Member Functions inherited from InputStream
virtual ~InputStream ()
 
virtual size_t read (void *data, size_t size)=0
 
void readOrFail (void *data, size_t size)
 
std::string readAll (size_t maxSize=-1)
 
virtual size_t skip (size_t size)=0
 
void skipOrFail (size_t size)
 
virtual void close ()=0
 
virtual std::string displayPath () const =0
 

Private Member Functions

size_t remaining () const
 

Private Attributes

Blob _blob
 
const char * _pos = nullptr
 
const char * _end = nullptr
 

Detailed Description

Input stream that reads from a Blob.

Besides the InputStream interface, this class also offers an interface for reading subblobs which share memory with the source blob, and thus no memory copying occurs.

Constructor & Destructor Documentation

◆ BlobInputStream() [1/3]

BlobInputStream::BlobInputStream ( )
default

◆ BlobInputStream() [2/3]

BlobInputStream::BlobInputStream ( Blob &&  blob)
explicit

◆ BlobInputStream() [3/3]

BlobInputStream::BlobInputStream ( const Blob blob)
explicit

Member Function Documentation

◆ close()

void BlobInputStream::close ( )
overridevirtual

Closes this input stream. Reading from a closed stream will result in undefined behavior.

Does nothing if the stream is already closed.

Exceptions
ExceptionOn error.

Implements InputStream.

Reimplemented in detail::MemoryFileSystemInputStream, and FFmpegBlobInputStream.

◆ displayPath()

std::string BlobInputStream::displayPath ( ) const
overridevirtual
Returns
Path to the file or resource being read, to be used for debugging and error reporting.

Implements InputStream.

◆ open() [1/2]

void BlobInputStream::open ( Blob &&  blob)

◆ open() [2/2]

void BlobInputStream::open ( const Blob blob)

◆ position()

ssize_t BlobInputStream::position ( ) const

◆ read()

size_t BlobInputStream::read ( void *  data,
size_t  size 
)
overridevirtual
Parameters
dataOutput buffer to write read data into.
sizeNumber of bytes to read.
Returns
Number of bytes actually read. A return value that's less than size signals end of stream.
Exceptions
ExceptionOn error.

Implements InputStream.

◆ readBlob()

Blob BlobInputStream::readBlob ( size_t  size)

Same as read, but returns the data as a blob that's shared with the blob that this stream is reading from.

This basically presents a way to conveniently cut a blob into subblobs using a streaming interface.

Parameters
sizeNumber of bytes to read.
Returns
Subblob of the blob that this stream is reading from. Actual size might be less than size if end of stream is encountered.

◆ readBlobOrFail()

Blob BlobInputStream::readBlobOrFail ( size_t  size)

Same as readOrFail, but returns the data as a blob that's shared with the blob that this stream is reading from.

Parameters
sizeNumber of bytes to read.
Returns
Subblob of the blob that this stream is reading from.
Exceptions
ExceptionIf there is not enough data in the stream.

◆ remaining()

size_t BlobInputStream::remaining ( ) const
private

◆ seek()

void BlobInputStream::seek ( ssize_t  pos)

◆ size()

ssize_t BlobInputStream::size ( ) const

◆ skip()

size_t BlobInputStream::skip ( size_t  size)
overridevirtual
Parameters
sizeNumber of bytes to skip.
Returns
Number of bytes actually skipped. A return value that's less than size signals end of stream.
Exceptions
ExceptionOn error.

Implements InputStream.

◆ tail()

Blob BlobInputStream::tail ( ) const
Returns
Remaining stream data, as a blob that's shared with the blob that this stream is reading from.

Member Data Documentation

◆ _blob

Blob BlobInputStream::_blob
private

◆ _end

const char* BlobInputStream::_end = nullptr
private

◆ _pos

const char* BlobInputStream::_pos = nullptr
private

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