StormByte C++ Library: Buffer module 0.0.9999
StormByte-Buffer is a StormByte library module for handling buffers
Loading...
Searching...
No Matches
Public Member Functions | List of all members
StormByte::Buffer::ReadWrite Class Reference

Generic class providing a buffer that can be both read from and written to. More...

#include <generic.hxx>

Inheritance diagram for StormByte::Buffer::ReadWrite:
Inheritance graph
[legend]
Collaboration diagram for StormByte::Buffer::ReadWrite:
Collaboration graph
[legend]

Public Member Functions

 ReadWrite () noexcept
 Construct ReadWrite.
 
 ReadWrite (const DataType &data) noexcept
 Construct ReadWrite.
 
 ReadWrite (DataType &&data) noexcept
 Construct ReadWrite with initial data using move semantics.
 
 ReadWrite (const ReadWrite &other) noexcept=default
 Copy construct deleted.
 
 ReadWrite (ReadWrite &&other) noexcept=default
 Move construct deleted.
 
virtual ~ReadWrite () noexcept=default
 Virtual destructor.
 
ReadWriteoperator= (const ReadWrite &other)=default
 Copy assign deleted.
 
ReadWriteoperator= (ReadWrite &&other) noexcept=default
 Move assign deleted.
 
- Public Member Functions inherited from StormByte::Buffer::ReadOnly
 ReadOnly () noexcept
 Construct ReadOnly.
 
 ReadOnly (const DataType &data) noexcept
 Construct ReadOnly.
 
 ReadOnly (DataType &&data) noexcept
 Construct ReadOnly with initial data using move semantics.
 
 ReadOnly (const ReadOnly &) noexcept=default
 Copy construct deleted.
 
 ReadOnly (ReadOnly &&) noexcept=default
 Move construct deleted.
 
virtual ~ReadOnly () noexcept=default
 Virtual destructor.
 
ReadOnlyoperator= (const ReadOnly &)=default
 Copy assign deleted.
 
ReadOnlyoperator= (ReadOnly &&) noexcept=default
 Move assign deleted.
 
virtual std::size_t AvailableBytes () const noexcept=0
 Gets available bytes for reading.
 
virtual void Clean () noexcept=0
 Clean buffer data from start to read position.
 
virtual void Clear () noexcept=0
 Clear all buffer contents.
 
virtual const DataType & Data () const noexcept
 Access the internal data buffer.
 
virtual bool Drop (const std::size_t &count) noexcept=0
 Drop bytes in the buffer.
 
virtual bool Empty () const noexcept=0
 Check if the buffer is empty.
 
virtual bool EoF () const noexcept=0
 Check if the reader has reached end-of-file.
 
virtual bool Extract (const std::size_t &count, DataType &outBuffer) noexcept=0
 Destructive read that removes data from the buffer into an existing vector.
 
bool Extract (DataType &outBuffer) noexcept
 Destructive read that removes all data from the buffer into an existing vector.
 
virtual bool Extract (const std::size_t &count, WriteOnly &outBuffer) noexcept=0
 Destructive read that removes data from the buffer into a FIFO.
 
bool Extract (WriteOnly &outBuffer) noexcept
 Destructive read that removes all data from the buffer into a FIFO.
 
virtual void ExtractUntilEoF (DataType &outBuffer) noexcept=0
 Read all bytes until end-of-file into an existing buffer.
 
virtual void ExtractUntilEoF (WriteOnly &outBuffer) noexcept=0
 Read all bytes until end-of-file into a WriteOnly buffer.
 
virtual bool IsReadable () const noexcept=0
 Check if the buffer is readable.
 
virtual bool Peek (const std::size_t &count, DataType &outBuffer) const noexcept=0
 Non-destructive peek at buffer data without advancing read position.
 
virtual bool Peek (const std::size_t &count, WriteOnly &outBuffer) const noexcept=0
 Non-destructive peek at buffer data without advancing read position.
 
virtual bool Read (const std::size_t &count, DataType &outBuffer) const noexcept=0
 Read bytes into an existing buffer.
 
bool Read (DataType &outBuffer) const noexcept
 Read bytes into an existing buffer.
 
virtual bool Read (const std::size_t &count, WriteOnly &outBuffer) const noexcept=0
 Read bytes into a WriteOnly buffer.
 
bool Read (WriteOnly &outBuffer) const noexcept
 Read bytes into a WriteOnly buffer.
 
virtual void ReadUntilEoF (DataType &outBuffer) const noexcept=0
 Read all bytes until end-of-file into an existing buffer.
 
virtual void ReadUntilEoF (WriteOnly &outBuffer) const noexcept=0
 Read all bytes until end-of-file into a WriteOnly buffer.
 
virtual void Seek (const std::ptrdiff_t &offset, const Position &mode) const noexcept=0
 Move the read position for non-destructive reads.
 
virtual std::size_t Size () const noexcept=0
 Get the current number of bytes stored in the buffer.
 
- Public Member Functions inherited from StormByte::Buffer::Generic
 Generic () noexcept=default
 Construct Generic.
 
 Generic (const DataType &data) noexcept
 Construct Generic.
 
 Generic (DataType &&data) noexcept
 Construct Generic with initial data using move semantics.
 
 Generic (const Generic &) noexcept=default
 Copy construct deleted.
 
 Generic (Generic &&) noexcept=default
 Move construct deleted.
 
virtual ~Generic () noexcept=0
 Virtual destructor.
 
Genericoperator= (const Generic &other)=default
 Copy assign deleted.
 
Genericoperator= (Generic &&) noexcept=default
 Move assign deleted.
 
- Public Member Functions inherited from StormByte::Buffer::WriteOnly
 WriteOnly () noexcept
 Construct WriteOnly.
 
 WriteOnly (const DataType &data) noexcept
 Construct WriteOnly.
 
 WriteOnly (DataType &&data) noexcept
 Construct WriteOnly with initial data using move semantics.
 
 WriteOnly (const WriteOnly &)=default
 Copy construct deleted.
 
 WriteOnly (WriteOnly &&) noexcept=default
 Move construct deleted.
 
virtual ~WriteOnly () noexcept=default
 Virtual destructor.
 
WriteOnlyoperator= (const WriteOnly &)=default
 Copy assign deleted.
 
WriteOnlyoperator= (WriteOnly &&) noexcept=default
 Move assign deleted.
 
virtual bool IsWritable () const noexcept=0
 Check if the buffer is writable.
 
virtual bool Write (const std::size_t &count, const DataType &data) noexcept=0
 Write bytes from a vector to the buffer.
 
bool Write (std::string_view sv) noexcept
 Write from a string view (does not include terminating NUL).
 
bool Write (const char *s) noexcept
 Write from a C string pointer (null-terminated). Uses std::string_view.
 
bool Write (const std::size_t &count, std::string_view sv) noexcept
 Write up-to count bytes from a string view (0 => all available).
 
bool Write (const std::size_t &count, const char *s) noexcept
 Write up-to count bytes from a C string pointer (null-terminated).
 
template<std::size_t N>
bool Write (const char(&s)[N]) noexcept
 Write from a string literal (array) and avoid copying the trailing NUL.
 
template<std::ranges::input_range R>
requires (!std::is_class_v<std::remove_cv_t<std::ranges::range_value_t<R>>>) && requires(std::ranges::range_value_t<R> v) { static_cast<std::byte>(v); }
bool Write (const R &r) noexcept
 Write all elements from an input range to the buffer.
 
template<std::ranges::input_range Rw>
requires (!std::is_class_v<std::remove_cv_t<std::ranges::range_value_t<Rw>>>) && requires(std::ranges::range_value_t<Rw> v) { static_cast<std::byte>(v); }
bool Write (const std::size_t &count, const Rw &r) noexcept
 Write up-to count elements from an input range.
 
template<std::ranges::input_range Rrw>
requires (!std::is_class_v<std::remove_cv_t<std::ranges::range_value_t<Rrw>>>) && requires(std::ranges::range_value_t<Rrw> v) { static_cast<std::byte>(v); }
bool Write (const std::size_t &count, Rrw &&r) noexcept
 Write up-to count elements from an rvalue range.
 
template<std::ranges::input_range Rr>
requires (!std::is_class_v<std::remove_cv_t<std::ranges::range_value_t<Rr>>>) && requires(std::ranges::range_value_t<Rr> v) { static_cast<std::byte>(v); }
bool Write (Rr &&r) noexcept
 Write from an rvalue input range.
 
template<std::input_iterator I, std::sentinel_for< I > S>
requires (!std::is_class_v<std::remove_cv_t<std::iter_value_t<I>>>) && requires(std::iter_value_t<I> v) { static_cast<std::byte>(v); }
bool Write (I first, S last) noexcept
 Write from iterator pair whose value_type is convertible to std::byte.
 
template<std::input_iterator I2, std::sentinel_for< I2 > S2>
requires (!std::is_class_v<std::remove_cv_t<std::iter_value_t<I2>>>) && requires(std::iter_value_t<I2> v) { static_cast<std::byte>(v); }
bool Write (const std::size_t &count, I2 first, S2 last) noexcept
 Write up-to count bytes from an iterator pair (0 => all available).
 
virtual bool Write (const std::size_t &count, DataType &&data) noexcept=0
 Move bytes from a vector to the buffer.
 
virtual bool Write (const std::size_t &count, const ReadOnly &data) noexcept=0
 Write bytes from a vector to the buffer.
 
bool Write (const ReadOnly &data) noexcept
 Write bytes from a vector to the buffer.
 
virtual bool Write (const std::size_t &count, ReadOnly &&data) noexcept=0
 Move bytes from a vector to the buffer.
 
bool Write (ReadOnly &&data) noexcept
 Move bytes from a vector to the buffer.
 

Additional Inherited Members

- Static Protected Member Functions inherited from StormByte::Buffer::Generic
template<std::ranges::input_range Src>
requires (!std::is_class_v<std::remove_cv_t<std::ranges::range_value_t<Src>>>) && requires(std::ranges::range_value_t<Src> v) { static_cast<std::byte>(v); }
static DataType DataConvert (const Src &src) noexcept
 Convert various source types into the library DataType.
 
template<std::ranges::input_range Src>
requires (!std::is_class_v<std::remove_cv_t<std::ranges::range_value_t<Src>>>) && requires(std::ranges::range_value_t<Src> v) { static_cast<std::byte>(v); }
static DataType DataConvert (Src &&src) noexcept
 
static DataType DataConvert (std::string_view sv) noexcept
 Convert a std::string_view to DataType.
 
static DataType DataConvert (const char *s) noexcept
 Convert a null-terminated C string to DataType.
 
- Protected Attributes inherited from StormByte::Buffer::Generic
DataType m_buffer
 Internal buffer storage.
 

Detailed Description

Generic class providing a buffer that can be both read from and written to.

Overview
ReadWrite extends both ReadOnly and WriteOnly to provide a full read-write buffer interface. It allows reading and writing data to the buffer, supporting scenarios where data needs to be both consumed and produced.

Constructor & Destructor Documentation

◆ ReadWrite() [1/2]

StormByte::Buffer::ReadWrite::ReadWrite ( const DataType &  data)
inlinenoexcept

Construct ReadWrite.

Parameters
dataInitial byte vector to populate the ReadWrite.

◆ ReadWrite() [2/2]

StormByte::Buffer::ReadWrite::ReadWrite ( DataType &&  data)
inlinenoexcept

Construct ReadWrite with initial data using move semantics.

Parameters
dataInitial byte vector to move into the ReadWrite.

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