StormByte-Buffer 4.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::Safe::Binary &data) noexcept
 Construct a FIFO with initial data (copy).
 FIFO (StormByte::Safe::Binary &&data) noexcept
 Construct a FIFO with initial data (move).
template<Type::ByteInputRange R>
requires (!Type::SameAs<R, StormByte::Safe::Binary>)
 FIFO (const R &r) noexcept
 Construct a FIFO from an input range.
template<Type::ByteInputRange Rr>
 FIFO (Rr &&r) noexcept
 Construct a FIFO from an rvalue range.
 FIFO (std::string_view sv) noexcept
 Construct a FIFO from a string view.
 FIFO (const char *s) noexcept
 Construct a FIFO from a C string.
 FIFO (const FIFO &other) noexcept
 Copy a FIFO, including contents and state.
 FIFO (FIFO &&other) noexcept
 Take a FIFO.
virtual ~FIFO () noexcept
 Destroy the FIFO.
FIFO & operator= (const FIFO &other)
 Copy-assign a FIFO, including contents and state.
FIFO & operator= (FIFO &&other) noexcept
 Move-assign a FIFO.
Comparison
bool operator== (const FIFO &other) const noexcept
 Compare two FIFOs.
bool operator!= (const FIFO &other) const noexcept
 Compare two FIFOs.
Queries
virtual StormByte::ByteSize Available () const noexcept override
 Bytes available from the current read position.
virtual const StormByte::Safe::Binary & 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 the 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 stored bytes 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 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.
void SetError () noexcept override
 Enter the permanent error state.
Extract (destructive)
bool Extract (const StormByte::ByteSize &count, StormByte::Safe::Binary &outBuffer) noexcept override
 Extract bytes into owned storage.
bool Extract (const StormByte::ByteSize &count, WriteOnly &outBuffer) noexcept override
 Extract bytes into a writer.
void ExtractUntilEoF (StormByte::Safe::Binary &outBuffer) noexcept override
 Extract until EoF into owned storage.
void ExtractUntilEoF (WriteOnly &outBuffer) noexcept override
 Extract until EoF into a writer.
bool Extract (StormByte::Safe::Binary &outBuffer) noexcept
 Bring the ReadOnly convenience Extract overloads into scope.
bool Extract (WriteOnly &outBuffer) noexcept
 Bring the ReadOnly convenience Extract overloads into scope.
Read (non-destructive)
bool Read (const StormByte::ByteSize &count, StormByte::Safe::Binary &outBuffer) const noexcept override
 Read into owned storage and advance the position.
bool Read (const StormByte::ByteSize &count, WriteOnly &outBuffer) const noexcept override
 Read into a writer and advance the position.
void ReadUntilEoF (StormByte::Safe::Binary &outBuffer) const noexcept override
 Read until EoF into owned storage.
void ReadUntilEoF (WriteOnly &outBuffer) const noexcept override
 Read until EoF into a writer.
bool Read (StormByte::Safe::Binary &outBuffer) const noexcept
 Bring the ReadOnly convenience Read overloads into scope.
bool Read (WriteOnly &outBuffer) const noexcept
 Bring the ReadOnly convenience Read overloads into scope.
Peek (non-destructive, does not advance)
bool Peek (const StormByte::ByteSize &count, StormByte::Safe::Binary &outBuffer) const noexcept override
 Peek into owned storage without advancing the position.
bool Peek (const StormByte::ByteSize &count, WriteOnly &outBuffer) const noexcept override
 Peek into a writer without advancing the position.
Diagnostics
virtual StormByte::Safe::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::Safe::Binary &data) noexcept override
 Append bytes from owned storage (copy).
bool Write (const StormByte::ByteSize &count, StormByte::Safe::Binary &&data) noexcept override
 Append bytes from owned storage (move).
bool Write (const StormByte::ByteSize &count, const ReadOnly &data) noexcept override
 Append bytes from a readable buffer (copy).
bool Write (const StormByte::ByteSize &count, ReadOnly &&data) noexcept override
 Append bytes from a readable buffer (extract path).
bool Write (const ReadOnly &data) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
bool Write (ReadOnly &&data) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
bool Write (std::string_view sv) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
bool Write (const char *s) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
bool Write (const StormByte::ByteSize &count, std::string_view sv) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
bool Write (const StormByte::ByteSize &count, const char *s) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
template<std::size_t N>
bool Write (const char(&s)[N]) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
template<Type::ByteInputRange R>
STORMBYTE_FORCE_INLINE bool Write (const R &r) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
template<Type::ByteInputRange Rw>
STORMBYTE_FORCE_INLINE bool Write (const StormByte::ByteSize &count, const Rw &r) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
template<Type::ByteInputRange Rrw>
STORMBYTE_FORCE_INLINE bool Write (const StormByte::ByteSize &count, Rrw &&r) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
template<Type::ByteInputRange Rr>
STORMBYTE_FORCE_INLINE bool Write (Rr &&r) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
template<Type::ByteInputIterator I, typename S>
requires Type::SentinelFor<S, I>
STORMBYTE_FORCE_INLINE bool Write (I first, S last) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
template<Type::ByteInputIterator I2, typename S2>
requires Type::SentinelFor<S2, I2>
STORMBYTE_FORCE_INLINE bool Write (const StormByte::ByteSize &count, I2 first, S2 last) noexcept
 Bring the WriteOnly convenience Write overloads into scope.
Public Member Functions inherited from StormByte::Buffer::ReadWrite
 ReadWrite () noexcept
 Default constructor.
 ReadWrite (const ReadWrite &other) noexcept
 Copy constructor.
 ReadWrite (ReadWrite &&other) noexcept
 Move constructor.
virtual ~ReadWrite () noexcept
 Destructor.
ReadWrite & operator= (const ReadWrite &other) noexcept
 Copy assignment.
ReadWrite & operator= (ReadWrite &&other) noexcept
 Move assignment.
Public Member Functions inherited from StormByte::Buffer::ReadOnly
 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.
bool Extract (StormByte::Safe::Binary &outBuffer) noexcept
 Extract all available bytes into a StormByte::Safe::Binary.
bool Extract (WriteOnly &outBuffer) noexcept
 Extract all available bytes into a WriteOnly.
bool Read (StormByte::Safe::Binary &outBuffer) const noexcept
 Read all available bytes into a StormByte::Safe::Binary.
bool Read (WriteOnly &outBuffer) const noexcept
 Read all available bytes 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.
Public Member Functions inherited from StormByte::Buffer::WriteOnly
 WriteOnly () noexcept
 Default constructor.
 WriteOnly (const WriteOnly &other) noexcept
 Copy constructor.
 WriteOnly (WriteOnly &&other) noexcept
 Move constructor.
virtual ~WriteOnly () noexcept
 Destructor.
WriteOnly & operator= (const WriteOnly &other) noexcept
 Copy assignment.
WriteOnly & operator= (WriteOnly &&other) noexcept
 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>
STORMBYTE_FORCE_INLINE bool Write (const R &r) noexcept
 Write all elements from an input range.
template<Type::ByteInputRange Rw>
STORMBYTE_FORCE_INLINE bool Write (const StormByte::ByteSize &count, const Rw &r) noexcept
 Write up to count elements from an input range.
template<Type::ByteInputRange Rrw>
STORMBYTE_FORCE_INLINE bool Write (const StormByte::ByteSize &count, Rrw &&r) noexcept
 Write up to count elements from an rvalue range.
template<Type::ByteInputRange Rr>
STORMBYTE_FORCE_INLINE bool Write (Rr &&r) noexcept
 Write all elements from an rvalue range.
template<Type::ByteInputIterator I, typename S>
requires Type::SentinelFor<S, I>
STORMBYTE_FORCE_INLINE 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>
STORMBYTE_FORCE_INLINE 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 StormByte::Safe::String HexDumpHeader () const noexcept
 Build the hexdump header.
Internal read / write helpers
virtual bool ReadInternal (const StormByte::ByteSize &count, StormByte::Safe::Binary &outBuffer, const Operation &flag) noexcept
 Shared implementation for Extract, Read and Peek into owned storage.
virtual bool ReadInternal (const StormByte::ByteSize &count, WriteOnly &outBuffer, const Operation &flag) noexcept
 Shared implementation for Extract, Read and Peek into a writer.
virtual void ReadUntilEoFInternal (StormByte::Safe::Binary &outBuffer, const Operation &flag) noexcept
 Drain until EoF into owned storage.
virtual void ReadUntilEoFInternal (WriteOnly &outBuffer, const Operation &flag) noexcept
 Drain until EoF into a writer.
virtual bool WriteInternal (const StormByte::ByteSize &count, const StormByte::Safe::Binary &src) noexcept
 Append from owned storage (copy).
virtual bool WriteInternal (const StormByte::ByteSize &count, StormByte::Safe::Binary &&src) noexcept
 Append from owned storage (move).
virtual bool WriteInternal (const StormByte::ByteSize &count, const ReadOnly &src) noexcept
 Append from a readable buffer (copy).
virtual bool WriteInternal (const StormByte::ByteSize &count, ReadOnly &&src) noexcept
 Append from a readable buffer (extract path).

Static Protected Member Functions

static StormByte::Safe::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 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.

Protected Attributes

StormByte::Safe::Binary m_buffer
 Owned contiguous byte storage.
StormByte::ByteSize m_position_offset {0}
 Logical read offset from the 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.

A contiguous growable buffer implemented atop StormByte::Safe::Binary that tracks a logical read position. It grows automatically to fit writes and supports non-destructive reads and destructive extracts.

This class is not thread-safe. For concurrent access use SharedFIFO or Ring.

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

Construction from StormByte::Safe::Binary, a byte range, a string view or a C string is implicit.

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 the position.

Peek 

Non-destructive peek. Does not 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::Safe::Binary & data)
inlinenoexcept

Construct a FIFO with initial data (copy).

Implicit.

Parameters
dataInitial bytes.

◆ FIFO() [3/9]

StormByte::Buffer::FIFO::FIFO ( StormByte::Safe::Binary && data)
inlinenoexcept

Construct a FIFO with initial data (move).

Implicit.

Parameters
dataInitial bytes. Moved into the FIFO.

◆ FIFO() [4/9]

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

Construct a FIFO from an input range.

Implicit.

Template Parameters
RInput range whose elements convert to std::byte.
Parameters
rRange to copy from.
Note
Disabled when R is already StormByte::Safe::Binary.

◆ FIFO() [5/9]

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

Construct a FIFO from an rvalue range.

Implicit.

Template Parameters
RrInput range type. Moved when it is StormByte::Safe::Binary.
Parameters
rRange to consume.

◆ FIFO() [6/9]

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

Construct a FIFO from a string view.

Implicit. No trailing NUL.

Parameters
svSource characters.

◆ FIFO() [7/9]

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

Construct a FIFO from a C string.

Implicit.

Parameters
sSource. Null yields an empty buffer.

◆ FIFO() [8/9]

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

Copy a FIFO, including contents and state.

Parameters
otherSource.

◆ FIFO() [9/9]

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

Take a FIFO.

other is left empty and valid.

Parameters
otherSource.

◆ ~FIFO()

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

Destroy the FIFO.

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
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 stored bytes and reset the read position.

Does not clear the closed or 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.

Later Write calls fail. Readers may still drain until Available() is zero.

Implements StormByte::Buffer::WriteOnly.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ Data()

virtual const StormByte::Safe::Binary & StormByte::Buffer::FIFO::Data ( ) const
overridevirtualnoexcept

Access the internal storage.

Returns
Owned bytes.

Implements StormByte::Buffer::ReadOnly.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ Drop()

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

Discard unread bytes and advance the read position.

Parameters
countBytes to drop.
Returns
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
Whether m_buffer is empty.
Note
With a non-zero read position, this 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
Whether the FIFO is in error, or closed with nothing left to read.

Implements StormByte::Buffer::ReadOnly.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ Extract() [1/4]

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

Extract bytes into owned storage.

Parameters
countBytes to extract. 0 means all available.
outBufferDestination.
Returns
False on failure.

Implements StormByte::Buffer::ReadOnly.

◆ Extract() [2/4]

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

Extract bytes into a writer.

Parameters
countBytes to extract. 0 means all available.
outBufferDestination writer.
Returns
False on failure.

Implements StormByte::Buffer::ReadOnly.

◆ Extract() [3/4]

Bring the ReadOnly convenience Extract overloads into scope.

◆ Extract() [4/4]

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

Bring the ReadOnly convenience Extract overloads into scope.

◆ ExtractUntilEoF() [1/2]

void StormByte::Buffer::FIFO::ExtractUntilEoF ( StormByte::Safe::Binary & outBuffer)
overridevirtualnoexcept

Extract until EoF into owned storage.

Parameters
outBufferDestination.

Implements StormByte::Buffer::ReadOnly.

◆ ExtractUntilEoF() [2/2]

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

Extract until EoF into a writer.

Parameters
outBufferDestination writer.

Implements StormByte::Buffer::ReadOnly.

◆ FormatHexLines()

StormByte::Safe::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, without a header.

◆ HexDump()

virtual StormByte::Safe::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 means 16.
byte_limitMaximum bytes to include. 0 means no limit.
Returns
Size, position and status, then hex/ASCII lines. No trailing newline.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ HexDumpHeader()

virtual StormByte::Safe::String StormByte::Buffer::FIFO::HexDumpHeader ( ) const
protectedvirtualnoexcept

Build the hexdump header.

Returns
Owned header text. Any formatting stream stays in this module.

◆ IsReadable()

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

Whether the buffer can be read.

Returns
False in a 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

Compare two FIFOs.

Parameters
otherOther FIFO.
Returns
Whether the FIFOs differ.

◆ operator=() [1/2]

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

Copy-assign a FIFO, including contents and state.

Parameters
otherSource.
Returns
This FIFO.

◆ operator=() [2/2]

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

Move-assign a FIFO.

other is left empty and valid.

Parameters
otherSource.
Returns
This FIFO.

◆ operator==()

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

Compare two FIFOs.

Parameters
otherOther FIFO.
Returns
Whether contents, read position and closed/error flags match.

◆ Peek() [1/2]

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

Peek into owned storage without advancing the position.

Parameters
countBytes to peek. 0 means all available.
outBufferDestination.
Returns
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 writer without advancing the position.

Parameters
countBytes to peek. 0 means all available.
outBufferDestination writer.
Returns
False on failure.

Implements StormByte::Buffer::ReadOnly.

◆ Read() [1/4]

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

Read into owned storage and advance the position.

Parameters
countBytes to read. 0 means all available.
outBufferDestination.
Returns
False on failure.

Implements StormByte::Buffer::ReadOnly.

◆ Read() [2/4]

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

Read into a writer and advance the position.

Parameters
countBytes to read. 0 means all available.
outBufferDestination writer.
Returns
False on failure.

Implements StormByte::Buffer::ReadOnly.

◆ Read() [3/4]

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

Bring the ReadOnly convenience Read overloads into scope.

◆ Read() [4/4]

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

Bring the ReadOnly convenience Read overloads into scope.

◆ ReadInternal() [1/2]

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

Shared implementation for Extract, Read and Peek into owned storage.

Parameters
countRequested byte count. 0 means all available.
outBufferDestination.
flagOperation kind.
Returns
False on failure.

◆ ReadInternal() [2/2]

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

Shared implementation for Extract, Read and Peek into a writer.

Parameters
countRequested byte count. 0 means all available.
outBufferDestination writer.
flagOperation kind.
Returns
False on failure.

◆ ReadUntilEoF() [1/2]

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

Read until EoF into owned storage.

Parameters
outBufferDestination.

Implements StormByte::Buffer::ReadOnly.

◆ ReadUntilEoF() [2/2]

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

Read until EoF into a writer.

Parameters
outBufferDestination writer.

Implements StormByte::Buffer::ReadOnly.

◆ ReadUntilEoFInternal() [1/2]

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

Drain until EoF into owned storage.

Parameters
outBufferDestination.
flagExtract or Read.

◆ ReadUntilEoFInternal() [2/2]

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

Drain until EoF into a writer.

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.

Parameters
offsetOffset.
modeAbsolute or relative.

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 the permanent error state.

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 the already-read prefix.

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

Implements StormByte::Buffer::Generic.

Reimplemented in StormByte::Buffer::SharedFIFO.

◆ Write() [1/17]

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

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [2/17]

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

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [3/17]

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

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [4/17]

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

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [5/17]

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

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [6/17]

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

Append bytes from a readable buffer (copy).

Parameters
countBytes to write.
dataSource buffer.
Returns
False if closed or in error.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [7/17]

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

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [8/17]

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

Append bytes from owned storage (copy).

Parameters
countBytes to write.
dataSource.
Returns
False if closed or in error.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [9/17]

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

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [10/17]

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

Append bytes from a readable buffer (extract path).

Parameters
countBytes to write.
dataSource buffer.
Returns
False if closed or in error.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [11/17]

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

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [12/17]

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

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [13/17]

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

Append bytes from owned storage (move).

Parameters
countBytes to write.
dataSource.
Returns
False if closed or in error.

Implements StormByte::Buffer::WriteOnly.

◆ Write() [14/17]

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

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [15/17]

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

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [16/17]

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

Bring the WriteOnly convenience Write overloads into scope.

◆ Write() [17/17]

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

Bring the 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 a readable buffer (copy).

Parameters
countBytes to write.
srcSource.
Returns
False if closed or in error.

◆ WriteInternal() [2/4]

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

Append from owned storage (copy).

Parameters
countBytes to write.
srcSource.
Returns
False if closed or in error.

◆ WriteInternal() [3/4]

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

Append from a readable buffer (extract path).

Parameters
countBytes to write.
srcSource.
Returns
False if closed or in error.

◆ WriteInternal() [4/4]

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

Append from owned storage (move).

Parameters
countBytes to write.
srcSource.
Returns
False if closed or in error.

Member Data Documentation

◆ m_buffer

StormByte::Safe::Binary 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 the start of m_buffer.


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