Read-oriented handle over a shared Ring. More...
#include <StormByte/buffer/consumer.hxx>


Public Member Functions | |
Constructors / destructor / assignment | |
| Consumer () noexcept | |
| Empty Consumer. | |
| 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 | |
| StormByte::ByteSize | Available () const noexcept override |
| Number of bytes available for reading from the current position. | |
| const StormByte::BinaryData & | 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. | |
| StormByte::ByteSize | Size () const noexcept override |
| Total number of bytes stored in the shared Ring. | |
| class Producer | Producer () const noexcept |
| Writer on the same 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 StormByte::ByteSize &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 StormByte::ByteSize &count, StormByte::BinaryData &out) noexcept override |
| Extract bytes into a StormByte::BinaryData (consumes data from the Ring). | |
| bool | Extract (const StormByte::ByteSize &count, WriteOnly &out) noexcept override |
| Extract bytes into a WriteOnly store. | |
| void | ExtractUntilEoF (StormByte::BinaryData &out) noexcept override |
| Extract until EoF into a StormByte::BinaryData. | |
| void | ExtractUntilEoF (WriteOnly &out) noexcept override |
| Extract until EoF into a WriteOnly store. | |
Read (non-destructive) | |
| bool | Read (const StormByte::ByteSize &count, StormByte::BinaryData &out) const noexcept override |
| Read bytes into a StormByte::BinaryData. | |
| bool | Read (const StormByte::ByteSize &count, WriteOnly &out) const noexcept override |
| Read bytes into a WriteOnly store. | |
| void | ReadUntilEoF (StormByte::BinaryData &out) const noexcept override |
| Read until EoF into a StormByte::BinaryData. | |
| void | ReadUntilEoF (WriteOnly &out) const noexcept override |
| Read until EoF into a WriteOnly store. | |
Peek | |
| bool | Peek (const StormByte::ByteSize &count, StormByte::BinaryData &out) const noexcept override |
| Peek bytes into a StormByte::BinaryData. | |
| bool | Peek (const StormByte::ByteSize &count, WriteOnly &out) const noexcept override |
| Peek bytes into a WriteOnly store. | |
Public Member Functions inherited from StormByte::Buffer::ReadOnly | |
| ReadOnly () noexcept | |
| Default constructor. | |
| ReadOnly (const ReadOnly &other) noexcept=default | |
| Copy constructor. | |
| ReadOnly (ReadOnly &&other) noexcept=default | |
| Move constructor. | |
| virtual | ~ReadOnly () noexcept |
| Destructor. | |
| ReadOnly & | operator= (const ReadOnly &other)=default |
| Copy assignment. | |
| ReadOnly & | operator= (ReadOnly &&other) noexcept=default |
| Move assignment. | |
| bool | Extract (StormByte::BinaryData &outBuffer) noexcept |
| Extract all available bytes into a StormByte::BinaryData. | |
| bool | Extract (WriteOnly &outBuffer) noexcept |
| Extract all available bytes into a WriteOnly. | |
| bool | Read (StormByte::BinaryData &outBuffer) const noexcept |
| Read all available bytes into a StormByte::BinaryData. | |
| 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 constructor. | |
| Generic (const Generic &other) noexcept=default | |
| Copy constructor. | |
| Generic (Generic &&other) noexcept=default | |
| Move constructor. | |
| virtual | ~Generic () noexcept=0 |
| Pure virtual destructor. | |
| Generic & | operator= (const Generic &other)=default |
| Copy assignment. | |
| Generic & | operator= (Generic &&other) noexcept=default |
| Move assignment. | |
Friends | |
| class | Producer |
Additional Inherited Members | |
Static Protected Member Functions inherited from StormByte::Buffer::Generic | |
| template<Type::ByteInputRange Src> | |
| static BinaryData | DataConvert (const Src &src) noexcept |
| Convert an lvalue input range to StormByte::BinaryData. | |
| template<Type::ByteInputRange Src> | |
| static BinaryData | DataConvert (Src &&src) noexcept |
| Convert an rvalue input range to StormByte::BinaryData. | |
| static BinaryData | DataConvert (std::string_view sv) noexcept |
| Convert a string view to StormByte::BinaryData. | |
| static BinaryData | DataConvert (const char *s) noexcept |
| Convert a C string to StormByte::BinaryData. | |
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.
An empty Consumer (Consumer()) creates its own Ring. Producer() then returns a writer on that Ring. A Consumer may also be obtained from 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 |
Empty Consumer.
Creates a new shared Ring.
Producer() returns a writer on that Ring. Use this when the owner only reads and still needs a write tip for a Bridge.
|
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 Available() 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 StormByte::BinaryData (consumes data from the Ring).
| count | Number of bytes to extract; 0 extracts all available. |
| out | Destination (appended to). |
true on success. Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Extract bytes into a WriteOnly store.
| count | Number of bytes to extract; 0 extracts all available. |
| out | Destination. |
true on success. Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Extract until EoF into a StormByte::BinaryData.
| out | Destination. |
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Extract until EoF into a WriteOnly store.
| out | Destination. |
Implements StormByte::Buffer::ReadOnly.
|
inlinenoexcept |
Whether the shared Ring is in a permanent error state.
true after Producer::SetError on any handle to the same Ring.
|
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 StormByte::BinaryData.
Does not advance the cursor.
| count | Number of bytes to peek; 0 peeks all available. |
| out | Destination (appended to). |
true on success. Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Peek bytes into a WriteOnly store.
Does not advance the cursor.
| count | Number of bytes to peek; 0 peeks all available. |
| out | Destination. |
true on success. Implements StormByte::Buffer::ReadOnly.
|
noexcept |
Writer on the same Ring.
Inverse of Producer::Consumer. The Ring already exists (Consumer() or a Producer-born Consumer).
|
overridevirtualnoexcept |
Read bytes into a StormByte::BinaryData.
Advances the cursor.
| count | Number of bytes to read; 0 reads all available. |
| out | Destination (appended to). |
true on success. Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Read bytes into a WriteOnly store.
Advances the cursor.
| count | Number of bytes to read; 0 reads all available. |
| out | Destination. |
true on success. Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Read until EoF into a StormByte::BinaryData.
| out | Destination. |
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Read until EoF into a WriteOnly store.
| out | Destination. |
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::Generic.
|
friend |