StormByte C++ Library: Buffer module 1.2.0
StormByte-Buffer is the buffer module of the StormByte C++ suite.
Loading...
Searching...
No Matches
List of all members
StormByte::Buffer::ExternalReader Class Referenceabstract

Abstract interface for reading data from an external or internal source. More...

#include <StormByte/buffer/external.hxx>

Inheritance diagram for StormByte::Buffer::ExternalReader:
Inheritance graph
[legend]
Collaboration diagram for StormByte::Buffer::ExternalReader:
Collaboration graph
[legend]

Public Member Functions

Constructors / destructor / assignment
 ExternalReader () noexcept=default
 
 ExternalReader (const ExternalReader &)=default
 
 ExternalReader (ExternalReader &&) noexcept=default
 
 ~ExternalReader () noexcept override
 
ExternalReaderoperator= (const ExternalReader &)=default
 
ExternalReaderoperator= (ExternalReader &&) noexcept=default
 
Queries
virtual std::size_t AvailableBytes () const noexcept=0
 Number of bytes currently available for reading.
 
virtual bool Empty () const noexcept=0
 Whether the underlying source holds no data.
 
virtual bool EoF () const noexcept=0
 End-of-file / end-of-stream condition.
 
virtual bool IsReadable () const noexcept=0
 Whether the source can still be read.
 
Reading
virtual bool Read (std::size_t count, DataType &out) const noexcept=0
 Non-destructive read (advances the logical position).
 
bool Read (DataType &out) const noexcept
 Convenience overload — read all available bytes.
 
virtual bool Extract (std::size_t count, DataType &out) noexcept=0
 Destructive read (consumes / erases data from the source).
 
bool Extract (DataType &out) noexcept
 Convenience overload — extract all available bytes.
 
virtual bool Peek (std::size_t count, DataType &out) const noexcept=0
 Non-destructive peek (does not advance the position).
 
virtual void ReadUntilEoF (DataType &out) const noexcept=0
 Read everything until EoF (non-destructive).
 
virtual void ExtractUntilEoF (DataType &out) noexcept=0
 Extract everything until EoF (destructive).
 
Positioning / maintenance
virtual void Seek (std::ptrdiff_t offset, Position mode) const noexcept
 Move the logical read position.
 
virtual void Clean () noexcept
 Discard already-consumed data (from start up to the current read position).
 

Detailed Description

Abstract interface for reading data from an external or internal source.

Overview
Provides a buffer-agnostic reading API so that pipeline stages (and other consumers) can work uniformly against any concrete source (file, socket, Ring, LockFreeRing, FIFO, etc.).
Design goals
  • Rich enough to replace direct use of ReadOnly / Consumer inside Pipeline stages.
  • Lets the Pipeline inject any concrete buffer implementation (including private ones such as LockFreeRing) without changing stage code.
Note
Implementations are expected to be lightweight adapters; the real storage lives elsewhere.
See also
ExternalBufferReader, ExternalWriter, Pipeline

Constructor & Destructor Documentation

◆ ExternalReader() [1/3]

StormByte::Buffer::ExternalReader::ExternalReader ( )
defaultnoexcept

◆ ExternalReader() [2/3]

StormByte::Buffer::ExternalReader::ExternalReader ( const ExternalReader )
default

◆ ExternalReader() [3/3]

StormByte::Buffer::ExternalReader::ExternalReader ( ExternalReader &&  )
defaultnoexcept

◆ ~ExternalReader()

StormByte::Buffer::ExternalReader::~ExternalReader ( )
overridenoexcept

Member Function Documentation

◆ AvailableBytes()

virtual std::size_t StormByte::Buffer::ExternalReader::AvailableBytes ( ) const
pure virtualnoexcept

Number of bytes currently available for reading.

Returns
Bytes that can be read without blocking (or until EoF).

Implemented in StormByte::Buffer::ExternalBufferReader.

◆ Clean()

virtual void StormByte::Buffer::ExternalReader::Clean ( )
virtualnoexcept

Discard already-consumed data (from start up to the current read position).

Note
Default implementation is a no-op.

Reimplemented in StormByte::Buffer::ExternalBufferReader.

◆ Empty()

virtual bool StormByte::Buffer::ExternalReader::Empty ( ) const
pure virtualnoexcept

Whether the underlying source holds no data.

Returns
true if no data remains.

Implemented in StormByte::Buffer::ExternalBufferReader.

◆ EoF()

virtual bool StormByte::Buffer::ExternalReader::EoF ( ) const
pure virtualnoexcept

End-of-file / end-of-stream condition.

Returns
true when the source is closed (or in error) and no more bytes are available.

Implemented in StormByte::Buffer::ExternalBufferReader.

◆ Extract() [1/2]

bool StormByte::Buffer::ExternalReader::Extract ( DataType out)
inlinenoexcept

Convenience overload — extract all available bytes.

Parameters
outDestination buffer.
Returns
true on success, false on insufficient data or error.

◆ Extract() [2/2]

virtual bool StormByte::Buffer::ExternalReader::Extract ( std::size_t  count,
DataType out 
)
pure virtualnoexcept

Destructive read (consumes / erases data from the source).

Parameters
countNumber of bytes requested (0 = all available).
outDestination buffer (appended to).
Returns
true on success, false on insufficient data or error.

Implemented in StormByte::Buffer::ExternalBufferReader.

◆ ExtractUntilEoF()

virtual void StormByte::Buffer::ExternalReader::ExtractUntilEoF ( DataType out)
pure virtualnoexcept

Extract everything until EoF (destructive).

Parameters
outDestination buffer.

Implemented in StormByte::Buffer::ExternalBufferReader.

◆ IsReadable()

virtual bool StormByte::Buffer::ExternalReader::IsReadable ( ) const
pure virtualnoexcept

Whether the source can still be read.

Returns
false when the source is in a permanent error state.

Implemented in StormByte::Buffer::ExternalBufferReader.

◆ operator=() [1/2]

ExternalReader & StormByte::Buffer::ExternalReader::operator= ( const ExternalReader )
default

◆ operator=() [2/2]

ExternalReader & StormByte::Buffer::ExternalReader::operator= ( ExternalReader &&  )
defaultnoexcept

◆ Peek()

virtual bool StormByte::Buffer::ExternalReader::Peek ( std::size_t  count,
DataType out 
) const
pure virtualnoexcept

Non-destructive peek (does not advance the position).

Parameters
countNumber of bytes requested (0 = all available).
outDestination buffer (appended to).
Returns
true on success, false on insufficient data or error.

Implemented in StormByte::Buffer::ExternalBufferReader.

◆ Read() [1/2]

bool StormByte::Buffer::ExternalReader::Read ( DataType out) const
inlinenoexcept

Convenience overload — read all available bytes.

Parameters
outDestination buffer.
Returns
true on success, false on insufficient data or error.

◆ Read() [2/2]

virtual bool StormByte::Buffer::ExternalReader::Read ( std::size_t  count,
DataType out 
) const
pure virtualnoexcept

Non-destructive read (advances the logical position).

Parameters
countNumber of bytes requested (0 = all available).
outDestination buffer (appended to).
Returns
true on success, false on insufficient data or error.

Implemented in StormByte::Buffer::ExternalBufferReader.

◆ ReadUntilEoF()

virtual void StormByte::Buffer::ExternalReader::ReadUntilEoF ( DataType out) const
pure virtualnoexcept

Read everything until EoF (non-destructive).

Parameters
outDestination buffer.

Implemented in StormByte::Buffer::ExternalBufferReader.

◆ Seek()

virtual void StormByte::Buffer::ExternalReader::Seek ( std::ptrdiff_t  offset,
Position  mode 
) const
virtualnoexcept

Move the logical read position.

Parameters
offsetOffset value.
modePosition::Absolute or Position::Relative.
Note
Default implementation is a no-op. Concrete adapters that support seeking should override it.

Reimplemented in StormByte::Buffer::ExternalBufferReader.


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