|
StormByte C++ Library: Buffer module 1.2.0
StormByte-Buffer is the buffer module of the StormByte C++ suite.
|
Read-oriented handle over a shared Ring. More...
#include <StormByte/buffer/consumer.hxx>


Public Member Functions | |
Copy / move / assignment | |
| Consumer (const Consumer &other) noexcept | |
| Copy constructor. | |
| Consumer (Consumer &&other) noexcept | |
| Move constructor. | |
| ~Consumer () noexcept override | |
| Destructor. | |
| Consumer & | operator= (const Consumer &other) noexcept |
| Copy assignment. | |
| Consumer & | operator= (Consumer &&other) noexcept |
| Move assignment. | |
Comparison | |
| bool | operator== (const Consumer &other) const noexcept |
| Equality comparison. | |
| bool | operator!= (const Consumer &other) const noexcept |
| Inequality comparison. | |
Queries | |
| std::size_t | AvailableBytes () const noexcept override |
| Number of bytes available for reading from the current position. | |
| const DataType & | Data () const noexcept override |
| Access a snapshot of the underlying data (implementation-defined). | |
| bool | Empty () const noexcept override |
| Whether the shared Ring holds no stored bytes. | |
| bool | EoF () const noexcept override |
| End-of-stream condition. | |
| bool | IsReadable () const noexcept override |
| Whether the shared Ring can still be read. | |
| bool | IsWritable () const noexcept |
| Whether the shared Ring still accepts writes. | |
| bool | HasError () const noexcept |
| Whether the shared Ring is in a permanent error state. | |
| std::size_t | Size () const noexcept override |
| Total number of bytes stored in the shared Ring. | |
Maintenance / lifecycle | |
| void | Clean () noexcept override |
| Discard already-consumed data (from start up to the read position). | |
| void | Clear () noexcept override |
| Clear all buffer contents. | |
| void | Close () noexcept |
| Close the shared Ring for further writes. | |
| bool | Drop (const std::size_t &count) noexcept override |
Discard count bytes from the current read position. | |
| void | Seek (const std::ptrdiff_t &offset, const Position &mode) const noexcept override |
| Move the logical read position for non-destructive reads. | |
Extract (destructive read) | |
| bool | Extract (const std::size_t &count, DataType &out) noexcept override |
| Extract bytes into a DataType (consumes data from the Ring). | |
| bool | Extract (const std::size_t &count, WriteOnly &out) noexcept override |
| Extract bytes into a WriteOnly sink (consumes data from the Ring). | |
| void | ExtractUntilEoF (DataType &out) noexcept override |
| Extract all remaining bytes until EoF into a DataType. | |
| void | ExtractUntilEoF (WriteOnly &out) noexcept override |
| Extract all remaining bytes until EoF into a WriteOnly. | |
Read (non-destructive) | |
| bool | Read (const std::size_t &count, DataType &out) const noexcept override |
| Non-destructive read into a DataType (advances logical position). | |
| bool | Read (const std::size_t &count, WriteOnly &out) const noexcept override |
| Non-destructive read into a WriteOnly (advances logical position). | |
| void | ReadUntilEoF (DataType &out) const noexcept override |
| Read all remaining bytes until EoF into a DataType. | |
| void | ReadUntilEoF (WriteOnly &out) const noexcept override |
| Read all remaining bytes until EoF into a WriteOnly. | |
Peek (non-destructive, does not advance position) | |
| bool | Peek (const std::size_t &count, DataType &out) const noexcept override |
| Peek bytes into a DataType without advancing the read position. | |
| bool | Peek (const std::size_t &count, WriteOnly &out) const noexcept override |
| Peek bytes into a WriteOnly without advancing the read position. | |
Public Member Functions inherited from StormByte::Buffer::ReadOnly | |
| ReadOnly () noexcept | |
| Default construct. | |
| ReadOnly (const ReadOnly &) noexcept=default | |
| Copy construct. | |
| ReadOnly (ReadOnly &&) noexcept=default | |
| Move construct. | |
| virtual | ~ReadOnly () noexcept |
| Virtual destructor. | |
| ReadOnly & | operator= (const ReadOnly &)=default |
| Copy assign. | |
| ReadOnly & | operator= (ReadOnly &&) noexcept=default |
| Move assign. | |
| bool | Extract (DataType &outBuffer) noexcept |
| Extract all available bytes into a DataType. | |
| bool | Extract (WriteOnly &outBuffer) noexcept |
| Extract all available bytes into a WriteOnly. | |
| bool | Read (DataType &outBuffer) const noexcept |
| Read all available bytes into a DataType. | |
| 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 construct. | |
| Generic (const Generic &) noexcept=default | |
| Copy construct. | |
| Generic (Generic &&) noexcept=default | |
| Move construct. | |
| virtual | ~Generic () noexcept=0 |
| Pure virtual destructor (keeps the class abstract). | |
| Generic & | operator= (const Generic &other)=default |
| Copy assign. | |
| Generic & | operator= (Generic &&) noexcept=default |
| Move assign. | |
Friends | |
| class | Producer |
Additional Inherited Members | |
Static Protected Member Functions inherited from StormByte::Buffer::Generic | |
| template<Type::ByteInputRange Src> | |
| static DataType | DataConvert (const Src &src) noexcept |
| Convert an lvalue input range to DataType. | |
| template<Type::ByteInputRange Src> | |
| static DataType | DataConvert (Src &&src) noexcept |
| Convert an rvalue input range to DataType (moves when already DataType). | |
| static DataType | DataConvert (std::string_view sv) noexcept |
| Convert a string view to DataType (no trailing NUL). | |
| static DataType | DataConvert (const char *s) noexcept |
| Convert a null-terminated C string to DataType. | |
Read-oriented handle over a shared Ring.
Multiple Consumer instances may share the same underlying Ring, allowing concurrent reads in a fully thread-safe manner. Consumers can only be created through a Producer (see Producer::Consumer()).
All operations are thread-safe and delegate to the shared Ring. Blocking semantics match Ring: Read / Extract / Peek block until data is available or the buffer is closed / in error.
|
inlinenoexcept |
|
inlinenoexcept |
Move constructor.
| other | Source Consumer (left in a valid but unspecified state). |
|
overridenoexcept |
Destructor.
|
overridevirtualnoexcept |
Number of bytes available for reading from the current position.
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Discard already-consumed data (from start up to the read position).
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Clear all buffer contents.
Does not clear closed / error flags on the shared Ring.
Implements StormByte::Buffer::ReadOnly.
|
inlinenoexcept |
Close the shared Ring for further writes.
Equivalent to Producer::Close on the same underlying buffer. Readers may still drain remaining data until EoF.
|
overridevirtualnoexcept |
Access a snapshot of the underlying data (implementation-defined).
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Discard count bytes from the current read position.
| count | Number of bytes to drop. |
true on success, false if fewer bytes were available. Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Whether the shared Ring holds no stored bytes.
true if empty. false even when AvailableBytes() is zero. Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
End-of-stream condition.
true when the Ring is closed (or in error) and no bytes remain. Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Extract bytes into a DataType (consumes data from the Ring).
| count | Number of bytes to extract; 0 extracts all available. |
| out | Destination buffer (appended to / filled by the Ring). |
true on success, false on insufficient data or error. Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Extract bytes into a WriteOnly sink (consumes data from the Ring).
| count | Number of bytes to extract; 0 extracts all available. |
| out | Destination writer. |
true on success, false on insufficient data or error. Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Extract all remaining bytes until EoF into a DataType.
| out | Destination buffer. |
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Extract all remaining bytes until EoF into a WriteOnly.
| out | Destination writer. |
Implements StormByte::Buffer::ReadOnly.
|
inlinenoexcept |
|
overridevirtualnoexcept |
Whether the shared Ring can still be read.
false if the Ring is in a permanent error state. Implements StormByte::Buffer::ReadOnly.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
overridevirtualnoexcept |
Peek bytes into a DataType without advancing the read position.
| count | Number of bytes to peek; 0 peeks all available. |
| out | Destination buffer. |
true on success, false on insufficient data or error. Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Peek bytes into a WriteOnly without advancing the read position.
| count | Number of bytes to peek; 0 peeks all available. |
| out | Destination writer. |
true on success, false on insufficient data or error. Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Non-destructive read into a DataType (advances logical position).
| count | Number of bytes to read; 0 reads all available. |
| out | Destination buffer. |
true on success, false on insufficient data or error. Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Non-destructive read into a WriteOnly (advances logical position).
| count | Number of bytes to read; 0 reads all available. |
| out | Destination writer. |
true on success, false on insufficient data or error. Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Read all remaining bytes until EoF into a DataType.
| out | Destination buffer. |
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Read all remaining bytes until EoF into a WriteOnly.
| out | Destination writer. |
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Move the logical read position for non-destructive reads.
| offset | Offset value. |
| mode | Position::Absolute or Position::Relative. |
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Total number of bytes stored in the shared Ring.
Implements StormByte::Buffer::ReadOnly.
|
friend |