44#include <StormByte/type_traits/safe.hxx>
48#include <StormByte/safe/string.hxx>
118 template<Type::ByteInputRange R>
120 inline FIFO(
const R& r) noexcept
128 template<Type::ByteInputRange Rr>
136 inline FIFO(std::string_view sv) noexcept
143 inline FIFO(
const char* s) noexcept
144 :
FIFO(s ? std::string_view(s) : std::string_view()) {}
191 inline
bool operator==(const
FIFO& other) const noexcept {
192 return m_buffer == other.m_buffer &&
204 return !(*
this == other);
235 virtual
bool Empty() const noexcept override;
241 virtual
bool EoF() const noexcept override;
274 virtual
void Clean() noexcept override;
281 virtual
void Clear() noexcept override;
303 virtual
void Seek(const
std::ptrdiff_t& offset, const
Position& mode) const noexcept override;
virtual bool Empty() const noexcept override
Whether the underlying storage is empty.
StormByte::ByteSize AvailableInternal() const noexcept
Return unread bytes without virtual dispatch.
void ExtractUntilEoF(StormByte::Safe::Binary &outBuffer) noexcept override
Extract until EoF into owned storage.
virtual bool IsWritable() const noexcept override
Whether the buffer accepts writes.
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.
FIFO(FIFO &&other) noexcept
Take a FIFO.
virtual ~FIFO() noexcept
Destroy the FIFO.
void ReadUntilEoF(StormByte::Safe::Binary &outBuffer) const noexcept override
Read until EoF into owned storage.
FIFO(std::string_view sv) noexcept
Construct a FIFO from a string view.
Definition fifo.hxx:136
FIFO(const FIFO &other) noexcept
Copy a FIFO, including contents and state.
virtual void ReadUntilEoFInternal(StormByte::Safe::Binary &outBuffer, const Operation &flag) noexcept
Drain until EoF into owned storage.
virtual StormByte::ByteSize Size() const noexcept override
Total number of bytes stored, including the already-read prefix.
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.
FIFO(const R &r) noexcept
Construct a FIFO from an input range.
Definition fifo.hxx:120
virtual bool WriteInternal(const StormByte::ByteSize &count, const StormByte::Safe::Binary &src) noexcept
Append from owned storage (copy).
FIFO(StormByte::Safe::Binary &&data) noexcept
Construct a FIFO with initial data (move).
Definition fifo.hxx:109
virtual StormByte::ByteSize Available() const noexcept override
Bytes available from the current read position.
void Close() noexcept override
Mark the buffer closed for further writes.
FIFO() noexcept=default
Default construct an empty FIFO.
virtual bool EoF() const noexcept override
End-of-stream condition.
virtual StormByte::Safe::String HexDumpHeader() const noexcept
Build the hexdump header.
FIFO(Rr &&r) noexcept
Construct a FIFO from an rvalue range.
Definition fifo.hxx:129
bool m_closed
Once true, further writes fail.
Definition fifo.hxx:497
Operation
Kind of internal read operation.
Definition fifo.hxx:503
virtual void Clear() noexcept override
Clear stored bytes and reset the read position.
virtual const StormByte::Safe::Binary & Data() const noexcept override
Access the internal storage.
StormByte::Safe::Binary m_buffer
Owned contiguous byte storage.
Definition fifo.hxx:495
bool operator!=(const FIFO &other) const noexcept
Compare two FIFOs.
Definition fifo.hxx:203
bool Extract(const StormByte::ByteSize &count, StormByte::Safe::Binary &outBuffer) noexcept override
Extract bytes into owned storage.
StormByte::ByteSize m_position_offset
Logical read offset from the start of m_buffer.
Definition fifo.hxx:496
bool Peek(const StormByte::ByteSize &count, StormByte::Safe::Binary &outBuffer) const noexcept override
Peek into owned storage without advancing the position.
virtual bool IsReadable() const noexcept override
Whether the buffer can be read.
bool Write(const StormByte::ByteSize &count, const StormByte::Safe::Binary &data) noexcept override
Append bytes from owned storage (copy).
virtual void Seek(const std::ptrdiff_t &offset, const Position &mode) const noexcept override
Move the logical read position.
FIFO(const char *s) noexcept
Construct a FIFO from a C string.
Definition fifo.hxx:143
virtual void Clean() noexcept override
Discard data from the start up to the current read position.
bool Read(const StormByte::ByteSize &count, StormByte::Safe::Binary &outBuffer) const noexcept override
Read into owned storage and advance the position.
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.
void SetError() noexcept override
Enter the permanent error state.
virtual bool Drop(const StormByte::ByteSize &count) noexcept override
Discard unread bytes and advance the read position.
bool m_error
Permanent error: unreadable and unwritable.
Definition fifo.hxx:498
static STORMBYTE_FORCE_INLINE Safe::Binary DataConvert(const Src &src) noexcept
Convert an lvalue input range to StormByte::Safe::Binary.
Definition generic.hxx:156
Buffer that can be read and not written.
Definition generic.hxx:220
ReadWrite() noexcept
Default constructor.
Buffer that can be written and not read.
Definition generic.hxx:497
STORMBYTE_DECLARE_MAYBE_SAFE(class StormByte::System::Device::Access)
Buffer module of the StormByte suite.
Position
Forward declaration of the WriteOnly interface.
Definition typedefs.hxx:74
Root namespace of the StormByte C++ suite.
#define STORMBYTE_BUFFER_PUBLIC
Definition visibility.h:54