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

Input stream driven by a user-supplied per-field callback. More...

#include <sofab.hpp>

Inheritance diagram for sofab::IStreamInline:
[legend]
Collaboration diagram for sofab::IStreamInline:
[legend]

Public Types

using fieldCallback = void(*)(sofab::id _id, size_t _size, size_t _count)
 Per-field callback signature: (field id, value size, element count).
 

Public Member Functions

 IStreamInline (fieldCallback callback) noexcept
 Construct with the per-field callback.
 
- Public Member Functions inherited from sofab::IStreamImpl
 IStreamImpl (const IStreamImpl &)=delete
 Copy construction is deleted (the context owns raw pointers).
 
IStreamImpl & operator= (const IStreamImpl &)=delete
 Copy assignment is deleted (the context owns raw pointers).
 
 IStreamImpl (IStreamImpl &&) noexcept=default
 Move construction (transfers the underlying context).
 
IStreamImpl & operator= (IStreamImpl &&) noexcept=default
 Move assignment (transfers the underlying context).
 
Result feed (const uint8_t *buffer, size_t buflen) noexcept
 Feed raw encoded bytes to the decoder.
 
void invalidate () noexcept
 Reject the message in progress as malformed, from within a field callback (§6.3's first tier).
 
void exceedLimit () noexcept
 Reject the message because a configured receiver limit was exceeded (§6.3's second tier, §6.2.1).
 
void refuseArgument () noexcept
 Reject the message because the destination this caller handed over cannot hold the value (§6.3's third tier, §6.6.3).
 
bool refuse (size_t n, long room) noexcept
 Refuse an announced length or element count the caller's own destination cannot hold.
 
bool refuseSchema (size_t n, long schemaBound) noexcept
 §6.3's first tier: the bound the schema declares.
 
bool refuseCap (size_t n, size_t dynCap) noexcept
 §6.3's second tier: the receiver cap on a schema-unbounded field (§6.2.1).
 
bool refuseUnbounded (long schemaBound, long room) noexcept
 Refuse a read that was given no ceiling of any kind.
 
bool refuseBound (size_t n, long schemaBound, DynCap dynCap) noexcept
 The two message-side refusals of §6.3 in one call, in the order §6.2.1 fixes: the schema first, the receiver cap only where the schema declared nothing — and a diagnosis where neither was stated.
 
Wire wire () const noexcept
 Wire type of the field currently being delivered.
 
Fix fixType () const noexcept
 Fixlen sub-type of the field currently being delivered.
 
bool delivered (Wire w) const noexcept
 Whether the field currently being delivered has wire type w.
 
bool delivered (Wire w, Fix f) const noexcept
 Whether the field currently being delivered has wire type w and fixlen subtype f.
 
template<typename T >
bool readMatch (T &value) noexcept
 read for a scalar, reporting whether the field will be decoded into value.
 
template<typename T >
void read (T &value) noexcept
 Bind the current field to a typed destination, deducing the wire type from T.
 
size_t read (void *dst, size_t maxlen) noexcept
 Decode a blob field into a caller-owned, address-stable buffer.
 
template<typename T >
void readString (T &value, size_t size, long maxlen=-1) noexcept
 Bind a string field, sizing the destination first.
 
template<typename Select , std::enable_if_t< std::is_invocable_v< Select & >, int > = 0>
void readString (Select &&select, size_t size, long maxlen=-1) noexcept
 readString into a destination that comes into existence only once the field matched: select is called behind the §7.3 test and the two refusals, and returns the destination.
 
template<typename T >
void readStringCapped (T &value, size_t size, size_t dynCap) noexcept
 readString for a schema-unbounded string, bounded by the receiver cap the caller supplies (§6.2.1).
 
template<typename T >
void readBlob (T &value, size_t size, long maxlen=-1) noexcept
 Bind a blob field, sizing the destination first.
 
template<typename Select , std::enable_if_t< std::is_invocable_v< Select & >, int > = 0>
void readBlob (Select &&select, size_t size, long maxlen=-1) noexcept
 readBlob into a destination that comes into existence only once the field matched – the blob counterpart of the selecting readString overload, for a tagged union's blob option.
 
template<typename T >
void readBlobCapped (T &value, size_t size, size_t dynCap) noexcept
 readBlob for a schema-unbounded blob, bounded by the receiver cap the caller supplies (§6.2.1).
 
template<typename C >
void readArray (C &out, size_t wireCount=0, long cap=-1) noexcept
 Bind a native scalar array, preparing the destination first.
 
template<typename Select , std::enable_if_t< std::is_invocable_v< Select & >, int > = 0>
void readArray (Select &&select, size_t wireCount=0, long cap=-1) noexcept
 readArray into a destination that comes into existence only once the field matched: select is called behind the §7.3 test and returns the destination – the array counterpart of the selecting readString overload, for a tagged union's array option.
 
template<typename C >
void readArrayCapped (C &out, size_t wireCount, size_t dynCap) noexcept
 readArray for a schema-unbounded array, bounded by the receiver cap the caller supplies (§6.2.1).
 
template<typename C , typename Out >
void readSequence (C &collector, Out &out) noexcept
 Bind a wrapper-array field through a collector, clearing the destination first.
 
template<typename C , typename Select , std::enable_if_t< std::is_invocable_v< Select & >, int > = 0>
void readSequence (C &collector, Select &&select) noexcept
 readSequence into a destination that comes into existence only once the field matched: select is called behind the §7.3 test and returns the destination – for a tagged union's wrapper-array option.
 

Additional Inherited Members

- Protected Member Functions inherited from sofab::IStreamImpl
 IStreamImpl () noexcept=default
 
void latchRefusal_ (sofab_ret_t category) noexcept
 
void resetRefusal_ () noexcept
 Clear a latched refusal, for a subclass that re-initialises the stream itself.
 
void noteSkip_ () noexcept
 
bool bindMatch_ (void *var, size_t len, uint8_t opt) noexcept
 
template<typename T >
void bindString_ (T &value, size_t size) noexcept
 
template<typename T >
void bindBlob_ (T &value, size_t size) noexcept
 
template<typename C >
bool arrayTagOk_ () noexcept
 
template<typename C >
void bindArray_ (C &out, size_t wireCount, long room) noexcept
 
- Static Protected Member Functions inherited from sofab::IStreamImpl
template<typename C >
static long arrayRoom_ (C &out, size_t wireCount) noexcept
 
- Protected Attributes inherited from sofab::IStreamImpl
sofab_istream_t ctx_
 Underlying C input stream context.
 
sofab_istream_decoder_t arrayDecoder_
 
uint8_t refusal_ = SOFAB_RET_OK
 

Detailed Description

Input stream driven by a user-supplied per-field callback.

The callback receives each decoded field's id, size and element count, and binds a destination by calling one of the IStreamImpl::read() overloads for the fields it is interested in; unhandled fields are skipped.

Definition at line 3519 of file sofab.hpp.

Member Typedef Documentation

◆ fieldCallback

Per-field callback signature: (field id, value size, element count).

As with OStreamImpl::flushCallback, a std::function hosted and a plain function pointer freestanding.

Definition at line 3529 of file sofab.hpp.

Constructor & Destructor Documentation

◆ IStreamInline()

sofab::IStreamInline::IStreamInline ( fieldCallback  callback)
inlinenoexcept

Construct with the per-field callback.

Parameters
callbackInvoked for each decoded field to bind a destination.

Definition at line 3550 of file sofab.hpp.

Here is the call graph for this function:

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