StormByte C++ Library: Buffer module 1.2.0
StormByte-Buffer is the buffer module of the StormByte C++ suite.
Loading...
Searching...
No Matches
List of all members
StormByte::Buffer::WriteOnly Class Referenceabstract

Pure interface for a buffer that can be written but not read. More...

#include <StormByte/buffer/generic.hxx>

Inheritance diagram for StormByte::Buffer::WriteOnly:
Inheritance graph
[legend]
Collaboration diagram for StormByte::Buffer::WriteOnly:
Collaboration graph
[legend]

Public Member Functions

Constructors / destructor / assignment
 WriteOnly () noexcept
 Default construct.
 
 WriteOnly (const WriteOnly &)=default
 Copy construct.
 
 WriteOnly (WriteOnly &&) noexcept=default
 Move construct.
 
virtual ~WriteOnly () noexcept
 Virtual destructor.
 
WriteOnlyoperator= (const WriteOnly &)=default
 Copy assign.
 
WriteOnlyoperator= (WriteOnly &&) noexcept=default
 Move assign.
 
Lifecycle / queries
virtual bool IsWritable () const noexcept=0
 Whether the buffer accepts writes.
 
virtual void Close () noexcept=0
 Mark the buffer closed for further writes.
 
virtual void SetError () noexcept=0
 Enter a permanent error state (unreadable and unwritable).
 
Write (canonical pure virtuals)
virtual bool Write (const std::size_t &count, const DataType &data) noexcept=0
 Append bytes from a DataType (copy).
 
virtual bool Write (const std::size_t &count, DataType &&data) noexcept=0
 Append bytes from a DataType (move).
 
virtual bool Write (const std::size_t &count, const ReadOnly &data) noexcept=0
 Append bytes from a ReadOnly (copy path).
 
virtual bool Write (const std::size_t &count, ReadOnly &&data) noexcept=0
 Append bytes from a ReadOnly (move / extract path).
 
Write (ReadOnly conveniences)
bool Write (const ReadOnly &data) noexcept
 Append all available bytes from a ReadOnly (copy).
 
bool Write (ReadOnly &&data) noexcept
 Append all available bytes from a ReadOnly (move path).
 
Write (string conveniences)

Stable overloads so string / C-string calls do not hit range templates.

String literals exclude the trailing NUL.

bool Write (std::string_view sv) noexcept
 Write a string view (no trailing NUL).
 
bool Write (const char *s) noexcept
 Write a null-terminated C string.
 
bool Write (const std::size_t &count, std::string_view sv) noexcept
 Write up to count characters from a string view.
 
bool Write (const std::size_t &count, const char *s) noexcept
 Write up to count characters from a C string.
 
template<std::size_t N>
bool Write (const char(&s)[N]) noexcept
 Write a string literal without the trailing NUL.
 
Write (range / iterator conveniences)
template<Type::ByteInputRange R>
bool Write (const R &r) noexcept
 Write all elements from an input range.
 
template<Type::ByteInputRange Rw>
bool Write (const std::size_t &count, const Rw &r) noexcept
 Write up to count elements from an input range.
 
template<Type::ByteInputRange Rrw>
bool Write (const std::size_t &count, Rrw &&r) noexcept
 Write up to count elements from an rvalue range.
 
template<Type::ByteInputRange Rr>
bool Write (Rr &&r) noexcept
 Write all elements from an rvalue range.
 
template<Type::ByteInputIterator I, typename S >
requires Type::SentinelFor<S, I>
bool Write (I first, S last) noexcept
 Write all elements from an iterator pair.
 
template<Type::ByteInputIterator I2, typename S2 >
requires Type::SentinelFor<S2, I2>
bool Write (const std::size_t &count, I2 first, S2 last) noexcept
 Write up to count elements from an iterator pair.
 
- 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).
 
Genericoperator= (const Generic &other)=default
 Copy assign.
 
Genericoperator= (Generic &&) noexcept=default
 Move assign.
 

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.
 

Detailed Description

Pure interface for a buffer that can be written but not read.

Declares lifecycle (Close / SetError), writability, and the canonical Write overloads. Convenience overloads for strings, ranges and iterators are implemented inline in terms of those.

See also
ReadOnly, ReadWrite, Generic

Constructor & Destructor Documentation

◆ WriteOnly() [1/3]

StormByte::Buffer::WriteOnly::WriteOnly ( )
inlinenoexcept

Default construct.

◆ WriteOnly() [2/3]

StormByte::Buffer::WriteOnly::WriteOnly ( const WriteOnly )
default

Copy construct.

◆ WriteOnly() [3/3]

StormByte::Buffer::WriteOnly::WriteOnly ( WriteOnly &&  )
defaultnoexcept

Move construct.

◆ ~WriteOnly()

virtual StormByte::Buffer::WriteOnly::~WriteOnly ( )
virtualnoexcept

Virtual destructor.

Member Function Documentation

◆ Close()

virtual void StormByte::Buffer::WriteOnly::Close ( )
pure virtualnoexcept

Mark the buffer closed for further writes.

Subsequent Write() calls must fail. Readers may still drain data. Thread-safe implementations should wake blocked waiters.

Implemented in StormByte::Buffer::FIFO, StormByte::Buffer::Producer, StormByte::Buffer::Ring, and StormByte::Buffer::SharedFIFO.

◆ IsWritable()

virtual bool StormByte::Buffer::WriteOnly::IsWritable ( ) const
pure virtualnoexcept

Whether the buffer accepts writes.

Returns
false if closed or in error state.

Implemented in StormByte::Buffer::FIFO, StormByte::Buffer::Producer, StormByte::Buffer::Ring, and StormByte::Buffer::SharedFIFO.

◆ operator=() [1/2]

WriteOnly & StormByte::Buffer::WriteOnly::operator= ( const WriteOnly )
default

Copy assign.

◆ operator=() [2/2]

WriteOnly & StormByte::Buffer::WriteOnly::operator= ( WriteOnly &&  )
defaultnoexcept

Move assign.

◆ SetError()

virtual void StormByte::Buffer::WriteOnly::SetError ( )
pure virtualnoexcept

Enter a permanent error state (unreadable and unwritable).

Implementations should wake any blocked waiters.

Implemented in StormByte::Buffer::FIFO, StormByte::Buffer::Producer, StormByte::Buffer::Ring, and StormByte::Buffer::SharedFIFO.

◆ Write() [1/17]

bool StormByte::Buffer::WriteOnly::Write ( const char *  s)
inlinenoexcept

Write a null-terminated C string.

Parameters
sSource (may be null → empty write).
Returns
true on success, false if closed / error.

◆ Write() [2/17]

template<std::size_t N>
bool StormByte::Buffer::WriteOnly::Write ( const char(&)  s[N])
inlinenoexcept

Write a string literal without the trailing NUL.

Template Parameters
NArray extent (includes NUL for literals).
Parameters
sLiteral / char array.
Returns
true on success, false if closed / error.

◆ Write() [3/17]

template<Type::ByteInputRange R>
bool StormByte::Buffer::WriteOnly::Write ( const R &  r)
inlinenoexcept

Write all elements from an input range.

Template Parameters
RRange whose value_type is convertible to std::byte.
Parameters
rSource range.
Returns
true on success, false if closed / error.

◆ Write() [4/17]

bool StormByte::Buffer::WriteOnly::Write ( const ReadOnly data)
inlinenoexcept

Append all available bytes from a ReadOnly (copy).

Parameters
dataSource buffer.
Returns
true on success, false if closed / error.

◆ Write() [5/17]

bool StormByte::Buffer::WriteOnly::Write ( const std::size_t &  count,
const char *  s 
)
inlinenoexcept

Write up to count characters from a C string.

Parameters
countMaximum characters (0 = entire string).
sSource (may be null).
Returns
true on success, false if closed / error.

◆ Write() [6/17]

virtual bool StormByte::Buffer::WriteOnly::Write ( const std::size_t &  count,
const DataType data 
)
pure virtualnoexcept

Append bytes from a DataType (copy).

Parameters
countNumber of bytes to write.
dataSource vector.
Returns
true on success, false if closed / error.
See also
IsWritable()

Implemented in StormByte::Buffer::FIFO, StormByte::Buffer::Producer, StormByte::Buffer::Ring, StormByte::Buffer::FIFO, StormByte::Buffer::Producer, and StormByte::Buffer::Ring.

◆ Write() [7/17]

virtual bool StormByte::Buffer::WriteOnly::Write ( const std::size_t &  count,
const ReadOnly data 
)
pure virtualnoexcept

Append bytes from a ReadOnly (copy path).

Parameters
countNumber of bytes to write.
dataSource buffer.
Returns
true on success, false if closed / error.
See also
IsWritable()

Implemented in StormByte::Buffer::FIFO, StormByte::Buffer::Producer, StormByte::Buffer::Ring, StormByte::Buffer::FIFO, StormByte::Buffer::Producer, and StormByte::Buffer::Ring.

◆ Write() [8/17]

template<Type::ByteInputRange Rw>
bool StormByte::Buffer::WriteOnly::Write ( const std::size_t &  count,
const Rw &  r 
)
inlinenoexcept

Write up to count elements from an input range.

Template Parameters
RwRange type.
Parameters
countMaximum elements (0 = entire range).
rSource range.
Returns
true on success, false if closed / error.

◆ Write() [9/17]

virtual bool StormByte::Buffer::WriteOnly::Write ( const std::size_t &  count,
DataType &&  data 
)
pure virtualnoexcept

Append bytes from a DataType (move).

Parameters
countNumber of bytes to write.
dataSource vector.
Returns
true on success, false if closed / error.
See also
IsWritable()

Implemented in StormByte::Buffer::FIFO, StormByte::Buffer::Producer, StormByte::Buffer::Ring, StormByte::Buffer::FIFO, StormByte::Buffer::Producer, and StormByte::Buffer::Ring.

◆ Write() [10/17]

template<Type::ByteInputIterator I2, typename S2 >
requires Type::SentinelFor<S2, I2>
bool StormByte::Buffer::WriteOnly::Write ( const std::size_t &  count,
I2  first,
S2  last 
)
inlinenoexcept

Write up to count elements from an iterator pair.

Template Parameters
I2Input iterator.
S2Sentinel for I2.
Parameters
countMaximum elements (0 = all).
firstBegin iterator.
lastEnd sentinel.
Returns
true on success, false if closed / error.

◆ Write() [11/17]

virtual bool StormByte::Buffer::WriteOnly::Write ( const std::size_t &  count,
ReadOnly &&  data 
)
pure virtualnoexcept

Append bytes from a ReadOnly (move / extract path).

Parameters
countNumber of bytes to write.
dataSource buffer.
Returns
true on success, false if closed / error.
See also
IsWritable()

Implemented in StormByte::Buffer::FIFO, StormByte::Buffer::Producer, StormByte::Buffer::Ring, StormByte::Buffer::FIFO, StormByte::Buffer::Producer, and StormByte::Buffer::Ring.

◆ Write() [12/17]

template<Type::ByteInputRange Rrw>
bool StormByte::Buffer::WriteOnly::Write ( const std::size_t &  count,
Rrw &&  r 
)
inlinenoexcept

Write up to count elements from an rvalue range.

Template Parameters
RrwRange type (may be DataType rvalue).
Parameters
countMaximum elements (0 = entire range).
rSource range (moved when DataType).
Returns
true on success, false if closed / error.

◆ Write() [13/17]

bool StormByte::Buffer::WriteOnly::Write ( const std::size_t &  count,
std::string_view  sv 
)
inlinenoexcept

Write up to count characters from a string view.

Parameters
countMaximum characters (0 = entire view).
svSource characters.
Returns
true on success, false if closed / error.

◆ Write() [14/17]

template<Type::ByteInputIterator I, typename S >
requires Type::SentinelFor<S, I>
bool StormByte::Buffer::WriteOnly::Write ( first,
last 
)
inlinenoexcept

Write all elements from an iterator pair.

Template Parameters
IInput iterator.
SSentinel for I.
Parameters
firstBegin iterator.
lastEnd sentinel.
Returns
true on success, false if closed / error.

◆ Write() [15/17]

bool StormByte::Buffer::WriteOnly::Write ( ReadOnly &&  data)
inlinenoexcept

Append all available bytes from a ReadOnly (move path).

Parameters
dataSource buffer.
Returns
true on success, false if closed / error.

◆ Write() [16/17]

template<Type::ByteInputRange Rr>
bool StormByte::Buffer::WriteOnly::Write ( Rr &&  r)
inlinenoexcept

Write all elements from an rvalue range.

Template Parameters
RrRange type.
Parameters
rSource (moved when DataType).
Returns
true on success, false if closed / error.

◆ Write() [17/17]

bool StormByte::Buffer::WriteOnly::Write ( std::string_view  sv)
inlinenoexcept

Write a string view (no trailing NUL).

Parameters
svSource characters.
Returns
true on success, false if closed / error.

The documentation for this class was generated from the following file: