StormByte-Buffer 2.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=default
 Copy constructor.
 
 ReadOnly (ReadOnly &&other) noexcept=default
 Move constructor.
 
virtual ~ReadOnly () noexcept
 Destructor.
 
ReadOnly & operator= (const ReadOnly &other)=default
 Copy assignment.
 
ReadOnly & operator= (ReadOnly &&other) noexcept=default
 Move assignment.
 
Queries
virtual StormByte::ByteSize Available () const noexcept=0
 Bytes available from the current read position.
 
virtual const BinaryData & 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::BinaryData &outBuffer) noexcept=0
 Extract bytes into a StormByte::BinaryData.
 
bool Extract (StormByte::BinaryData &outBuffer) noexcept
 Extract all available bytes into a StormByte::BinaryData.
 
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::BinaryData &outBuffer) noexcept=0
 Extract until EoF into a StormByte::BinaryData.
 
virtual void ExtractUntilEoF (WriteOnly &outBuffer) noexcept=0
 Extract until EoF into a WriteOnly.
 
Peek
virtual bool Peek (const StormByte::ByteSize &count, StormByte::BinaryData &outBuffer) const noexcept=0
 Peek into a StormByte::BinaryData.
 
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::BinaryData &outBuffer) const noexcept=0
 Read into a StormByte::BinaryData.
 
bool Read (StormByte::BinaryData &outBuffer) const noexcept
 Read all available bytes into a StormByte::BinaryData.
 
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::BinaryData &outBuffer) const noexcept=0
 Read until EoF into a StormByte::BinaryData.
 
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
 Default constructor.
 
 Generic (const Generic &other) noexcept=default
 Copy constructor.
 
 Generic (Generic &&other) noexcept=default
 Move constructor.
 
virtual ~Generic () noexcept=0
 Pure virtual destructor.
 
Generic & operator= (const Generic &other)=default
 Copy assignment.
 
Generic & operator= (Generic &&other) noexcept=default
 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 BinaryData DataConvert (const Src &src) noexcept
 Convert an lvalue input range to StormByte::BinaryData.
 
template<Type::ByteInputRange Src>
static BinaryData DataConvert (Src &&src) noexcept
 Convert an rvalue input range to StormByte::BinaryData.
 
static BinaryData DataConvert (std::string_view sv) noexcept
 Convert a string view to StormByte::BinaryData.
 
static BinaryData DataConvert (const char *s) noexcept
 Convert a C string to StormByte::BinaryData.
 

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 ( )
inlinenoexcept

Default constructor.

◆ ReadOnly() [2/3]

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

Copy constructor.

Parameters
otherInstance to copy.

◆ ReadOnly() [3/3]

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

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 BinaryData & StormByte::Buffer::ReadOnly::Data ( ) const
pure virtualnoexcept

View of internal storage.

Implementation-defined.

Returns
Constant reference to a StormByte::BinaryData.

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::BinaryData &  outBuffer 
)
inlinepure virtualnoexcept

Extract bytes into a StormByte::BinaryData.

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

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

◆ 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, StormByte::Buffer::Ring, and StormByte::Buffer::FIFO.

◆ Extract() [3/4]

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

Extract all available bytes into a StormByte::BinaryData.

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::BinaryData &  outBuffer)
pure virtualnoexcept

Extract until EoF into a StormByte::BinaryData.

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)
default

Copy assignment.

Parameters
otherInstance to copy.
Returns
*this.

◆ operator=() [2/2]

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

Move assignment.

Parameters
otherInstance to take from.
Returns
*this.

◆ Peek() [1/2]

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

Peek into a StormByte::BinaryData.

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::BinaryData 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::BinaryData &  outBuffer 
) const
pure virtualnoexcept

Read into a StormByte::BinaryData.

Advances the cursor.

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

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

◆ 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, StormByte::Buffer::Ring, and StormByte::Buffer::FIFO.

◆ Read() [3/4]

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

Read all available bytes into a StormByte::BinaryData.

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::BinaryData &  outBuffer) const
pure virtualnoexcept

Read until EoF into a StormByte::BinaryData.

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: