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


Public Member Functions | |
Constructors / destructor / assignment | |
| Consumer () | |
| Create a Consumer and a new shared Ring. | |
| Consumer (const Consumer &other) | |
| Copy a Consumer. | |
| Consumer (Consumer &&other) noexcept | |
| Take a Consumer. | |
| ~Consumer () noexcept override | |
| Destroy the Consumer. | |
| Consumer & | operator= (const Consumer &other) |
| Copy-assign a Consumer. | |
| Consumer & | operator= (Consumer &&other) noexcept |
| Move-assign a Consumer. | |
Comparison | |
| bool | operator== (const Consumer &other) const noexcept |
| Compare two Consumers. | |
| bool | operator!= (const Consumer &other) const noexcept |
| Compare two Consumers. | |
Queries | |
| StormByte::ByteSize | Available () const noexcept override |
| Bytes available from the current position. | |
| const StormByte::Safe::Binary & | Data () const noexcept override |
| Snapshot of the underlying data. | |
| 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 |
| Writer on the same Ring. | |
Maintenance / lifecycle | |
| void | Clean () noexcept override |
| Discard already-consumed data up to the read position. | |
| void | Clear () noexcept override |
| Clear stored bytes. | |
| void | Close () noexcept |
| Close the shared Ring for further writes. | |
| bool | Drop (const StormByte::ByteSize &count) noexcept override |
| Discard bytes from the current read position. | |
| void | Seek (const std::ptrdiff_t &offset, const Position &mode) const noexcept override |
| Move the logical read position. | |
Extract (destructive read) | |
| bool | Extract (const StormByte::ByteSize &count, StormByte::Safe::Binary &out) noexcept override |
| Extract bytes into owned storage. | |
| bool | Extract (const StormByte::ByteSize &count, WriteOnly &out) noexcept override |
| Extract bytes into a writer. | |
| void | ExtractUntilEoF (StormByte::Safe::Binary &out) noexcept override |
| Extract until EoF into owned storage. | |
| void | ExtractUntilEoF (WriteOnly &out) noexcept override |
| Extract until EoF into a writer. | |
Read (non-destructive) | |
| bool | Read (const StormByte::ByteSize &count, StormByte::Safe::Binary &out) const noexcept override |
| Read into owned storage and advance the cursor. | |
| bool | Read (const StormByte::ByteSize &count, WriteOnly &out) const noexcept override |
| Read into a writer and advance the cursor. | |
| void | ReadUntilEoF (StormByte::Safe::Binary &out) const noexcept override |
| Read until EoF into owned storage. | |
| void | ReadUntilEoF (WriteOnly &out) const noexcept override |
| Read until EoF into a writer. | |
Peek | |
| bool | Peek (const StormByte::ByteSize &count, StormByte::Safe::Binary &out) const noexcept override |
| Peek into owned storage. | |
| bool | Peek (const StormByte::ByteSize &count, WriteOnly &out) const noexcept override |
| Peek into a writer. | |
| Public Member Functions inherited from StormByte::Buffer::ReadOnly | |
| ReadOnly () noexcept | |
| Default constructor. | |
| ReadOnly (const ReadOnly &other) noexcept | |
| Copy constructor. | |
| ReadOnly (ReadOnly &&other) noexcept | |
| Move constructor. | |
| virtual | ~ReadOnly () noexcept |
| Destructor. | |
| ReadOnly & | operator= (const ReadOnly &other) noexcept |
| Copy assignment. | |
| ReadOnly & | operator= (ReadOnly &&other) noexcept |
| Move assignment. | |
| bool | Extract (StormByte::Safe::Binary &outBuffer) noexcept |
| Extract all available bytes into a StormByte::Safe::Binary. | |
| bool | Extract (WriteOnly &outBuffer) noexcept |
| Extract all available bytes into a WriteOnly. | |
| bool | Read (StormByte::Safe::Binary &outBuffer) const noexcept |
| Read all available bytes into a StormByte::Safe::Binary. | |
| bool | Read (WriteOnly &outBuffer) const noexcept |
| Read all available bytes into a WriteOnly. | |
| Public Member Functions inherited from StormByte::Buffer::Generic | |
| Generic () noexcept | |
| Default constructor. | |
| Generic (const Generic &other) noexcept | |
| Copy constructor. | |
| Generic (Generic &&other) noexcept | |
| Move constructor. | |
| virtual | ~Generic () noexcept=0 |
| Pure virtual destructor. | |
| Generic & | operator= (const Generic &other) noexcept |
| Copy assignment. | |
| Generic & | operator= (Generic &&other) noexcept |
| Move assignment. | |
Friends | |
| class | Producer |
Additional Inherited Members | |
| Static Protected Member Functions inherited from StormByte::Buffer::Generic | |
| template<Type::ByteInputRange Src> | |
| static STORMBYTE_FORCE_INLINE Safe::Binary | DataConvert (const Src &src) noexcept |
| Convert an lvalue input range to StormByte::Safe::Binary. | |
| template<Type::ByteInputRange Src> | |
| static STORMBYTE_FORCE_INLINE Safe::Binary | DataConvert (Src &&src) noexcept |
| Convert an rvalue input range to StormByte::Safe::Binary. | |
| static Safe::Binary | DataConvert (std::string_view sv) noexcept |
| Convert a string view to StormByte::Safe::Binary. | |
| static Safe::Binary | DataConvert (const char *s) noexcept |
| Convert a C string to StormByte::Safe::Binary. | |
Read-oriented handle over a shared Ring.
Several Consumer instances may share the same Ring. An empty Consumer creates its own Ring. Producer() then returns a writer on that Ring. A Consumer may also come from Producer::Consumer().
All operations are thread-safe and delegate to the shared Ring. Ring ownership is held by StormByte::Safe::Owner. Blocking semantics match Ring.
Consumer is a ReadOnly view and also exposes Close(), IsWritable() and HasError() so a reader can observe the shared lifecycle.
| StormByte::Buffer::Consumer::Consumer | ( | ) |
Create a Consumer and a new shared Ring.
| StormByte::Safe::AllocationError | Ring ownership cannot be allocated. |
| StormByte::Buffer::Consumer::Consumer | ( | const Consumer & | other | ) |
Copy a Consumer.
Both share the same Ring.
| other | Source. |
| StormByte::Exception | The shared owner cannot be retained. |
|
noexcept |
|
overridenoexcept |
Destroy the Consumer.
|
overridevirtualnoexcept |
Bytes available from the current position.
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Discard already-consumed data up to the read position.
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Clear stored bytes.
Does not clear closed or error flags on the shared Ring.
Implements StormByte::Buffer::ReadOnly.
|
inlinenoexcept |
Close the shared Ring for further writes.
Same effect as Producer::Close on this Ring. Readers may still drain.
|
overridevirtualnoexcept |
Snapshot of the underlying data.
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Discard bytes from the current read position.
| count | Bytes to drop. |
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Whether the shared Ring holds no stored bytes.
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
End-of-stream condition.
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Extract bytes into owned storage.
| count | Bytes to extract. 0 means all available. |
| out | Destination. Appended to. |
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Extract bytes into a writer.
| count | Bytes to extract. 0 means all available. |
| out | Destination. |
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Extract until EoF into owned storage.
| out | Destination. |
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
|
inlinenoexcept |
|
overridevirtualnoexcept |
Whether the shared Ring can still be read.
Implements StormByte::Buffer::ReadOnly.
|
inlinenoexcept |
Whether the shared Ring still accepts writes.
|
inlinenoexcept |
Copy-assign a Consumer.
Both share the same Ring afterwards.
| other | Source. |
| StormByte::Exception | The shared owner cannot be retained. |
|
noexcept |
|
overridevirtualnoexcept |
Peek into owned storage.
Does not advance the cursor.
| count | Bytes to peek. 0 means all available. |
| out | Destination. Appended to. |
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Peek into a writer.
Does not advance the cursor.
| count | Bytes to peek. 0 means all available. |
| out | Destination. |
Implements StormByte::Buffer::ReadOnly.
| class Producer StormByte::Buffer::Consumer::Producer | ( | ) | const |
|
overridevirtualnoexcept |
Read into owned storage and advance the cursor.
| count | Bytes to read. 0 means all available. |
| out | Destination. Appended to. |
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Read into a writer and advance the cursor.
| count | Bytes to read. 0 means all available. |
| out | Destination. |
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Read until EoF into owned storage.
| out | Destination. |
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
|
overridevirtualnoexcept |
Move the logical read position.
| offset | Offset. |
| mode | Absolute or relative. |
Implements StormByte::Buffer::ReadOnly.
|
overridevirtualnoexcept |
Total number of bytes stored in the shared Ring.
Implements StormByte::Buffer::Generic.
|
friend |