StormByte-Buffer 2.0.0
C++26 buffer module of the StormByte suite
 
Loading...
Searching...
No Matches
StormByte::Buffer::FIFO Class Reference

Byte-oriented FIFO buffer with grow-on-demand and close/error support. More...

#include <StormByte/buffer/fifo.hxx>

Inheritance diagram for StormByte::Buffer::FIFO:
Collaboration diagram for StormByte::Buffer::FIFO:

Public Member Functions

Constructors / destructor / assignment
 FIFO () noexcept=default
 Default construct an empty FIFO.
 
 FIFO (const StormByte::BinaryData &data) noexcept
 Construct FIFO with initial data (copy).
 
 FIFO (StormByte::BinaryData &&data) noexcept
 Construct FIFO with initial data (move).
 
template<Type::ByteInputRange R>
requires (!Type::SameAs<R, StormByte::BinaryData>)
 FIFO (const R &r) noexcept
 Construct FIFO from an input range (copy / convert).
 
template<Type::ByteInputRange Rr>
 FIFO (Rr &&r) noexcept
 Construct FIFO from an rvalue range (moves when StormByte::BinaryData).
 
 FIFO (std::string_view sv) noexcept
 Construct FIFO from a string view (no trailing NUL).
 
 FIFO (const char *s) noexcept
 Construct FIFO from a null-terminated C string.
 
 FIFO (const FIFO &other) noexcept
 Copy construct, preserving buffer contents and state.
 
 FIFO (FIFO &&other) noexcept
 Move construct.
 
virtual ~FIFO () noexcept
 Virtual destructor.
 
FIFO & operator= (const FIFO &other)
 Copy assign, preserving buffer contents and state.
 
FIFO & operator= (FIFO &&other) noexcept
 Move assign.
 
Comparison
bool operator== (const FIFO &other) const noexcept
 Equality comparison.
 
bool operator!= (const FIFO &other) const noexcept
 Inequality comparison.
 
Queries
virtual StormByte::ByteSize Available () const noexcept override
 Bytes available from the current read position.
 
virtual const StormByte::BinaryData & Data () const noexcept override
 Access the internal storage.
 
virtual bool Empty () const noexcept override
 Whether the underlying storage is empty.
 
virtual bool EoF () const noexcept override
 End-of-stream condition.
 
virtual bool IsReadable () const noexcept override
 Whether the buffer can be read.
 
virtual bool IsWritable () const noexcept override
 Whether the buffer accepts writes.
 
virtual StormByte::ByteSize Size () const noexcept override
 Total number of bytes stored (including already-read prefix).
 
Maintenance / lifecycle
virtual void Clean () noexcept override
 Discard data from the start up to the current read position.
 
virtual void Clear () noexcept override
 Clear all buffer contents and reset the read position.
 
void Close () noexcept override
 Mark the buffer closed for further writes.
 
virtual bool Drop (const StormByte::ByteSize &count) noexcept override
 Discard count unread bytes and advance the read position.
 
virtual void Seek (const std::ptrdiff_t &offset, const Position &mode) const noexcept override
 Move the logical read position for non-destructive reads.
 
void SetError () noexcept override
 Enter permanent error state (unreadable and unwritable).
 
Extract (destructive)
bool Extract (const StormByte::ByteSize &count, StormByte::BinaryData &outBuffer) noexcept override
 Extract bytes into a StormByte::BinaryData.
 
bool Extract (const StormByte::ByteSize &count, WriteOnly &outBuffer) noexcept override
 Extract bytes into a WriteOnly.
 
void ExtractUntilEoF (StormByte::BinaryData &outBuffer) noexcept override
 Extract all remaining bytes until EoF into a StormByte::BinaryData.
 
void ExtractUntilEoF (WriteOnly &outBuffer) noexcept override
 Extract all remaining bytes until EoF into a WriteOnly.
 
virtual bool Extract (const StormByte::ByteSize &count, StormByte::BinaryData &outBuffer) noexcept=0
 Bring ReadOnly convenience Extract overloads into scope.
 
bool Extract (StormByte::BinaryData &outBuffer) noexcept
 Bring ReadOnly convenience Extract overloads into scope.
 
virtual bool Extract (const StormByte::ByteSize &count, WriteOnly &outBuffer) noexcept=0
 Bring ReadOnly convenience Extract overloads into scope.
 
bool Extract (WriteOnly &outBuffer) noexcept
 Bring ReadOnly convenience Extract overloads into scope.
 
Read (non-destructive)
bool Read (const StormByte::ByteSize &count, StormByte::BinaryData &outBuffer) const noexcept override
 Non-destructive read into a StormByte::BinaryData (advances position).
 
bool Read (const StormByte::ByteSize &count, WriteOnly &outBuffer) const noexcept override
 Non-destructive read into a WriteOnly (advances position).
 
void ReadUntilEoF (StormByte::BinaryData &outBuffer) const noexcept override
 Read all remaining bytes until EoF into a StormByte::BinaryData.
 
void ReadUntilEoF (WriteOnly &outBuffer) const noexcept override
 Read all remaining bytes until EoF into a WriteOnly.
 
virtual bool Read (const StormByte::ByteSize &count, StormByte::BinaryData &outBuffer) const noexcept=0
 Bring ReadOnly convenience Read overloads into scope.
 
bool Read (StormByte::BinaryData &outBuffer) const noexcept
 Bring ReadOnly convenience Read overloads into scope.
 
virtual bool Read (const StormByte::ByteSize &count, WriteOnly &outBuffer) const noexcept=0
 Bring ReadOnly convenience Read overloads into scope.
 
bool Read (WriteOnly &outBuffer) const noexcept
 Bring ReadOnly convenience Read overloads into scope.
 
Peek (non-destructive, does not advance)
bool Peek (const StormByte::ByteSize &count, StormByte::BinaryData &outBuffer) const noexcept override
 Peek into a StormByte::BinaryData without advancing the read position.
 
bool Peek (const StormByte::ByteSize &count, WriteOnly &outBuffer) const noexcept override
 Peek into a WriteOnly without advancing the read position.
 
Diagnostics
virtual StormByte::String::String HexDump (const StormByte::ByteSize &columns=16, const StormByte::ByteSize &byte_limit=0) const noexcept
 Hexdump of unread contents from the current read position.
 
Write
bool Write (const StormByte::ByteSize &count, const StormByte::BinaryData &data) noexcept override
 Append bytes from a StormByte::BinaryData (copy).
 
bool Write (const StormByte::ByteSize &count, StormByte::BinaryData &&data) noexcept override
 Append bytes from a StormByte::BinaryData (move).
 
bool Write (const StormByte::ByteSize &count, const ReadOnly &data) noexcept override
 Append bytes from a ReadOnly source (copy).
 
bool Write (const StormByte::ByteSize &count, ReadOnly &&data) noexcept override
 Append bytes from a ReadOnly source (move / extract path).
 
virtual bool Write (const StormByte::ByteSize &count, const BinaryData &data) noexcept=0
 Bring WriteOnly convenience Write overloads into scope.
 
virtual bool Write (const StormByte::ByteSize &count, BinaryData &&data) noexcept=0
 Bring WriteOnly convenience Write overloads into scope.
 
virtual bool Write (const StormByte::ByteSize &count, const ReadOnly &data) noexcept=0
 Bring WriteOnly convenience Write overloads into scope.
 
virtual bool Write (const StormByte::ByteSize &count, ReadOnly &&data) noexcept=0
 Bring WriteOnly convenience Write overloads into scope.
 
bool Write (const ReadOnly &data) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
bool Write (ReadOnly &&data) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
bool Write (std::string_view sv) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
bool Write (const char *s) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
bool Write (const StormByte::ByteSize &count, std::string_view sv) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
bool Write (const StormByte::ByteSize &count, const char *s) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
template<std::size_t N>
bool Write (const char(&s)[N]) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
template<Type::ByteInputRange R>
bool Write (const R &r) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
template<Type::ByteInputRange Rw>
bool Write (const StormByte::ByteSize &count, const Rw &r) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
template<Type::ByteInputRange Rrw>
bool Write (const StormByte::ByteSize &count, Rrw &&r) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
template<Type::ByteInputRange Rr>
bool Write (Rr &&r) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
template<Type::ByteInputIterator I, typename S >
requires Type::SentinelFor<S, I>
bool Write (I first, S last) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
template<Type::ByteInputIterator I2, typename S2 >
requires Type::SentinelFor<S2, I2>
bool Write (const StormByte::ByteSize &count, I2 first, S2 last) noexcept
 Bring WriteOnly convenience Write overloads into scope.
 
- Public Member Functions inherited from StormByte::Buffer::ReadWrite
 ReadWrite () noexcept
 Default constructor.
 
 ReadWrite (const ReadWrite &other) noexcept=default
 Copy constructor.
 
 ReadWrite (ReadWrite &&other) noexcept=default
 Move constructor.
 
virtual ~ReadWrite () noexcept
 Destructor.
 
ReadWrite & operator= (const ReadWrite &other)=default
 Copy assignment.
 
ReadWrite & operator= (ReadWrite &&other) noexcept=default
 Move assignment.
 
- Public Member Functions inherited from StormByte::Buffer::ReadOnly
 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.
 
bool Extract (StormByte::BinaryData &outBuffer) noexcept
 Extract all available bytes into a StormByte::BinaryData.
 
bool Extract (WriteOnly &outBuffer) noexcept
 Extract all available bytes into a WriteOnly.
 
bool Read (StormByte::BinaryData &outBuffer) const noexcept
 Read all available bytes into a StormByte::BinaryData.
 
bool Read (WriteOnly &outBuffer) const noexcept
 Read all available bytes 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.
 
- Public Member Functions inherited from StormByte::Buffer::WriteOnly
 WriteOnly () noexcept
 Default constructor.
 
 WriteOnly (const WriteOnly &other)=default
 Copy constructor.
 
 WriteOnly (WriteOnly &&other) noexcept=default
 Move constructor.
 
virtual ~WriteOnly () noexcept
 Destructor.
 
WriteOnly & operator= (const WriteOnly &other)=default
 Copy assignment.
 
WriteOnly & operator= (WriteOnly &&other) noexcept=default
 Move assignment.
 
bool Write (const ReadOnly &data) noexcept
 Append all available bytes from a ReadOnly (copy).
 
bool Write (ReadOnly &&data) noexcept
 Append all available bytes from a ReadOnly (extract).
 
bool Write (std::string_view sv) noexcept
 Write a string view.
 
bool Write (const char *s) noexcept
 Write a C string.
 
bool Write (const StormByte::ByteSize &count, std::string_view sv) noexcept
 Write up to count characters of a string view.
 
bool Write (const StormByte::ByteSize &count, const char *s) noexcept
 Write up to count characters of a C string.
 
template<std::size_t N>
bool Write (const char(&s)[N]) noexcept
 Write a string literal without the trailing NUL.
 
template<Type::ByteInputRange R>
bool Write (const R &r) noexcept
 Write all elements from an input range.
 
template<Type::ByteInputRange Rw>
bool Write (const StormByte::ByteSize &count, const Rw &r) noexcept
 Write up to count elements from an input range.
 
template<Type::ByteInputRange Rrw>
bool Write (const StormByte::ByteSize &count, Rrw &&r) noexcept
 Write up to count elements from an rvalue range.
 
template<Type::ByteInputRange Rr>
bool Write (Rr &&r) noexcept
 Write all elements from an rvalue range.
 
template<Type::ByteInputIterator I, typename S >
requires Type::SentinelFor<S, I>
bool Write (I first, S last) noexcept
 Write all elements from an iterator pair.
 
template<Type::ByteInputIterator I2, typename S2 >
requires Type::SentinelFor<S2, I2>
bool Write (const StormByte::ByteSize &count, I2 first, S2 last) noexcept
 Write up to count elements from an iterator pair.
 

Protected Types

enum class  Operation { Extract , Read , Peek }
 Kind of internal read operation. More...
 

Protected Member Functions

StormByte::ByteSize AvailableInternal () const noexcept
 Return unread bytes without virtual dispatch.
 
virtual std::ostringstream HexDumpHeader () const noexcept
 Build the hexdump header (size / position / status).
 
Internal read / write helpers
virtual bool ReadInternal (const StormByte::ByteSize &count, StormByte::BinaryData &outBuffer, const Operation &flag) noexcept
 Shared implementation for Extract / Read / Peek into StormByte::BinaryData.
 
virtual bool ReadInternal (const StormByte::ByteSize &count, WriteOnly &outBuffer, const Operation &flag) noexcept
 Shared implementation for Extract / Read / Peek into WriteOnly.
 
virtual void ReadUntilEoFInternal (StormByte::BinaryData &outBuffer, const Operation &flag) noexcept
 Drain until EoF into StormByte::BinaryData using flag semantics.
 
virtual void ReadUntilEoFInternal (WriteOnly &outBuffer, const Operation &flag) noexcept
 Drain until EoF into WriteOnly using flag semantics.
 
virtual bool WriteInternal (const StormByte::ByteSize &count, const StormByte::BinaryData &src) noexcept
 Append from StormByte::BinaryData (copy).
 
virtual bool WriteInternal (const StormByte::ByteSize &count, StormByte::BinaryData &&src) noexcept
 Append from StormByte::BinaryData (move).
 
virtual bool WriteInternal (const StormByte::ByteSize &count, const ReadOnly &src) noexcept
 Append from ReadOnly (copy path).
 
virtual bool WriteInternal (const StormByte::ByteSize &count, ReadOnly &&src) noexcept
 Append from ReadOnly (move / extract path).
 

Static Protected Member Functions

static StormByte::String::String FormatHexLines (std::span< const std::byte > &data, StormByte::ByteSize start_offset, StormByte::ByteSize columns) noexcept
 Format hex/ASCII lines for a data span.
 
- 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.
 

Protected Attributes

StormByte::BinaryData m_buffer
 Owned contiguous byte storage.
 
StormByte::ByteSize m_position_offset {0}
 Logical read offset from start of m_buffer.
 
bool m_closed {false}
 Once true, further writes fail.
 
bool m_error {false}
 Permanent error: unreadable and unwritable.
 

Detailed Description

Byte-oriented FIFO buffer with grow-on-demand and close/error support.

Overview
A contiguous growable buffer implemented atop StormByte::BinaryData that tracks a logical read position. It grows automatically to fit writes and supports efficient non-destructive reads and destructive extracts.
Thread safety
This class is not thread-safe. For concurrent access use SharedFIFO or Ring.
Buffer behaviour
Supports clear / clean, a movable read position for non-destructive reads, and a closed / error state to signal end-of-writes or permanent failure. Once closed, further writes fail; readers can still drain remaining data until EoF().
See also
SharedFIFO, Ring, ReadWrite, Producer, Consumer

Member Enumeration Documentation

◆ Operation

enum class StormByte::Buffer::FIFO::Operation
strongprotected

Kind of internal read operation.

Enumerator
Extract 

Destructive read.

Read 

Non-destructive read (advances position)

Peek 

Non-destructive peek (no advance)

Constructor & Destructor Documentation

◆ FIFO() [1/9]

StormByte::Buffer::FIFO::FIFO ( )
defaultnoexcept

Default construct an empty FIFO.

◆ FIFO() [2/9]

StormByte::Buffer::FIFO::FIFO ( const StormByte::BinaryData &  data)
inlinenoexcept

Construct FIFO with initial data (copy).

Parameters
dataInitial StormByte::BinaryData.

◆ FIFO() [3/9]

StormByte::Buffer::FIFO::FIFO ( StormByte::BinaryData &&  data)
inlinenoexcept

Construct FIFO with initial data (move).

Parameters
dataInitial StormByte::BinaryData (moved into the FIFO).

◆ FIFO() [4/9]

template<Type::ByteInputRange R>
requires (!Type::SameAs<R, StormByte::BinaryData>)
StormByte::Buffer::FIFO::FIFO ( const R &  r)
inlinenoexcept

Construct FIFO from an input range (copy / convert).

Template Parameters
RInput range whose elements are convertible to std::byte.
Parameters
rRange to copy from.
Note
Disabled when R is already StormByte::BinaryData to avoid overload ambiguity.

◆ FIFO() [5/9]

template<Type::ByteInputRange Rr>
StormByte::Buffer::FIFO::FIFO ( Rr &&  r)
inlinenoexcept

Construct FIFO from an rvalue range (moves when StormByte::BinaryData).

Template Parameters
RrInput range type.
Parameters
rRange to consume.

◆ FIFO() [6/9]

StormByte::Buffer::FIFO::FIFO ( std::string_view  sv)
inlinenoexcept

Construct FIFO from a string view (no trailing NUL).

Parameters
svSource characters.

◆ FIFO() [7/9]

StormByte::Buffer::FIFO::FIFO ( const char *  s)
inlinenoexcept

Construct FIFO from a null-terminated C string.

Parameters
sSource string (may be null → empty buffer).

◆ FIFO() [8/9]

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

Copy construct, preserving buffer contents and state.

Parameters
otherSource FIFO.

◆ FIFO() [9/9]

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

Move construct.

Parameters
otherSource FIFO (left empty / unspecified but valid).

◆ ~FIFO()

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

Virtual destructor.

Member Function Documentation

◆ Available()

virtual StormByte::ByteSize StormByte::Buffer::FIFO::Available ( ) const
overridevirtualnoexcept

Bytes available from the current read position.

Returns
Unread byte count.
See also
Size(), Read(), Extract(), Seek()

Implements StormByte::Buffer::ReadOnly.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ AvailableInternal()

StormByte::ByteSize StormByte::Buffer::FIFO::AvailableInternal ( ) const
protectednoexcept

Return unread bytes without virtual dispatch.

Returns
Number of bytes from the current read position.
Note
Callers that synchronize derived state must hold their own lock.

◆ Clean()

virtual void StormByte::Buffer::FIFO::Clean ( )
overridevirtualnoexcept

Discard data from the start up to the current read position.

Implements StormByte::Buffer::ReadOnly.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ Clear()

virtual void StormByte::Buffer::FIFO::Clear ( )
overridevirtualnoexcept

Clear all buffer contents and reset the read position.

Does not clear the closed / error flags.

See also
Size(), Empty()

Implements StormByte::Buffer::ReadOnly.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ Close()

void StormByte::Buffer::FIFO::Close ( )
overridevirtualnoexcept

Mark the buffer closed for further writes.

Subsequent Write() calls fail. Readers may still drain remaining data until Available() is zero.

Implements StormByte::Buffer::WriteOnly.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ Data()

virtual const StormByte::BinaryData & StormByte::Buffer::FIFO::Data ( ) const
overridevirtualnoexcept

Access the internal storage.

Returns
Constant reference to the owned StormByte::BinaryData.

Implements StormByte::Buffer::ReadOnly.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ Drop()

virtual bool StormByte::Buffer::FIFO::Drop ( const StormByte::ByteSize &  count)
overridevirtualnoexcept

Discard count unread bytes and advance the read position.

Parameters
countNumber of bytes to drop.
Returns
true on success, false if fewer bytes were available.
See also
Read(), Seek()

Implements StormByte::Buffer::ReadOnly.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ Empty()

virtual bool StormByte::Buffer::FIFO::Empty ( ) const
overridevirtualnoexcept

Whether the underlying storage is empty.

Returns
true if m_buffer is empty.
Note
With a non-zero read position, Empty() may be false while Available() is zero.
See also
Size(), Available()

Implements StormByte::Buffer::ReadOnly.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ EoF()

virtual bool StormByte::Buffer::FIFO::EoF ( ) const
overridevirtualnoexcept

End-of-stream condition.

Returns
true if in error, or closed with no remaining unread bytes.

Implements StormByte::Buffer::ReadOnly.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ Extract() [1/6]

bool StormByte::Buffer::FIFO::Extract ( const StormByte::ByteSize &  count,
StormByte::BinaryData &  outBuffer 
)
overridevirtualnoexcept

Extract bytes into a StormByte::BinaryData.

Parameters
countBytes to extract; 0 = all available.
outBufferDestination (filled / resized as needed).
Returns
true on success, false on failure.

Implements StormByte::Buffer::ReadOnly.

◆ Extract() [2/6]

virtual bool StormByte::Buffer::ReadOnly::Extract ( const StormByte::ByteSize &  count,
StormByte::BinaryData &  outBuffer 
)
inlinevirtualnoexcept

Bring ReadOnly convenience Extract overloads into scope.

Implements StormByte::Buffer::ReadOnly.

◆ Extract() [3/6]

bool StormByte::Buffer::FIFO::Extract ( const StormByte::ByteSize &  count,
WriteOnly &  outBuffer 
)
overridevirtualnoexcept

Extract bytes into a WriteOnly.

Parameters
countBytes to extract; 0 = all available.
outBufferDestination writer.
Returns
true on success, false on failure.

Implements StormByte::Buffer::ReadOnly.

◆ Extract() [4/6]

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

Bring ReadOnly convenience Extract overloads into scope.

Implements StormByte::Buffer::ReadOnly.

◆ Extract() [5/6]

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

Bring ReadOnly convenience Extract overloads into scope.

◆ Extract() [6/6]

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

Bring ReadOnly convenience Extract overloads into scope.

◆ ExtractUntilEoF() [1/2]

void StormByte::Buffer::FIFO::ExtractUntilEoF ( StormByte::BinaryData &  outBuffer)
overridevirtualnoexcept

Extract all remaining bytes until EoF into a StormByte::BinaryData.

Parameters
outBufferDestination buffer.

Implements StormByte::Buffer::ReadOnly.

◆ ExtractUntilEoF() [2/2]

void StormByte::Buffer::FIFO::ExtractUntilEoF ( WriteOnly &  outBuffer)
overridevirtualnoexcept

Extract all remaining bytes until EoF into a WriteOnly.

Parameters
outBufferDestination writer.

Implements StormByte::Buffer::ReadOnly.

◆ FormatHexLines()

static StormByte::String::String StormByte::Buffer::FIFO::FormatHexLines ( std::span< const std::byte > &  data,
StormByte::ByteSize  start_offset,
StormByte::ByteSize  columns 
)
staticprotectednoexcept

Format hex/ASCII lines for a data span.

Parameters
dataBytes to dump.
start_offsetDisplay offset of the first byte.
columnsBytes per line.
Returns
Formatted lines (no header).

◆ HexDump()

virtual StormByte::String::String StormByte::Buffer::FIFO::HexDump ( const StormByte::ByteSize &  columns = 16,
const StormByte::ByteSize &  byte_limit = 0 
) const
virtualnoexcept

Hexdump of unread contents from the current read position.

Parameters
columnsBytes per line (0 → default 16).
byte_limitMax bytes to include (0 → no limit).
Returns
Formatted string: size / position / status, then hex/ASCII lines (no trailing newline).

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ HexDumpHeader()

virtual std::ostringstream StormByte::Buffer::FIFO::HexDumpHeader ( ) const
protectedvirtualnoexcept

Build the hexdump header (size / position / status).

Returns
Stream containing the header lines.

◆ IsReadable()

virtual bool StormByte::Buffer::FIFO::IsReadable ( ) const
overridevirtualnoexcept

Whether the buffer can be read.

Returns
false in permanent error state.

Implements StormByte::Buffer::ReadOnly.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ IsWritable()

virtual bool StormByte::Buffer::FIFO::IsWritable ( ) const
overridevirtualnoexcept

Whether the buffer accepts writes.

Returns
false if closed or in error.

Implements StormByte::Buffer::WriteOnly.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ operator!=()

bool StormByte::Buffer::FIFO::operator!= ( const FIFO &  other) const
inlinenoexcept

Inequality comparison.

Parameters
otherOther FIFO.
Returns
Negation of operator==.

◆ operator=() [1/2]

FIFO & StormByte::Buffer::FIFO::operator= ( const FIFO &  other)

Copy assign, preserving buffer contents and state.

Parameters
otherSource FIFO.
Returns
Reference to this FIFO.

◆ operator=() [2/2]

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

Move assign.

Parameters
otherSource FIFO.
Returns
Reference to this FIFO.

◆ operator==()

bool StormByte::Buffer::FIFO::operator== ( const FIFO &  other) const
inlinenoexcept

Equality comparison.

Parameters
otherOther FIFO.
Returns
true if buffer contents, read position and closed/error flags match.

◆ Peek() [1/2]

bool StormByte::Buffer::FIFO::Peek ( const StormByte::ByteSize &  count,
StormByte::BinaryData &  outBuffer 
) const
overridevirtualnoexcept

Peek into a StormByte::BinaryData without advancing the read position.

Parameters
countBytes to peek; 0 = all available.
outBufferDestination buffer.
Returns
true on success, false on failure.

Implements StormByte::Buffer::ReadOnly.

◆ Peek() [2/2]

bool StormByte::Buffer::FIFO::Peek ( const StormByte::ByteSize &  count,
WriteOnly &  outBuffer 
) const
overridevirtualnoexcept

Peek into a WriteOnly without advancing the read position.

Parameters
countBytes to peek; 0 = all available.
outBufferDestination writer.
Returns
true on success, false on failure.

Implements StormByte::Buffer::ReadOnly.

◆ Read() [1/6]

bool StormByte::Buffer::FIFO::Read ( const StormByte::ByteSize &  count,
StormByte::BinaryData &  outBuffer 
) const
overridevirtualnoexcept

Non-destructive read into a StormByte::BinaryData (advances position).

Parameters
countBytes to read; 0 = all available.
outBufferDestination buffer.
Returns
true on success, false on failure.

Implements StormByte::Buffer::ReadOnly.

◆ Read() [2/6]

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

Bring ReadOnly convenience Read overloads into scope.

Implements StormByte::Buffer::ReadOnly.

◆ Read() [3/6]

bool StormByte::Buffer::FIFO::Read ( const StormByte::ByteSize &  count,
WriteOnly &  outBuffer 
) const
overridevirtualnoexcept

Non-destructive read into a WriteOnly (advances position).

Parameters
countBytes to read; 0 = all available.
outBufferDestination writer.
Returns
true on success, false on failure.

Implements StormByte::Buffer::ReadOnly.

◆ Read() [4/6]

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

Bring ReadOnly convenience Read overloads into scope.

Implements StormByte::Buffer::ReadOnly.

◆ Read() [5/6]

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

Bring ReadOnly convenience Read overloads into scope.

◆ Read() [6/6]

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

Bring ReadOnly convenience Read overloads into scope.

◆ ReadInternal() [1/2]

virtual bool StormByte::Buffer::FIFO::ReadInternal ( const StormByte::ByteSize &  count,
StormByte::BinaryData &  outBuffer,
const Operation &  flag 
)
protectedvirtualnoexcept

Shared implementation for Extract / Read / Peek into StormByte::BinaryData.

Parameters
countRequested byte count (0 = all available).
outBufferDestination.
flagOperation kind.
Returns
true on success.

◆ ReadInternal() [2/2]

virtual bool StormByte::Buffer::FIFO::ReadInternal ( const StormByte::ByteSize &  count,
WriteOnly &  outBuffer,
const Operation &  flag 
)
protectedvirtualnoexcept

Shared implementation for Extract / Read / Peek into WriteOnly.

Parameters
countRequested byte count (0 = all available).
outBufferDestination writer.
flagOperation kind.
Returns
true on success.

◆ ReadUntilEoF() [1/2]

void StormByte::Buffer::FIFO::ReadUntilEoF ( StormByte::BinaryData &  outBuffer) const
overridevirtualnoexcept

Read all remaining bytes until EoF into a StormByte::BinaryData.

Parameters
outBufferDestination buffer.

Implements StormByte::Buffer::ReadOnly.

◆ ReadUntilEoF() [2/2]

void StormByte::Buffer::FIFO::ReadUntilEoF ( WriteOnly &  outBuffer) const
overridevirtualnoexcept

Read all remaining bytes until EoF into a WriteOnly.

Parameters
outBufferDestination writer.

Implements StormByte::Buffer::ReadOnly.

◆ ReadUntilEoFInternal() [1/2]

virtual void StormByte::Buffer::FIFO::ReadUntilEoFInternal ( StormByte::BinaryData &  outBuffer,
const Operation &  flag 
)
protectedvirtualnoexcept

Drain until EoF into StormByte::BinaryData using flag semantics.

Parameters
outBufferDestination.
flagExtract or Read.

◆ ReadUntilEoFInternal() [2/2]

virtual void StormByte::Buffer::FIFO::ReadUntilEoFInternal ( WriteOnly &  outBuffer,
const Operation &  flag 
)
protectedvirtualnoexcept

Drain until EoF into WriteOnly using flag semantics.

Parameters
outBufferDestination.
flagExtract or Read.

◆ Seek()

virtual void StormByte::Buffer::FIFO::Seek ( const std::ptrdiff_t &  offset,
const Position &  mode 
) const
overridevirtualnoexcept

Move the logical read position for non-destructive reads.

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

Position is clamped to [0, Size()]. Does not modify stored data.

Implements StormByte::Buffer::ReadOnly.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ SetError()

void StormByte::Buffer::FIFO::SetError ( )
overridevirtualnoexcept

Enter permanent error state (unreadable and unwritable).

Implements StormByte::Buffer::WriteOnly.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ Size()

virtual StormByte::ByteSize StormByte::Buffer::FIFO::Size ( ) const
overridevirtualnoexcept

Total number of bytes stored (including already-read prefix).

Returns
Size of the internal buffer.
See also
Empty(), Available()

Implements StormByte::Buffer::Generic.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ Write() [1/21]

bool StormByte::Buffer::WriteOnly::Write ( const char *  s)
inlinenoexcept

Bring WriteOnly convenience Write overloads into scope.

◆ Write() [2/21]

template<std::size_t N>
bool StormByte::Buffer::WriteOnly::Write ( const char(&)  s[N])
inlinenoexcept

Bring WriteOnly convenience Write overloads into scope.

◆ Write() [3/21]

template<Type::ByteInputRange R>
bool StormByte::Buffer::WriteOnly::Write ( const R &  r)
inlinenoexcept

Bring WriteOnly convenience Write overloads into scope.

◆ Write() [4/21]

bool StormByte::Buffer::WriteOnly::Write ( const ReadOnly &  data)
inlinenoexcept

Bring WriteOnly convenience Write overloads into scope.

◆ Write() [5/21]

virtual bool StormByte::Buffer::WriteOnly::Write ( const StormByte::ByteSize &  count,
BinaryData &&  data 
)
virtualnoexcept

Bring WriteOnly convenience Write overloads into scope.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [6/21]

virtual bool StormByte::Buffer::WriteOnly::Write ( const StormByte::ByteSize &  count,
const BinaryData &  data 
)
virtualnoexcept

Bring WriteOnly convenience Write overloads into scope.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [7/21]

bool StormByte::Buffer::WriteOnly::Write ( const StormByte::ByteSize &  count,
const char *  s 
)
inlinenoexcept

Bring WriteOnly convenience Write overloads into scope.

◆ Write() [8/21]

bool StormByte::Buffer::FIFO::Write ( const StormByte::ByteSize &  count,
const ReadOnly &  data 
)
overridevirtualnoexcept

Append bytes from a ReadOnly source (copy).

Parameters
countNumber of bytes to write.
dataSource buffer.
Returns
true on success, false if closed / error.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [9/21]

virtual bool StormByte::Buffer::WriteOnly::Write ( const StormByte::ByteSize &  count,
const ReadOnly &  data 
)
virtualnoexcept

Bring WriteOnly convenience Write overloads into scope.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [10/21]

template<Type::ByteInputRange Rw>
bool StormByte::Buffer::WriteOnly::Write ( const StormByte::ByteSize &  count,
const Rw &  r 
)
inlinenoexcept

Bring WriteOnly convenience Write overloads into scope.

◆ Write() [11/21]

bool StormByte::Buffer::FIFO::Write ( const StormByte::ByteSize &  count,
const StormByte::BinaryData &  data 
)
overridevirtualnoexcept

Append bytes from a StormByte::BinaryData (copy).

Parameters
countNumber of bytes to write.
dataSource.
Returns
true on success, false if closed / error.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [12/21]

template<Type::ByteInputIterator I2, typename S2 >
requires Type::SentinelFor<S2, I2>
bool StormByte::Buffer::WriteOnly::Write ( const StormByte::ByteSize &  count,
I2  first,
S2  last 
)
inlinenoexcept

Bring WriteOnly convenience Write overloads into scope.

◆ Write() [13/21]

bool StormByte::Buffer::FIFO::Write ( const StormByte::ByteSize &  count,
ReadOnly &&  data 
)
overridevirtualnoexcept

Append bytes from a ReadOnly source (move / extract path).

Parameters
countNumber of bytes to write.
dataSource buffer.
Returns
true on success, false if closed / error.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [14/21]

virtual bool StormByte::Buffer::WriteOnly::Write ( const StormByte::ByteSize &  count,
ReadOnly &&  data 
)
virtualnoexcept

Bring WriteOnly convenience Write overloads into scope.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [15/21]

template<Type::ByteInputRange Rrw>
bool StormByte::Buffer::WriteOnly::Write ( const StormByte::ByteSize &  count,
Rrw &&  r 
)
inlinenoexcept

Bring WriteOnly convenience Write overloads into scope.

◆ Write() [16/21]

bool StormByte::Buffer::WriteOnly::Write ( const StormByte::ByteSize &  count,
std::string_view  sv 
)
inlinenoexcept

Bring WriteOnly convenience Write overloads into scope.

◆ Write() [17/21]

bool StormByte::Buffer::FIFO::Write ( const StormByte::ByteSize &  count,
StormByte::BinaryData &&  data 
)
overridevirtualnoexcept

Append bytes from a StormByte::BinaryData (move).

Parameters
countNumber of bytes to write.
dataSource.
Returns
true on success, false if closed / error.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [18/21]

template<Type::ByteInputIterator I, typename S >
requires Type::SentinelFor<S, I>
bool StormByte::Buffer::WriteOnly::Write ( I  first,
S  last 
)
inlinenoexcept

Bring WriteOnly convenience Write overloads into scope.

◆ Write() [19/21]

bool StormByte::Buffer::WriteOnly::Write ( ReadOnly &&  data)
inlinenoexcept

Bring WriteOnly convenience Write overloads into scope.

◆ Write() [20/21]

template<Type::ByteInputRange Rr>
bool StormByte::Buffer::WriteOnly::Write ( Rr &&  r)
inlinenoexcept

Bring WriteOnly convenience Write overloads into scope.

◆ Write() [21/21]

bool StormByte::Buffer::WriteOnly::Write ( std::string_view  sv)
inlinenoexcept

Bring WriteOnly convenience Write overloads into scope.

◆ WriteInternal() [1/4]

virtual bool StormByte::Buffer::FIFO::WriteInternal ( const StormByte::ByteSize &  count,
const ReadOnly &  src 
)
protectedvirtualnoexcept

Append from ReadOnly (copy path).

Parameters
countNumber of bytes.
srcSource.
Returns
true on success, false if closed / error.

◆ WriteInternal() [2/4]

virtual bool StormByte::Buffer::FIFO::WriteInternal ( const StormByte::ByteSize &  count,
const StormByte::BinaryData &  src 
)
protectedvirtualnoexcept

Append from StormByte::BinaryData (copy).

Parameters
countNumber of bytes.
srcSource.
Returns
true on success, false if closed / error.

◆ WriteInternal() [3/4]

virtual bool StormByte::Buffer::FIFO::WriteInternal ( const StormByte::ByteSize &  count,
ReadOnly &&  src 
)
protectedvirtualnoexcept

Append from ReadOnly (move / extract path).

Parameters
countNumber of bytes.
srcSource.
Returns
true on success, false if closed / error.

◆ WriteInternal() [4/4]

virtual bool StormByte::Buffer::FIFO::WriteInternal ( const StormByte::ByteSize &  count,
StormByte::BinaryData &&  src 
)
protectedvirtualnoexcept

Append from StormByte::BinaryData (move).

Parameters
countNumber of bytes.
srcSource.
Returns
true on success, false if closed / error.

Member Data Documentation

◆ m_buffer

StormByte::BinaryData StormByte::Buffer::FIFO::m_buffer
protected

Owned contiguous byte storage.

◆ m_closed

bool StormByte::Buffer::FIFO::m_closed {false}
protected

Once true, further writes fail.

◆ m_error

bool StormByte::Buffer::FIFO::m_error {false}
protected

Permanent error: unreadable and unwritable.

◆ m_position_offset

StormByte::ByteSize StormByte::Buffer::FIFO::m_position_offset {0}
mutableprotected

Logical read offset from start of m_buffer.


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