44#include <StormByte/type_traits/safe.hxx>
48#include <StormByte/safe/condition_variable_any.hxx>
49#include <StormByte/safe/deque.hxx>
50#include <StormByte/safe/exclusive_lock.hxx>
51#include <StormByte/safe/shared_mutex.hxx>
52#include <StormByte/safe/string.hxx>
119 template<
Type::ByteInputRange R>
121 inline explicit
Ring(const R& r) noexcept
129 template<Type::ByteInputRange Rr>
130 inline explicit Ring(Rr&& r) noexcept
137 explicit Ring(std::string_view sv)
noexcept;
143 inline explicit Ring(
const char* s) noexcept
144 :
Ring(s ? std::string_view(s) : std::string_view{}) {}
188 bool operator==(const
Ring& other) const noexcept;
195 inline
bool operator!=(const
Ring& other) const noexcept {
196 return !(*
this == other);
224 bool Empty() const noexcept override;
230 bool EoF() const noexcept override;
294 void Seek(const
std::ptrdiff_t& offset, const
Position& mode) const noexcept override;
555 bool m_closed{
false};
static STORMBYTE_FORCE_INLINE Safe::Binary DataConvert(const Src &src) noexcept
Convert an lvalue input range to StormByte::Safe::Binary.
Definition generic.hxx:156
Buffer that can be read and not written.
Definition generic.hxx:220
ReadWrite() noexcept
Default constructor.
Highly concurrent thread-safe ring buffer.
Definition ring.hxx:90
virtual ~Ring() noexcept
Destroy the Ring.
bool Read(const StormByte::ByteSize &count, StormByte::Safe::Binary &outBuffer) const noexcept override
Read into owned storage and advance the position.
bool Empty() const noexcept override
Whether the underlying storage is empty.
bool Peek(const StormByte::ByteSize &count, StormByte::Safe::Binary &outBuffer) const noexcept override
Peek into owned storage without advancing the position.
void Seek(const std::ptrdiff_t &offset, const Position &mode) const noexcept override
Move the logical read position.
void Clean() noexcept override
Discard data from the start up to the current read position.
Ring(Ring &&other) noexcept
Take a Ring.
StormByte::Safe::String HexDump(const StormByte::ByteSize &columns=16, const StormByte::ByteSize &byte_limit=0) const noexcept
Hexdump of unread contents from the current read position.
void Close() noexcept override
Close the buffer for further writes and notify waiters.
virtual void ReadUntilEoFInternal(StormByte::Safe::Binary &outBuffer, Operation flag) noexcept
Drain until EoF into owned storage.
bool Write(const StormByte::ByteSize &count, const StormByte::Safe::Binary &data) noexcept override
Append bytes from owned storage (copy).
Ring(const Ring &)=delete
Copy constructor.
StormByte::ByteSize Size() const noexcept override
Total number of bytes stored.
Ring(const char *s) noexcept
Construct from a C string.
Definition ring.hxx:143
bool EoF() const noexcept override
End-of-stream condition.
bool IsWritable() const noexcept override
Whether the buffer accepts writes.
void ExtractUntilEoF(StormByte::Safe::Binary &outBuffer) noexcept override
Extract until EoF into owned storage.
virtual bool WriteInternal(const StormByte::ByteSize &count, const StormByte::Safe::Binary &src) noexcept
Append from owned storage (copy).
void Clear() noexcept override
Clear stored bytes and reset the read position.
bool HasError() const noexcept
Whether SetError() has been called.
StormByte::ByteSize Available() const noexcept override
Bytes available from the current read position.
Ring(Rr &&r) noexcept
Convert an rvalue range and delegate construction to the provider.
Definition ring.hxx:130
bool Extract(const StormByte::ByteSize &count, StormByte::Safe::Binary &outBuffer) noexcept override
Extract bytes into owned storage.
bool IsReadable() const noexcept override
Whether the buffer can still be read.
static StormByte::Safe::String FormatHexLines(std::span< const std::byte > data, StormByte::ByteSize start_offset, StormByte::ByteSize columns) noexcept
Format hex/ASCII lines for a data span.
void ReadUntilEoF(StormByte::Safe::Binary &outBuffer) const noexcept override
Read until EoF into owned storage.
void SetError() noexcept override
Enter the permanent error state and notify waiters.
const StormByte::Safe::Binary & Data() const noexcept override
Snapshot of stored data.
virtual StormByte::Safe::String HexDumpHeader() const noexcept
Build the hexdump header.
bool Drop(const StormByte::ByteSize &count) noexcept override
Discard unread bytes.
virtual bool ReadInternal(const StormByte::ByteSize &count, StormByte::Safe::Binary &outBuffer, Operation flag) noexcept
Shared Extract, Read and Peek into owned storage.
Ring(std::string_view sv) noexcept
Construct from a string view.
Operation
Kind of internal read operation.
Definition ring.hxx:472
Ring() noexcept
Construct an empty Ring.
Buffer that can be written and not read.
Definition generic.hxx:497
STORMBYTE_DECLARE_MAYBE_SAFE(class StormByte::System::Device::Access)
Buffer module of the StormByte suite.
Position
Forward declaration of the WriteOnly interface.
Definition typedefs.hxx:74
Root namespace of the StormByte C++ suite.
#define STORMBYTE_BUFFER_PUBLIC
Definition visibility.h:54