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::ExternalWriter Class Referenceabstract

Abstract interface for writing data to an external or internal sink. More...

#include <StormByte/buffer/external.hxx>

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

Public Member Functions

Constructors / destructor / assignment
 ExternalWriter () noexcept=default
 
 ExternalWriter (const ExternalWriter &)=default
 
 ExternalWriter (ExternalWriter &&) noexcept=default
 
 ~ExternalWriter () noexcept override
 
ExternalWriteroperator= (const ExternalWriter &)=default
 
ExternalWriteroperator= (ExternalWriter &&) noexcept=default
 
Queries
virtual bool IsWritable () const noexcept=0
 Whether the sink still accepts writes.
 
Writing (canonical overloads)
virtual bool Write (const DataType &data) noexcept=0
 Write (copy) a full byte vector.
 
virtual bool Write (DataType &&data) noexcept=0
 Write (move) a full byte vector.
 
virtual bool Write (std::size_t count, const DataType &data) noexcept=0
 Write up to count bytes from a vector (copy).
 
virtual bool Write (std::size_t count, DataType &&data) noexcept=0
 Write up to count bytes from a vector (move).
 
Writing (string conveniences)

Non-virtual helpers implemented in terms of the canonical overloads.

These ensure std::string_view / C-string / string-literal calls bind to a stable API and avoid copying the trailing NUL of string literals.

bool Write (std::string_view sv) noexcept
 Write a string view (no terminating NUL).
 
bool Write (const char *s) noexcept
 Write a null-terminated C string.
 
bool Write (std::size_t count, std::string_view sv) noexcept
 Write up to count characters from a string view.
 
template<std::size_t N>
bool Write (const char(&s)[N]) noexcept
 Write a string literal without the trailing NUL.
 
End-of-stream signalling
virtual void Close () noexcept=0
 Mark the sink closed for further writes.
 
virtual void SetError () noexcept=0
 Put the sink into a permanent error state.
 

Detailed Description

Abstract interface for writing data to an external or internal sink.

Overview
Provides a buffer-agnostic writing API (including end-of-stream signalling) so that pipeline stages can write uniformly to any concrete destination (file, socket, Ring, LockFreeRing, Producer, etc.).
See also
ExternalBufferWriter, ExternalReader, Pipeline

Constructor & Destructor Documentation

◆ ExternalWriter() [1/3]

StormByte::Buffer::ExternalWriter::ExternalWriter ( )
defaultnoexcept

◆ ExternalWriter() [2/3]

StormByte::Buffer::ExternalWriter::ExternalWriter ( const ExternalWriter )
default

◆ ExternalWriter() [3/3]

StormByte::Buffer::ExternalWriter::ExternalWriter ( ExternalWriter &&  )
defaultnoexcept

◆ ~ExternalWriter()

StormByte::Buffer::ExternalWriter::~ExternalWriter ( )
overridenoexcept

Member Function Documentation

◆ Close()

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

Mark the sink closed for further writes.

Subsequent Write() calls must fail. Readers can still drain remaining data. Implementations should wake any waiting readers.

Implemented in StormByte::Buffer::ExternalBufferWriter.

◆ IsWritable()

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

Whether the sink still accepts writes.

Returns
false when the sink has been closed or is in error state.

Implemented in StormByte::Buffer::ExternalBufferWriter.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ SetError()

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

Put the sink into a permanent error state.

Makes the sink unreadable and unwritable from the buffer’s perspective. Implementations should wake any waiters.

Implemented in StormByte::Buffer::ExternalBufferWriter.

◆ Write() [1/8]

bool StormByte::Buffer::ExternalWriter::Write ( const char *  s)
noexcept

Write a null-terminated C string.

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

◆ Write() [2/8]

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

Write a string literal without the trailing NUL.

Template Parameters
NArray extent (includes the NUL for literals).
Parameters
sString literal / char array.
Returns
true on success, false if the sink is closed / in error.

◆ Write() [3/8]

virtual bool StormByte::Buffer::ExternalWriter::Write ( const DataType data)
pure virtualnoexcept

Write (copy) a full byte vector.

Parameters
dataData to append.
Returns
true on success, false if the sink is closed / in error.

Implemented in StormByte::Buffer::ExternalBufferWriter.

◆ Write() [4/8]

virtual bool StormByte::Buffer::ExternalWriter::Write ( DataType &&  data)
pure virtualnoexcept

Write (move) a full byte vector.

Parameters
dataData to append (emptied on success when the implementation moves).
Returns
true on success, false if the sink is closed / in error.

Implemented in StormByte::Buffer::ExternalBufferWriter.

◆ Write() [5/8]

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

Write up to count bytes from a vector (copy).

Parameters
countMaximum bytes to write (0 = entire vector).
dataSource vector.
Returns
true on success, false if the sink is closed / in error.

Implemented in StormByte::Buffer::ExternalBufferWriter.

◆ Write() [6/8]

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

Write up to count bytes from a vector (move).

Parameters
countMaximum bytes to write (0 = entire vector).
dataSource vector (may be modified on success).
Returns
true on success, false if the sink is closed / in error.

Implemented in StormByte::Buffer::ExternalBufferWriter.

◆ Write() [7/8]

bool StormByte::Buffer::ExternalWriter::Write ( std::size_t  count,
std::string_view  sv 
)
noexcept

Write up to count characters from a string view.

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

◆ Write() [8/8]

bool StormByte::Buffer::ExternalWriter::Write ( std::string_view  sv)
noexcept

Write a string view (no terminating NUL).

Parameters
svSource characters.
Returns
true on success, false if the sink is closed / in error.

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