StormByte-Buffer 4.0.0
C++26 buffer module of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Buffer::ReadOnly Class Referenceabstract

Buffer that can be read and not written. More...

#include <StormByte/buffer/generic.hxx>

Inheritance diagram for StormByte::Buffer::ReadOnly:
Collaboration diagram for StormByte::Buffer::ReadOnly:

Public Member Functions

Lifecycle
 ReadOnly () noexcept
 Default constructor.
 ReadOnly (const ReadOnly &other) noexcept
 Copy constructor.
 ReadOnly (ReadOnly &&other) noexcept
 Move constructor.
virtual ~ReadOnly () noexcept
 Destructor.
ReadOnly & operator= (const ReadOnly &other) noexcept
 Copy assignment.
ReadOnly & operator= (ReadOnly &&other) noexcept
 Move assignment.
Queries
virtual StormByte::ByteSize Available () const noexcept=0
 Bytes available from the current read position.
virtual const Safe::Binary & Data () const noexcept=0
 View of internal storage.
virtual bool Empty () const noexcept=0
 Whether the store holds no bytes.
virtual bool EoF () const noexcept=0
 End of stream.
virtual bool IsReadable () const noexcept=0
 Whether the buffer can still be read.
Maintenance
virtual void Clean () noexcept=0
 Drop bytes from the start up to the current read position.
virtual void Clear () noexcept=0
 Clear stored bytes and reset logical positions.
virtual bool Drop (const StormByte::ByteSize &count) noexcept=0
 Discard count unread bytes.
virtual void Seek (const std::ptrdiff_t &offset, const Position &mode) const noexcept=0
 Move the logical read position.
Extract
virtual bool Extract (const StormByte::ByteSize &count, StormByte::Safe::Binary &outBuffer) noexcept=0
 Extract bytes into a StormByte::Safe::Binary.
bool Extract (StormByte::Safe::Binary &outBuffer) noexcept
 Extract all available bytes into a StormByte::Safe::Binary.
virtual bool Extract (const StormByte::ByteSize &count, WriteOnly &outBuffer) noexcept=0
 Extract bytes into a WriteOnly.
bool Extract (WriteOnly &outBuffer) noexcept
 Extract all available bytes into a WriteOnly.
virtual void ExtractUntilEoF (StormByte::Safe::Binary &outBuffer) noexcept=0
 Extract until EoF into a StormByte::Safe::Binary.
virtual void ExtractUntilEoF (WriteOnly &outBuffer) noexcept=0
 Extract until EoF into a WriteOnly.
Peek
virtual bool Peek (const StormByte::ByteSize &count, StormByte::Safe::Binary &outBuffer) const noexcept=0
 Peek into a StormByte::Safe::Binary.
virtual bool Peek (const StormByte::ByteSize &count, WriteOnly &outBuffer) const noexcept=0
 Peek into a WriteOnly.
Read
virtual bool Read (const StormByte::ByteSize &count, StormByte::Safe::Binary &outBuffer) const noexcept=0
 Read into a StormByte::Safe::Binary.
bool Read (StormByte::Safe::Binary &outBuffer) const noexcept
 Read all available bytes into a StormByte::Safe::Binary.
virtual bool Read (const StormByte::ByteSize &count, WriteOnly &outBuffer) const noexcept=0
 Read into a WriteOnly.
bool Read (WriteOnly &outBuffer) const noexcept
 Read all available bytes into a WriteOnly.
virtual void ReadUntilEoF (StormByte::Safe::Binary &outBuffer) const noexcept=0
 Read until EoF into a StormByte::Safe::Binary.
virtual void ReadUntilEoF (WriteOnly &outBuffer) const noexcept=0
 Read until EoF into a WriteOnly.
Public Member Functions inherited from StormByte::Buffer::Generic
 Generic () noexcept
 Default constructor.
 Generic (const Generic &other) noexcept
 Copy constructor.
 Generic (Generic &&other) noexcept
 Move constructor.
virtual ~Generic () noexcept=0
 Pure virtual destructor.
Generic & operator= (const Generic &other) noexcept
 Copy assignment.
Generic & operator= (Generic &&other) noexcept
 Move assignment.
virtual StormByte::ByteSize Size () const noexcept=0
 Total number of bytes stored.

Additional Inherited Members

Static Protected Member Functions inherited from StormByte::Buffer::Generic
template<Type::ByteInputRange Src>
static STORMBYTE_FORCE_INLINE Safe::Binary DataConvert (const Src &src) noexcept
 Convert an lvalue input range to StormByte::Safe::Binary.
template<Type::ByteInputRange Src>
static STORMBYTE_FORCE_INLINE Safe::Binary DataConvert (Src &&src) noexcept
 Convert an rvalue input range to StormByte::Safe::Binary.
static Safe::Binary DataConvert (std::string_view sv) noexcept
 Convert a string view to StormByte::Safe::Binary.
static Safe::Binary DataConvert (const char *s) noexcept
 Convert a C string to StormByte::Safe::Binary.

Detailed Description

Buffer that can be read and not written.

Read, extract, peek and seek. Occupancy is Generic::Size.

See also
WriteOnly, ReadWrite, Generic

Constructor & Destructor Documentation

◆ ReadOnly() [1/3]

StormByte::Buffer::ReadOnly::ReadOnly ( )
noexcept

Default constructor.

◆ ReadOnly() [2/3]

StormByte::Buffer::ReadOnly::ReadOnly ( const ReadOnly & other)
noexcept

Copy constructor.

Parameters
otherInstance to copy.

◆ ReadOnly() [3/3]

StormByte::Buffer::ReadOnly::ReadOnly ( ReadOnly && other)
noexcept

Move constructor.

Parameters
otherInstance to take from.

◆ ~ReadOnly()

virtual StormByte::Buffer::ReadOnly::~ReadOnly ( )
virtualnoexcept

Destructor.

Member Function Documentation

◆ Available()

virtual StormByte::ByteSize StormByte::Buffer::ReadOnly::Available ( ) const
pure virtualnoexcept

Bytes available from the current read position.

Returns
Unread byte count.

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, StormByte::Buffer::Ring, and StormByte::Buffer::SharedFIFO.

◆ Clean()

virtual void StormByte::Buffer::ReadOnly::Clean ( )
pure virtualnoexcept

Drop bytes from the start up to the current read position.

See also
Size(), Empty()

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, StormByte::Buffer::Ring, and StormByte::Buffer::SharedFIFO.

◆ Clear()

virtual void StormByte::Buffer::ReadOnly::Clear ( )
pure virtualnoexcept

Clear stored bytes and reset logical positions.

Closed and error flags are implementation-defined.

See also
Size(), Empty()

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, StormByte::Buffer::Ring, and StormByte::Buffer::SharedFIFO.

◆ Data()

virtual const Safe::Binary & StormByte::Buffer::ReadOnly::Data ( ) const
pure virtualnoexcept

View of internal storage.

Implementation-defined.

Returns
Constant reference to a StormByte::Safe::Binary.

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, StormByte::Buffer::Ring, and StormByte::Buffer::SharedFIFO.

◆ Drop()

virtual bool StormByte::Buffer::ReadOnly::Drop ( const StormByte::ByteSize & count)
pure virtualnoexcept

Discard count unread bytes.

Parameters
countBytes to drop.
Returns
false if fewer bytes were available.
See also
Read()

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, StormByte::Buffer::Ring, and StormByte::Buffer::SharedFIFO.

◆ Empty()

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

Whether the store holds no bytes.

Returns
true if empty.
See also
Size()

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, StormByte::Buffer::Ring, and StormByte::Buffer::SharedFIFO.

◆ EoF()

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

End of stream.

Returns
true when closed or failed and nothing remains to read.

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, StormByte::Buffer::Ring, and StormByte::Buffer::SharedFIFO.

◆ Extract() [1/4]

virtual bool StormByte::Buffer::ReadOnly::Extract ( const StormByte::ByteSize & count,
StormByte::Safe::Binary & outBuffer )
inlinepure virtualnoexcept

Extract bytes into a StormByte::Safe::Binary.

Parameters
countBytes to extract. 0 = all available.
outBufferDestination.
Returns
false on failure.

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, and StormByte::Buffer::Ring.

◆ Extract() [2/4]

virtual bool StormByte::Buffer::ReadOnly::Extract ( const StormByte::ByteSize & count,
WriteOnly & outBuffer )
inlinepure virtualnoexcept

Extract bytes into a WriteOnly.

Parameters
countBytes to extract. 0 = all available.
outBufferDestination writer.
Returns
false on failure.

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, and StormByte::Buffer::Ring.

◆ Extract() [3/4]

bool StormByte::Buffer::ReadOnly::Extract ( StormByte::Safe::Binary & outBuffer)
inlinenoexcept

Extract all available bytes into a StormByte::Safe::Binary.

Parameters
outBufferDestination.
Returns
false on failure.

◆ Extract() [4/4]

bool StormByte::Buffer::ReadOnly::Extract ( WriteOnly & outBuffer)
inlinenoexcept

Extract all available bytes into a WriteOnly.

Parameters
outBufferDestination writer.
Returns
false on failure.

◆ ExtractUntilEoF() [1/2]

virtual void StormByte::Buffer::ReadOnly::ExtractUntilEoF ( StormByte::Safe::Binary & outBuffer)
pure virtualnoexcept

Extract until EoF into a StormByte::Safe::Binary.

Parameters
outBufferDestination.
Warning
Can grow without bound.

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, and StormByte::Buffer::Ring.

◆ ExtractUntilEoF() [2/2]

virtual void StormByte::Buffer::ReadOnly::ExtractUntilEoF ( WriteOnly & outBuffer)
pure virtualnoexcept

Extract until EoF into a WriteOnly.

Parameters
outBufferDestination writer.
Warning
Can grow without bound.

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, and StormByte::Buffer::Ring.

◆ IsReadable()

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

Whether the buffer can still be read.

Returns
false in a permanent error state.

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, StormByte::Buffer::Ring, and StormByte::Buffer::SharedFIFO.

◆ operator=() [1/2]

ReadOnly & StormByte::Buffer::ReadOnly::operator= ( const ReadOnly & other)
noexcept

Copy assignment.

Parameters
otherInstance to copy.
Returns
*this.

◆ operator=() [2/2]

ReadOnly & StormByte::Buffer::ReadOnly::operator= ( ReadOnly && other)
noexcept

Move assignment.

Parameters
otherInstance to take from.
Returns
*this.

◆ Peek() [1/2]

virtual bool StormByte::Buffer::ReadOnly::Peek ( const StormByte::ByteSize & count,
StormByte::Safe::Binary & outBuffer ) const
pure virtualnoexcept

Peek into a StormByte::Safe::Binary.

Does not advance the cursor.

Parameters
countBytes to peek. 0 = all available (fails if none). Greater than 0: exactly that many bytes, or fail.
outBufferDestination.
Returns
false if insufficient data or error.
See also
Read(), Seek()

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, and StormByte::Buffer::Ring.

◆ Peek() [2/2]

virtual bool StormByte::Buffer::ReadOnly::Peek ( const StormByte::ByteSize & count,
WriteOnly & outBuffer ) const
pure virtualnoexcept

Peek into a WriteOnly.

Does not advance the cursor.

Parameters
countSame semantics as the StormByte::Safe::Binary overload.
outBufferDestination writer.
Returns
false if insufficient data or error.
See also
Read(), Seek()

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, and StormByte::Buffer::Ring.

◆ Read() [1/4]

virtual bool StormByte::Buffer::ReadOnly::Read ( const StormByte::ByteSize & count,
StormByte::Safe::Binary & outBuffer ) const
pure virtualnoexcept

Read into a StormByte::Safe::Binary.

Advances the cursor.

Parameters
countBytes to read. 0 = all available.
outBufferDestination.
Returns
false on failure.

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, and StormByte::Buffer::Ring.

◆ Read() [2/4]

virtual bool StormByte::Buffer::ReadOnly::Read ( const StormByte::ByteSize & count,
WriteOnly & outBuffer ) const
pure virtualnoexcept

Read into a WriteOnly.

Advances the cursor.

Parameters
countBytes to read. 0 = all available.
outBufferDestination writer.
Returns
false on failure.

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, and StormByte::Buffer::Ring.

◆ Read() [3/4]

bool StormByte::Buffer::ReadOnly::Read ( StormByte::Safe::Binary & outBuffer) const
inlinenoexcept

Read all available bytes into a StormByte::Safe::Binary.

Parameters
outBufferDestination.
Returns
false on failure.

◆ Read() [4/4]

bool StormByte::Buffer::ReadOnly::Read ( WriteOnly & outBuffer) const
inlinenoexcept

Read all available bytes into a WriteOnly.

Parameters
outBufferDestination writer.
Returns
false on failure.

◆ ReadUntilEoF() [1/2]

virtual void StormByte::Buffer::ReadOnly::ReadUntilEoF ( StormByte::Safe::Binary & outBuffer) const
pure virtualnoexcept

Read until EoF into a StormByte::Safe::Binary.

Parameters
outBufferDestination.
Warning
Can grow without bound.

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, and StormByte::Buffer::Ring.

◆ ReadUntilEoF() [2/2]

virtual void StormByte::Buffer::ReadOnly::ReadUntilEoF ( WriteOnly & outBuffer) const
pure virtualnoexcept

Read until EoF into a WriteOnly.

Parameters
outBufferDestination writer.
Warning
Can grow without bound.

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, and StormByte::Buffer::Ring.

◆ Seek()

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

Move the logical read position.

Parameters
offsetOffset.
modePosition::Absolute or Position::Relative.

Clamped to [0, Size()]. Absolute + negative offset is a no-op.

See also
Read(), Position

Implemented in StormByte::Buffer::Consumer, StormByte::Buffer::FIFO, StormByte::Buffer::Ring, and StormByte::Buffer::SharedFIFO.


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