SofaBuffers C/C++ 0.12.0
API Documentation
Loading...
Searching...
No Matches
sofab::OStreamImpl::Result Class Reference

Outcome of an encode operation, supporting fluent chaining. More...

#include <sofab.hpp>

Public Member Functions

template<typename T >
Result write (sofab_id_t id, const T &value) noexcept
 Chained write of a field (no-op if a prior call failed).
 
template<typename T >
Result writeIf (sofab_id_t id, const T &value, bool condition) noexcept
 Chained conditional write (no-op if a prior call failed).
 
template<typename T >
Result writeLazy (sofab_id_t id, const T &value) noexcept
 Chained nested-message field write that is omitted when the message is all-default (no-op if a prior call failed).
 
Result sequenceEndKeep () noexcept
 Chained frame-keeping sequence-end (no-op if a prior call failed).
 
Result sequenceBeginLazy (sofab_id_t id) noexcept
 Chained lazy sequence-begin (no-op if a prior call failed).
 
Result sequenceEnd () noexcept
 Chained sequence-end marker (no-op if a prior call failed).
 
 operator bool () const noexcept
 True if no error occurred (same as ok()).
 
bool operator== (Error e) const noexcept
 Compare the held error code to e.
 
bool operator!= (Error e) const noexcept
 Negated operator==().
 
bool ok () const noexcept
 True if the operation (and the chain so far) succeeded.
 
Error code () const noexcept
 The first Error encountered in the chain.
 

Friends

class OStreamImpl
 

Detailed Description

Outcome of an encode operation, supporting fluent chaining.

Returned by every OStreamImpl write/sequence call. The first error is sticky: once set, subsequent chained calls become no-ops and the original error is preserved, so a chain can be checked once at the end. Convertible to bool (true on success).

Definition at line 951 of file sofab.hpp.

Member Function Documentation

◆ code()

Error sofab::OStreamImpl::Result::code ( ) const
inlinenoexcept

The first Error encountered in the chain.

Definition at line 1129 of file sofab.hpp.

Here is the caller graph for this function:

◆ ok()

bool sofab::OStreamImpl::Result::ok ( ) const
inlinenoexcept

True if the operation (and the chain so far) succeeded.

Definition at line 1123 of file sofab.hpp.

◆ operator bool()

sofab::OStreamImpl::Result::operator bool ( ) const
inlineexplicitnoexcept

True if no error occurred (same as ok()).

Definition at line 1105 of file sofab.hpp.

Here is the call graph for this function:

◆ operator!=()

bool sofab::OStreamImpl::Result::operator!= ( Error  e) const
inlinenoexcept

Negated operator==().

Definition at line 1117 of file sofab.hpp.

Here is the call graph for this function:

◆ operator==()

bool sofab::OStreamImpl::Result::operator== ( Error  e) const
inlinenoexcept

Compare the held error code to e.

Definition at line 1111 of file sofab.hpp.

Here is the call graph for this function:

◆ sequenceBeginLazy()

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

Chained lazy sequence-begin (no-op if a prior call failed).

Parameters
idField identifier of the nested sequence.
Returns
This Result, carrying the first error encountered (if any).
See also
OStreamImpl::sequenceBeginLazy

Definition at line 1068 of file sofab.hpp.

Here is the call graph for this function:

◆ sequenceEnd()

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

Chained sequence-end marker (no-op if a prior call failed).

Returns
This Result, carrying the first error encountered (if any).

Definition at line 1088 of file sofab.hpp.

Here is the call graph for this function:

◆ sequenceEndKeep()

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

Chained frame-keeping sequence-end (no-op if a prior call failed).

Returns
This Result, carrying the first error encountered (if any).
See also
OStreamImpl::sequenceEndKeep

Definition at line 1046 of file sofab.hpp.

Here is the call graph for this function:

◆ write()

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

Chained write of a field (no-op if a prior call failed).

Parameters
idField identifier.
valueValue to encode; the wire type is deduced from T.
Returns
This Result, carrying the first error encountered (if any).

Definition at line 976 of file sofab.hpp.

Here is the call graph for this function:

◆ writeIf()

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

Chained conditional write (no-op if a prior call failed).

Parameters
idField identifier.
valueValue to encode; the wire type is deduced from T.
conditionWrite the field only when true.
Returns
This Result, carrying the first error encountered (if any).

Definition at line 1000 of file sofab.hpp.

Here is the call graph for this function:

◆ writeLazy()

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

Chained nested-message field write that is omitted when the message is all-default (no-op if a prior call failed).

Parameters
idField identifier.
valueNested message to encode.
Returns
This Result, carrying the first error encountered (if any).
See also
OStreamImpl::writeLazy

Definition at line 1025 of file sofab.hpp.

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ OStreamImpl

Definition at line 957 of file sofab.hpp.


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