|
StormByte C++ Library: Buffer module 0.0.9999
StormByte-Buffer is a StormByte library module for handling buffers
|
Read-only interface for consuming data from a shared FIFO buffer. More...
#include <consumer.hxx>


Public Member Functions | |
| Consumer (const Consumer &other) noexcept | |
| Copy constructor. | |
| Consumer (Consumer &&other) noexcept | |
| Move constructor. | |
| ~Consumer () noexcept=default | |
| Destructor. | |
| Consumer & | operator= (const Consumer &other) noexcept |
| Copy assignment operator. | |
| Consumer & | operator= (Consumer &&other) noexcept |
| Move assignment operator. | |
| bool | operator== (const Consumer &other) const noexcept |
| Equality comparison. | |
| bool | operator!= (const Consumer &other) const noexcept |
| Inequality comparison. | |
| std::size_t | AvailableBytes () const noexcept override |
| Gets available bytes for reading. | |
| void | Clean () noexcept override |
| Clean buffer data from start to read position. | |
| void | Clear () noexcept override |
| Clear all buffer contents. | |
| void | Close () noexcept |
| Thread-safe close for further writes. | |
| bool | Drop (const std::size_t &count) noexcept override |
| Drop bytes in the buffer. | |
| bool | Empty () const noexcept override |
| Check if the buffer is empty. | |
| bool | EoF () const noexcept override |
| Check if the reader has reached end-of-file. | |
| bool | Extract (const std::size_t &count, DataType &outBuffer) noexcept override |
| Destructive read that removes data from the buffer into an existing vector. | |
| bool | Extract (const std::size_t &count, WriteOnly &outBuffer) noexcept |
| Destructive read that removes data from the buffer into a FIFO. | |
| void | ExtractUntilEoF (DataType &outBuffer) noexcept override |
| Read all bytes until end-of-file into an existing buffer. | |
| void | ExtractUntilEoF (WriteOnly &outBuffer) noexcept override |
| Read all bytes until end-of-file into a WriteOnly buffer. | |
| bool | IsReadable () const noexcept override |
| Check if the buffer is readable (not in error state). | |
| bool | IsWritable () const noexcept |
| Check if the buffer is writable (not closed and not in error state). | |
| bool | HasError () const noexcept |
| Check if the buffer is in an error state. | |
| bool | Read (const std::size_t &count, DataType &outBuffer) const noexcept override |
| Read bytes into an existing buffer. | |
| bool | Read (const std::size_t &count, WriteOnly &outBuffer) const noexcept override |
| Read bytes into a WriteOnly buffer. | |
| void | ReadUntilEoF (DataType &outBuffer) const noexcept override |
| Read all bytes until end-of-file into an existing buffer. | |
| void | ReadUntilEoF (WriteOnly &outBuffer) const noexcept override |
| Read all bytes until end-of-file into a WriteOnly buffer. | |
| bool | Peek (const std::size_t &count, DataType &outBuffer) const noexcept override |
| Non-destructive peek at buffer data without advancing read position. | |
| bool | Peek (const std::size_t &count, WriteOnly &outBuffer) const noexcept override |
| Non-destructive peek at buffer data without advancing read position. | |
| void | Seek (const std::ptrdiff_t &offset, const Position &mode) const noexcept |
| Move the read position for non-destructive reads. | |
| std::size_t | Size () const noexcept override |
| Get the current number of bytes stored in the buffer. | |
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. | |
| ReadOnly & | operator= (const ReadOnly &)=default |
| Copy assign deleted. | |
| ReadOnly & | operator= (ReadOnly &&) noexcept=default |
| Move assign deleted. | |
| virtual const DataType & | Data () const noexcept |
| Access the internal data buffer. | |
| bool | Extract (DataType &outBuffer) noexcept |
| Destructive read that removes all data from the buffer into an existing vector. | |
| bool | Extract (WriteOnly &outBuffer) noexcept |
| Destructive read that removes all data from the buffer into a FIFO. | |
| bool | Read (DataType &outBuffer) const noexcept |
| Read bytes into an existing buffer. | |
| bool | Read (WriteOnly &outBuffer) const noexcept |
| Read bytes into a WriteOnly 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. | |
| Generic & | operator= (const Generic &other)=default |
| Copy assign deleted. | |
| Generic & | operator= (Generic &&) noexcept=default |
| Move assign deleted. | |
Friends | |
| class | Producer |
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. | |
Read-only interface for consuming data from a shared FIFO buffer.
|
inlinenoexcept |
Copy constructor.
| other | Source Consumer to copy from. |
Copies the Consumer instance, sharing the same underlying buffer. Both instances will read from the same SharedFIFO and share the read position state.
|
inlinenoexcept |
|
inlineoverridevirtualnoexcept |
Gets available bytes for reading.
Implements StormByte::Buffer::ReadOnly.
|
inlineoverridevirtualnoexcept |
Clean buffer data from start to read position.
Implements StormByte::Buffer::ReadOnly.
|
inlineoverridevirtualnoexcept |
Clear all buffer contents.
Removes all data from the buffer, resets head/tail/read positions, and restores capacity to the initial value requested in the constructor.
Implements StormByte::Buffer::ReadOnly.
|
inlinenoexcept |
Thread-safe close for further writes.
Marks buffer as closed, notifies all waiting threads. Subsequent writes are ignored. The buffer remains readable until all data is consumed.
|
inlineoverridevirtualnoexcept |
Drop bytes in the buffer.
| count | Number of bytes to drop. |
Implements StormByte::Buffer::ReadOnly.
|
inlineoverridevirtualnoexcept |
Check if the buffer is empty.
Implements StormByte::Buffer::ReadOnly.
|
inlineoverridevirtualnoexcept |
Check if the reader has reached end-of-file.
Returns true when the buffer has been closed or set to error and there are no available bytes remaining.
Implements StormByte::Buffer::ReadOnly.
|
inlineoverridevirtualnoexcept |
Destructive read that removes data from the buffer into an existing vector.
| count | Number of bytes to extract; 0 extracts all available. |
| outBuffer | Vector to fill with extracted bytes; resized as needed. |
Implements StormByte::Buffer::ReadOnly.
|
inlinevirtualnoexcept |
Destructive read that removes data from the buffer into a FIFO.
| count | Number of bytes to extract; 0 extracts all available. |
| outBuffer | WriteOnly to fill with extracted bytes; resized as needed. |
Implements StormByte::Buffer::ReadOnly.
|
inlineoverridevirtualnoexcept |
Read all bytes until end-of-file into an existing buffer.
| outBuffer | Vector to fill with read bytes; resized as needed. |
Implements StormByte::Buffer::ReadOnly.
|
inlineoverridevirtualnoexcept |
Read all bytes until end-of-file into a WriteOnly buffer.
| outBuffer | WriteOnly to fill with read bytes; resized as needed. |
Implements StormByte::Buffer::ReadOnly.
|
inlinenoexcept |
Check if the buffer is in an error state.
|
inlineoverridevirtualnoexcept |
Check if the buffer is readable (not in error state).
A buffer becomes unreadable when SetError() is called. Use in combination with AvailableBytes() to check if there is data pending to read.
Implements StormByte::Buffer::ReadOnly.
|
inlinenoexcept |
Check if the buffer is writable (not closed and not in error state).
A buffer becomes unwritable when Close() or SetError() is called.
|
inlinenoexcept |
Inequality comparison.
Copy assignment operator.
|
inlinenoexcept |
Equality comparison.
|
inlineoverridevirtualnoexcept |
Non-destructive peek at buffer data without advancing read position.
| count | Number of bytes to peek; 0 peeks all available from read position. |
Similar to Read(), but does not advance the read position. Allows inspecting upcoming data without consuming it.
Semantics:
count == 0: the call returns all available bytes. If no bytes are available, a ReadError is returned.count > 0: the call returns exactly count bytes when that many bytes are available. If zero bytes are available, or if count is greater than the number of available bytes, a ReadError is returned.Implements StormByte::Buffer::ReadOnly.
|
inlineoverridevirtualnoexcept |
Non-destructive peek at buffer data without advancing read position.
| count | Number of bytes to peek; 0 peeks all available from read position. |
Similar to Read(), but does not advance the read position. Allows inspecting upcoming data without consuming it.
Semantics:
count == 0: the call returns all available bytes. If no bytes are available, a ReadError is returned.count > 0: the call returns exactly count bytes when that many bytes are available. If zero bytes are available, or if count is greater than the number of available bytes, a ReadError is returned.Implements StormByte::Buffer::ReadOnly.
|
inlineoverridevirtualnoexcept |
Read bytes into an existing buffer.
| count | Number of bytes to read; 0 reads all available from read position. |
| outBuffer | Vector to fill with read bytes; resized as needed. |
Implements StormByte::Buffer::ReadOnly.
|
inlineoverridevirtualnoexcept |
Read bytes into a WriteOnly buffer.
| count | Number of bytes to read; 0 reads all available from read position. |
| outBuffer | WriteOnly to fill with read bytes; resized as needed. |
Implements StormByte::Buffer::ReadOnly.
|
inlineoverridevirtualnoexcept |
Read all bytes until end-of-file into an existing buffer.
| outBuffer | Vector to fill with read bytes; resized as needed. |
Implements StormByte::Buffer::ReadOnly.
|
inlineoverridevirtualnoexcept |
Read all bytes until end-of-file into a WriteOnly buffer.
| outBuffer | WriteOnly to fill with read bytes; resized as needed. |
Implements StormByte::Buffer::ReadOnly.
|
inlinevirtualnoexcept |
Move the read position for non-destructive reads.
| position | The offset value to apply. |
| mode | Unused for base class; included for API consistency. |
Changes where subsequent Read() operations will start reading from. Position is clamped to [0, Size()]. Does not affect stored data.
Implements StormByte::Buffer::ReadOnly.
|
inlineoverridevirtualnoexcept |
Get the current number of bytes stored in the buffer.
Implements StormByte::Buffer::ReadOnly.