|
SofaBuffers C/C++ 0.12.0
API Documentation
|
Decoder that decodes into a message instance the CALLER owns. More...
#include <sofab.hpp>
Public Member Functions | |
| IStreamInto (MessageType &message) noexcept | |
Bind message to this stream. | |
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 |
Decoder that decodes into a message instance the CALLER owns.
IStreamObject with the instance taken out: it binds the message handed to the constructor instead of holding one, so fed bytes are dispatched to that object's deserialize and nothing is staged and copied. The whole difference is where the message lives – same C-ABI field callback, same dispatch, no std::function – so it costs a pointer where IStreamObject costs a whole message, which on a heap-free target is the difference between one and two copies of it on the stack.
The bound object is written as the bytes arrive, so a rejected input leaves the fields decoded before the error in it. Put it back where it belongs first if that matters – generated code calls its reset() – and note that a field the bytes do not carry keeps whatever the object already held (MESSAGE_SPEC §2 omits an all-default field), which is the same reason.
The message must outlive the stream, and must not be bound to a second stream while this one is fed: binding is what the object's own callback context points at.
| MessageType | An InputMessage type. |
|
inlineexplicitnoexcept |