SofaBuffers C++ 0.12.0
Pure-C++20 SofaBuffers — API Documentation
Loading...
Searching...
No Matches
sofab::OStreamImpl::Result Class Reference

Chainable result of a write operation. More...

#include <sofab.hpp>

Public Member Functions

template<typename T >
Result write (sofab::id fieldId, const T &value) noexcept
 Chain another field write onto the same stream.
 
template<typename T >
Result writeIf (sofab::id fieldId, const T &value, bool condition) noexcept
 Chain a field write that only happens when condition holds.
 
template<typename T >
Result writeLazy (sofab::id fieldId, const T &value) noexcept
 Chain a nested-message field write that is omitted when the message is all-default (OStreamImpl::writeLazy).
 
Result sequenceEndKeep () noexcept
 Chain a frame-keeping close (OStreamImpl::sequenceEndKeep).
 
Result sequenceBeginLazy (sofab::id fieldId) noexcept
 Chain the opening of a nested sub-message that is framed only if it turns out to have content (OStreamImpl::sequenceBeginLazy).
 
Result sequenceEnd () noexcept
 Chain the closing of the current nested sub-message.
 
 operator bool () const noexcept
 
bool ok () const noexcept
 
Error code () const noexcept
 
bool operator== (Error e) const noexcept
 
bool operator!= (Error e) const noexcept
 

Friends

class OStreamImpl
 

Detailed Description

Chainable result of a write operation.

Each chained call is a no-op once an error has been latched, so a sequence of writes can be expressed fluently and the first failure inspected at the end via ok / code.

Definition at line 2030 of file sofab.hpp.

Member Function Documentation

◆ code()

Error sofab::OStreamImpl::Result::code ( ) const
inlinenoexcept
Returns
The latched status code (Error::None if all writes succeeded).

Definition at line 2113 of file sofab.hpp.

◆ ok()

bool sofab::OStreamImpl::Result::ok ( ) const
inlinenoexcept
Returns
true if no error has been latched.

Definition at line 2111 of file sofab.hpp.

◆ operator bool()

sofab::OStreamImpl::Result::operator bool ( ) const
inlineexplicitnoexcept
Returns
true if no error has been latched.

Definition at line 2109 of file sofab.hpp.

◆ operator!=()

bool sofab::OStreamImpl::Result::operator!= ( Error  e) const
inlinenoexcept
Returns
true if the latched code differs from e.

Definition at line 2117 of file sofab.hpp.

◆ operator==()

bool sofab::OStreamImpl::Result::operator== ( Error  e) const
inlinenoexcept
Returns
true if the latched code equals e.

Definition at line 2115 of file sofab.hpp.

◆ sequenceBeginLazy()

Result sofab::OStreamImpl::Result::sequenceBeginLazy ( sofab::id  fieldId)
inlinenoexcept

Chain the opening of a nested sub-message that is framed only if it turns out to have content (OStreamImpl::sequenceBeginLazy).

Parameters
fieldIdField identifier of the sub-message.
Returns
*this, for further chaining.

Definition at line 2094 of file sofab.hpp.

◆ sequenceEnd()

Result sofab::OStreamImpl::Result::sequenceEnd ( )
inlinenoexcept

Chain the closing of the current nested sub-message.

Returns
*this, for further chaining.

Definition at line 2103 of file sofab.hpp.

◆ sequenceEndKeep()

Result sofab::OStreamImpl::Result::sequenceEndKeep ( )
inlinenoexcept

Chain a frame-keeping close (OStreamImpl::sequenceEndKeep).

Returns
*this, for further chaining.

Definition at line 2082 of file sofab.hpp.

◆ write()

template<typename T >
Result sofab::OStreamImpl::Result::write ( sofab::id  fieldId,
const T &  value 
)
inlinenoexcept

Chain another field write onto the same stream.

Template Parameters
TValue type accepted by OStreamImpl::write.
Parameters
fieldIdField identifier.
valueValue to encode.
Returns
*this, for further chaining.

Definition at line 2046 of file sofab.hpp.

◆ writeIf()

template<typename T >
Result sofab::OStreamImpl::Result::writeIf ( sofab::id  fieldId,
const T &  value,
bool  condition 
)
inlinenoexcept

Chain a field write that only happens when condition holds.

Template Parameters
TValue type accepted by OStreamImpl::write.
Parameters
fieldIdField identifier.
valueValue to encode when condition is true.
conditionWrite the field only if this is true.
Returns
*this, for further chaining.

Definition at line 2060 of file sofab.hpp.

◆ writeLazy()

template<typename T >
Result sofab::OStreamImpl::Result::writeLazy ( sofab::id  fieldId,
const T &  value 
)
inlinenoexcept

Chain a nested-message field write that is omitted when the message is all-default (OStreamImpl::writeLazy).

Parameters
fieldIdField identifier of the sub-message.
valueNested message to encode.
Returns
*this, for further chaining.

Definition at line 2073 of file sofab.hpp.

Friends And Related Symbol Documentation

◆ OStreamImpl

friend class OStreamImpl
friend

Definition at line 2034 of file sofab.hpp.


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