|
SofaBuffers C++ 0.12.0
Pure-C++20 SofaBuffers — API Documentation
|
Base of the input streams: decodes fields from fed bytes. More...
#include <sofab.hpp>
Classes | |
| struct | FieldCb |
Decode fields at the current nesting level, firing cb for each. More... | |
| class | Result |
| Three-valued outcome of a feed call (spec §7). More... | |
Public Member Functions | |
| IStreamImpl (const IStreamImpl &)=delete | |
| IStreamImpl & | operator= (const IStreamImpl &)=delete |
| IStreamImpl (IStreamImpl &&) noexcept=default | |
| IStreamImpl & | operator= (IStreamImpl &&) noexcept=default |
| virtual | ~IStreamImpl ()=default |
| Result | feed (const uint8_t *buffer, size_t buflen) noexcept |
| Feed bytes into the decoder, delivering every complete top-level field. | |
| virtual void | reset () noexcept |
| Drop every byte of decoder state, so the next feed starts a brand-new message. | |
| void | invalidate () noexcept |
| Mark the running decode INVALID from inside a deliver callback. | |
| void | exceedLimit () noexcept |
| Report a receiver-side decode-limit violation from inside a deliver callback. | |
| void | rejectDestination () noexcept |
| Refuse the current field because the caller's destination is too short for it (§6.3's third refusal tier, §6.6.3). | |
| void | rejectUnbounded () noexcept |
Refuse the current field because the call stated no bound for it at all (§6.3's InvalidArgument). | |
| void | rejectElementIndex (sofab::id bad) noexcept |
| Refuse a wrapper-array element whose index is at or past a bound, in the category §6.3 gives that bound. | |
| size_t | skipped () const noexcept |
| Number of fields skipped this stream because their wire tag contradicted the type the callback asked for (MESSAGE_SPEC §7.3). | |
| template<typename T > | |
| bool | read (T &value) noexcept |
Read the current field's value, dispatching on value's type. | |
| template<typename S , typename Sizer = detail::NoSizer> | |
| bool | readString (S &value, long bound, Sizer sizer={}) noexcept |
Read the current field as a string, or skip it (§7.3). | |
| template<typename S , typename Sizer = detail::NoSizer> | |
| bool | readStringCapped (S &value, long dynCap, Sizer sizer={}) noexcept |
Read the current field as a schema-**unbounded** string under the receiver's max_dyn_string_len (§6.2.1). | |
| template<typename B , typename Sizer = detail::NoSizer> | |
| bool | readBlob (B &value, long bound, Sizer sizer={}) noexcept |
Read the current field as a blob, or skip it (§7.3). | |
| template<typename B , typename Sizer = detail::NoSizer> | |
| bool | readBlobCapped (B &value, long dynCap, Sizer sizer={}) noexcept |
Read the current field as a schema-**unbounded** blob under the receiver's max_dyn_blob_len (§6.2.1). | |
| template<typename T , typename Sizer = detail::NoSizer> | |
| bool | readArray (T &dst, long schemaCount, ElemBound elem={}, Sizer sizer={}) noexcept |
| Read a count-prefixed native array, applying every receiver-side decision at the one word that decides it. | |
| template<typename T , typename Sizer = detail::NoSizer> | |
| bool | readArrayCapped (T &dst, long dynCap, ElemBound elem={}, Sizer sizer={}) noexcept |
Read a schema-**unbounded** count-prefixed array under the receiver's max_dyn_array_count (§6.2.1). | |
| size_t | read (void *dst, size_t maxlen) noexcept |
| Read the current blob field into a caller buffer. | |
| bool | consumed () const noexcept |
| 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. | |
| size_t | announcedSize () const noexcept |
The payload length the current field's header announces — a string/blob byte count, or a fixlen array's element width. | |
| size_t | announcedCount () const noexcept |
| The element count the current array field's header announces. | |
| size_t | available () const noexcept |
| Bytes of this field readable right now, in the chunk being parsed. | |
| size_t | progress () const noexcept |
| How much of the current field earlier chunks already delivered — payload bytes written, or array elements decoded. | |
| bool | resumed () const noexcept |
true when this delivery re-enters a sequence an earlier feed left open, rather than announcing a new field. | |
| bool | acceptsString (long bound) noexcept |
| The §7.3 and §7.1 decisions readString makes, taken before a destination exists. | |
| bool | acceptsStringCapped (long dynCap) noexcept |
acceptsString for a schema-unbounded element, under the receiver's max_dyn_string_len (§6.2.1). | |
| bool | acceptsBlob (long bound) noexcept |
| The §7.3 and §7.1 decisions readString makes, taken before a destination exists. | |
| bool | acceptsBlobCapped (long dynCap) noexcept |
acceptsString for a schema-unbounded element, under the receiver's max_dyn_string_len (§6.2.1). | |
Protected Types | |
| enum class | Entry : uint8_t { Fresh , Descend , Resume } |
| How a level is being entered (see levelEntry). More... | |
| enum class | Field : uint8_t { Ready , SkipElem , Stop } |
| What beginField found at this level's next field. More... | |
Protected Member Functions | |
| IStreamImpl (Limits limits) noexcept | |
| Construct with the receiver's Limits; a derived class installs topCallback_. | |
| bool | tagMatches (Wire wantWire) noexcept |
| The §7.3 seam: does the delivered field's wire tag match the one the caller's read declares? | |
| bool | tagMatches (Wire wantWire, Fix wantFix) noexcept |
| bool | tagMatches (Wire wantWire, Fix wantFix, Fix wantFix2) noexcept |
| template<typename D > | |
| bool | readPayload (D &value, bool validateUtf8) noexcept |
| Deliver the current fixlen payload into the destination the caller handed over (§6.6.3, second shape). | |
| template<typename D > | |
| bool | roomFor (D &value, size_t need) noexcept |
Is there room for need bytes in the destination the caller handed over (§6.6.3)? | |
| template<typename D > | |
| bool | readPayloadPiece (D &value, bool validateUtf8, size_t avail) noexcept |
| The chunk-straddling half of readPayload — deliver the piece that has arrived and remember how far the value got. | |
| bool | capCannotFire (size_t n) const noexcept |
Hoisted form of exceedsBuffer for a whole window of n bytes: true when no field of it can cross the budget. | |
| bool | exceedsBuffer (size_t consumed, uint64_t need) const noexcept |
| Would buffering this field cross maxBufferedField_? | |
| Entry | levelEntry () noexcept |
| Decide how this level is being entered, and clear the replay state once the suspended level is reached. | |
| template<typename Cb > | |
| void | dispatchLevel (Cb &&cb, bool stopAtEnd) noexcept |
| Field | beginField (bool stopAtEnd) noexcept |
| Parse the next field's header and metadata at a nested level, and apply every rule that is decided before the value. | |
| bool | finishField (const uint8_t *fieldStart, const uint8_t *payload, sofab::id fieldId) noexcept |
| Settle a field the callback has been offered: skip it if the callback did not want it, suspend it if its bytes ran out. | |
| void | closeLevel (bool stopAtEnd) noexcept |
The bytes ran out with this sequence still open — INCOMPLETE, not malformed (§7). | |
| bool | reenterLevel (FieldCb cb, Entry entry) noexcept |
| Take the Entry::Descend or Entry::Resume path. | |
| void | suspendHere (sofab::id fieldId, bool declined) noexcept |
| Record that this level's current field is the suspension point. | |
| void | suspendAtBoundary () noexcept |
| Claim the suspension for this level at a field boundary — nothing half-delivered, only a header cut in two or a sequence still open. | |
| void | restorePending () noexcept |
| Put the suspended field's header back before continuing it. | |
| bool | deliverPending (FieldCb cb, bool declined) noexcept |
| Re-deliver the half-delivered field at this level. | |
| bool | descendResume (FieldCb cb) noexcept |
| Re-descend one recorded level of pathId_ towards suspendDepth_. | |
| void | skipPayload () noexcept |
| Step over the payload of the current field, resumably. | |
| void | skipSequence () noexcept |
| Walk a sub-sequence nobody asked for, delivering nothing. | |
| size_t | spanned () const noexcept |
| The bytes of the current top-level field seen so far, across every chunk it spans (#26, Limits::max_buffered_field). | |
| size_t | spannedLive () const noexcept |
| spanned less what this field spent on skipped subtrees — the number the field-span cap is measured against (§6.2.1). | |
| void | discountSkipped (const uint8_t *from) noexcept |
| Discount a skipped field's bytes from the live span (§6.2.1). | |
| Result | latchTerminal () noexcept |
| Latch the refusal this feed produced, in §6.3's order of tiers. | |
| void | stash (const uint8_t *p, size_t n) noexcept |
| Hold the ≤ CARRY_CAP bytes of a cut item until the next feed. | |
| size_t | parseWindow (const uint8_t *p, size_t n) noexcept |
| Parse one window of bytes, resuming whatever the last one left open, and report how much of it was consumed. | |
| void | parseTopLevel () noexcept |
| Deliver every complete top-level field in the current window, leaving p_ at the first byte not consumed. | |
| bool | parseFieldTag () noexcept |
| Parse a field header word into fieldId_ and type_ (§4.3). | |
| bool | parseFieldMeta () noexcept |
| Parse the word(s) between a field header and its payload — the fixlen word (§4.6), the array count (§4.7) or both (§4.8). | |
| bool | parseFieldHeader () noexcept |
| Parse one top-level field header plus the metadata that precedes its payload, into the current-field members. | |
| bool | exceedsBufferAtHeader () noexcept |
| Would this field cross maxBufferedField_, judged from its header alone (#26)? | |
| template<bool Bounded, typename Elem > | |
| bool | readIntElements (std::span< Elem > sp, ElemBound b={}) noexcept |
Decode the current integer-array payload: count_ varint elements, the first sp.size() of them into sp. | |
| template<typename S , typename Sizer > | |
| bool | readStringGated (S &value, long bound, long dynCap, Sizer sizer) noexcept |
The body both string reads share, so the two cannot answer differently. | |
| template<typename B , typename Sizer > | |
| bool | readBlobGated (B &value, long bound, long dynCap, Sizer sizer) noexcept |
The body both blob reads share. | |
| template<typename T , typename Sizer > | |
| bool | readArrayGated (T &dst, long schemaCount, long dynCap, ElemBound elem, Sizer sizer) noexcept |
| The body both array reads share. | |
| bool | acceptsStringGated (long bound, long dynCap) noexcept |
The body both string accepts share. | |
| bool | acceptsBlobGated (long bound, long dynCap) noexcept |
The body both blob accepts share. | |
Static Protected Member Functions | |
| static bool | getVarintWindowed (const uint8_t *&p, uint64_t &out, bool *overflow) noexcept |
| Read one varint, given that a full varint window is in the buffer. | |
| static bool | skipVarintWindowed (const uint8_t *&p, bool *overflow) noexcept |
| getVarintWindowed without building the value — see skipVarint. | |
| static bool | getVarint (const uint8_t *&p, const uint8_t *end, uint64_t &out, bool *overflow=nullptr) noexcept |
| Read one base-128 varint, advancing the cursor (bounds-checked). | |
| static bool | skipVarint (const uint8_t *&p, const uint8_t *end, bool *overflow=nullptr) noexcept |
| Advance the cursor past one varint without decoding it (bounds-checked). | |
| static bool | fixlenWordValid (uint64_t word) noexcept |
Validate a single Fixlen field's length-and-subtype word (§4.6, §6.2). | |
| static bool | arrayFixlenWordValid (uint64_t word) noexcept |
Validate a ArrayFixlen element word (§4.8, §6.2). | |
| template<std::floating_point F> | |
| static F | loadFloat (const uint8_t *p) noexcept |
| Load a little-endian float or double from raw bytes. | |
| template<typename Cb > | |
| static FieldCb | wrapCb (Cb &cb) noexcept |
| Wrap a level's callback as a FieldCb. | |
| static constexpr bool | schemaBoundsHeader (Wire w) noexcept |
| Does this wire type's header state a size the schema can bound? | |
Protected Attributes | |
| uint8_t | carry_ [CARRY_CAP] |
| The prefix of one cut item, carried to the next feed. | |
| size_t | carryLen_ = 0 |
| Live bytes of carry_. | |
| int | suspendDepth_ = -1 |
| Depth at which the parse is suspended, or -1 when nothing is. | |
| bool | replay_ = false |
| Re-descending pathId_ to reach suspendDepth_. | |
| sofab::id | pathId_ [MAX_DEPTH+1] |
| Id of the sequence field entered at each open level (§4.9). | |
| bool | pathSkip_ [MAX_DEPTH+1] |
| That level was entered by skipPayload, not by a handler. | |
| bool | pend_ = false |
| A field at suspendDepth_ is half-delivered. | |
| sofab::id | pendId_ = 0 |
| That field's header, kept apart from the live type_ / fixLen_ / count_. | |
| Wire | pendType_ {} |
| That field's header, kept apart from the live type_ / fixLen_ / count_. | |
| Fix | pendFix_ {} |
| That field's header, kept apart from the live type_ / fixLen_ / count_. | |
| size_t | pendLen_ = 0 |
| That field's header, kept apart from the live type_ / fixLen_ / count_. | |
| size_t | pendCount_ = 0 |
| That field's header, kept apart from the live type_ / fixLen_ / count_. | |
| bool | pendSkip_ = false |
| ...and it was declined, so skipPayload resumes it rather than the handler. | |
| size_t | pendDone_ = 0 |
| Progress through the pending field: payload bytes already written into the caller's destination, or array elements already decoded. | |
| uint32_t | utf8State_ = 0 |
Incremental UTF-8 DFA state for the string payload in progress (§6.4.4). | |
| size_t | spanCarry_ = 0 |
| Bytes of the current top-level field consumed in earlier chunks (#26). | |
| const uint8_t * | spanBase_ = nullptr |
| Where that field's span continues in the window being parsed (#26). | |
| bool | spanSkip_ = false |
| Is the parse currently inside a skipped sequence subtree (§6.2.1, #129)? | |
| bool | capInert_ = false |
| Can the field-span cap provably not fire anywhere in the window being parsed (§6.2.1, #26)? Set once per parseWindow. | |
| size_t | spanSkipped_ = 0 |
| Bytes of the current top-level field spent on SKIPPED subtrees (§6.2.1, #129 one level down). | |
| const uint8_t * | p_ = nullptr |
| Read cursor. | |
| const uint8_t * | end_ = nullptr |
| One past the last readable byte. | |
| Wire | type_ {} |
| Wire type of the field being delivered. | |
| Fix | fixType_ {} |
| Sub-type of the current fixlen field. | |
| size_t | fixLen_ = 0 |
| Payload length (fixlen) or element size (fixlen array), in bytes. | |
| size_t | count_ = 0 |
| Element count of the current array field. | |
| bool | consumed_ = false |
| Set once the callback has read the current field's value. | |
| bool | error_ = false |
| Sticky "this feed was refused" flag, and the only one the parse loops test. | |
| bool | limitExceeded_ = false |
| Category: a receiver-side limit was crossed (§6.2.1). | |
| bool | argError_ = false |
| Category: a well-formed value did not fit the destination the caller handed over (§6.3's third refusal tier, §6.6.3). | |
| Error | terminal_ = Error::None |
| The stream's latched terminal verdict, or Error::None while the stream is still usable (§5.2, §6.3). | |
| int | seqDepth_ = 0 |
| Current nested-sequence depth during dispatch (§4.9 MAX_DEPTH). | |
| size_t | skipped_ = 0 |
| §7.3 type-mismatch skips seen so far (skipped). | |
| bool | incomplete_ = false |
| The field being delivered needs more bytes (§7 INCOMPLETE, not malformed). | |
| long | elemBound_ = -1 |
| The tightest armed element-index bound of the wrapper sequence being read (§5.1); -1 = none. | |
| long | elemSchema_ = -1 |
Schema count N: an id at or past it is InvalidMessage (§7.1). | |
| long | elemDyn_ = -1 |
Configured max_dyn_array_count: LimitExceeded (§6.2.1). | |
| long | elemDest_ = -1 |
The destination container's own capacity: InvalidArgument (§6.6.3). | |
| int | elemWire_ = -1 |
| §7.3 wire type its elements must carry (a Wire as int); -1 = the collector decides the bound itself. | |
| int | elemFix_ = -1 |
| §7.3 fixlen subtype for that element type (a Fix as int); -1 = the element type has none. | |
| sofab::id | fieldId_ = 0 |
| Id of the field being delivered. | |
| size_t | maxBufferedField_ |
| The receiver's byte budget for one top-level field (Limits::max_buffered_field), as this decode was told it. | |
| std::function< void(sofab::id, size_t, size_t)> | topCallback_ |
| Delivers each top-level field. | |
Static Protected Attributes | |
| static constexpr size_t | CARRY_CAP = 3 * detail::VARINT_MAX_BYTES |
| Widest prefix of a wire item that can outlive a chunk boundary, derived from this format's own constants (§6.6). | |
| static constexpr uint64_t | CAP_NEED_MAX |
Upper bound of any header-declared need (§6.2 ceilings). | |
Base of the input streams: decodes fields from fed bytes.
Bytes are supplied through feed, which may be called repeatedly with chunks. A whole message handed in at once is parsed in place with no copy; an incomplete trailing field is buffered and resumed on the next feed. Each complete top-level field is delivered to a callback, inside which read pulls the field's value out at the matching type.
|
strongprotected |
How a level is being entered (see levelEntry).
| Enumerator | |
|---|---|
| Fresh | Nothing open here: parse the next field. |
| Descend | The suspended level is deeper: replay one more id. |
| Resume | This level is it: continue its half-delivered field. |
|
strongprotected |
What beginField found at this level's next field.
| Enumerator | |
|---|---|
| Ready | Deliver it. |
| SkipElem | §7.3 says it is not this array's element: skip, do not deliver. |
| Stop | The level is finished, suspended or refused. |
|
inlineexplicitprotectednoexcept |
Construct with the receiver's Limits; a derived class installs topCallback_.
There is no default constructor. §6.2.1 leaves this codec no number to invent, so a stream that was told none cannot be built: the omission is a compile error rather than a decode that turns out to have been bounded by nothing.
|
delete |
|
defaultnoexcept |
|
virtualdefault |
|
inlinenoexcept |
The §7.3 and §7.1 decisions readString makes, taken before a destination exists.
For a caller that has to place an element before it can offer a destination — StringSeq puts an element at its index, and growing the container for a field that turns out not to be an element would change the array's length (§5.1/§7.4). It answers the same two questions readString answers first, in the same order and through the same seam, so the skip is counted exactly once: the tag (§7.3) and then the declared maxlen (§7.1).
It takes the §6.2.1 receiver cap on the same terms as readString — passed in, never held, and consulted only where bound is negative — so the two seams cannot answer differently.
It splits into a bounded and a capped form for the same reason readString does, and refuses a call that states neither the same way (rejectUnbounded).
| bound | Declared maxlen. Required and non-negative; acceptsStringCapped is the schema-unbounded form. |
true when a destination may be placed and handed to readString.
|
inlinenoexcept |
acceptsString for a schema-unbounded element, under the receiver's max_dyn_string_len (§6.2.1).
| dynCap | The caller's cap. Required and non-negative. |
|
inlineprotectednoexcept |
|
inlinenoexcept |
The §7.3 and §7.1 decisions readString makes, taken before a destination exists.
For a caller that has to place an element before it can offer a destination — StringSeq puts an element at its index, and growing the container for a field that turns out not to be an element would change the array's length (§5.1/§7.4). It answers the same two questions readString answers first, in the same order and through the same seam, so the skip is counted exactly once: the tag (§7.3) and then the declared maxlen (§7.1).
It takes the §6.2.1 receiver cap on the same terms as readString — passed in, never held, and consulted only where bound is negative — so the two seams cannot answer differently.
It splits into a bounded and a capped form for the same reason readString does, and refuses a call that states neither the same way (rejectUnbounded).
| bound | Declared maxlen. Required and non-negative; acceptsStringCapped is the schema-unbounded form. |
true when a destination may be placed and handed to readString.
|
inlinenoexcept |
acceptsString for a schema-unbounded element, under the receiver's max_dyn_string_len (§6.2.1).
| dynCap | The caller's cap. Required and non-negative. |
|
inlineprotectednoexcept |
|
inlinenoexcept |
The element count the current array field's header announces.
§6.6.3's "after being told the announced count": the number the caller sizes its destination from before handing it back. Identical to the size argument of the deliver callback, reachable from a helper that was not handed it (sofab::readString and friends).
|
inlinenoexcept |
The payload length the current field's header announces — a string/blob byte count, or a fixlen array's element width.
§6.6.3's "after being told the announced count": the number the caller sizes its destination from before handing it back. Identical to the size argument of the deliver callback, reachable from a helper that was not handed it (sofab::readString and friends).
|
inlinestaticprotectednoexcept |
Validate a ArrayFixlen element word (§4.8, §6.2).
A fixlen array may only carry fixed-width elements — Fp32 (4 bytes) or Fp64 (8 bytes). Dynamic subtypes (String, Blob) and the reserved subtypes are not permitted as array elements (§4.8); such a word is INVALID.
| word | The decoded per-element fixlen_word. |
true if the subtype/element-size pair is legal for a fixlen array.
|
inlinenoexcept |
Bytes of this field readable right now, in the chunk being parsed.
What lets a helper sizing a destination clamp an announced count to what the bytes in hand could ever fill, so a hostile count never decides an allocation — the same clamp readArray applies to its own refusal.
|
inlineprotectednoexcept |
Parse the next field's header and metadata at a nested level, and apply every rule that is decided before the value.
Split out of dispatchLevel so it is compiled once rather than once per callback type: the loop's callback is a template parameter so the delivery inlines, but everything around it is the same code in every instantiation, and a dozen copies of it are a dozen copies of the §7.3 and §5.1 rules for a reader to keep in step.
| stopAtEnd | Whether a Wire::SequenceEnd closes this level. |
|
inlineprotectednoexcept |
Hoisted form of exceedsBuffer for a whole window of n bytes: true when no field of it can cross the budget.
|
inlineprotectednoexcept |
|
inlinenoexcept |
|
inlineprotectednoexcept |
Re-deliver the half-delivered field at this level.
Its metadata (type_, fixLen_, count_, fieldId_) is still the state the previous chunk left, and pendDone_ says how far it got, so the read (or the skip) continues where it stopped instead of starting over.
false when the level must return — the field suspended again, or the decode failed.
|
inlineprotectednoexcept |
Re-descend one recorded level of pathId_ towards suspendDepth_.
Replays the sequence field this level was inside when the chunk ran out: either by handing its id back to cb — whose deserialize dispatches on the id and calls read on the same member, re-establishing exactly the handler that was open — or, for a level that was being skipped, by re-entering the skip descent directly. Nothing is parsed here: the bytes of the sequence header were consumed by an earlier chunk and are gone.
| cb | This level's per-field callback. |
false when the level must return.
|
inlineprotectednoexcept |
|
inlineprotectednoexcept |
|
inlinenoexcept |
Report a receiver-side decode-limit violation from inside a deliver callback.
Sets the sticky limit flag, so the surrounding feed stops dispatching further fields and returns Error::LimitExceeded. For callers enforcing policy caps the wire layer cannot know — e.g. a generated message rejecting an unbounded (schema-bound-less) array/string/blob whose claimed count/length exceeds a configured decode limit (generator#102). Deliberately distinct from invalidate: the bytes may be perfectly well-formed; rejecting them is receiver policy, not wire malformation (§7). Idempotent; a no-op outside a feed since every feed clears the flag on entry.
|
inlineprotectednoexcept |
Would buffering this field cross maxBufferedField_?
| consumed | Bytes of the current top-level field already spanned. |
| need | Further bytes the field is now known to require (a declared payload length, array byte-span, or per-element lower bound). |
true if consumed + need exceeds the cap. Overflow-safe: the addition is never formed, so a caller that stated SIZE_MAX as its budget gets a check that runs and never fires, rather than a check this library switched off.
|
inlineprotectednoexcept |
Would this field cross maxBufferedField_, judged from its header alone (#26)?
The header states the size exactly for a fixlen or fixlen-array payload; a varint array's count is a lower bound on its bytes. A sequence accrues instead, and is bounded field by field in dispatchLevel.
true when the field must be rejected before its payload is read.
|
inlinenoexcept |
Feed bytes into the decoder, delivering every complete top-level field.
May be called repeatedly with successive chunks; a field split across chunks is resumed on a later call — its pieces are written into the caller's destination as they arrive, and only what a chunk boundary can cut in half (a field header, the words before a payload, one varint element — at most CARRY_CAP bytes) is carried over. Every chunk is parsed in place; nothing is copied but the value itself.
| buffer | Bytes to decode. |
| buflen | Number of bytes in buffer. |
COMPLETE) when the fed bytes end exactly at a field boundary; Error::Incomplete (INCOMPLETE) when they end inside a field (partial varint, short fixlen/array payload) or with an open sequence — the decoder keeps its place for the next feed and this is not an error; or Error::InvalidMessage (INVALID) when the bytes are malformed regardless of what follows. Error::LimitExceeded is the fourth, receiver-policy outcome (§6.2.1) — well-formed bytes this receiver refuses to buffer.INVALID, and §6.3 calls LimitExceeded "a terminal, receiver-local policy rejection". Once feed has returned either, the verdict is latched on the stream: every later call returns the same code without parsing a byte, no further field is delivered, and the input after the fault is neither buffered nor inspected. reset is the way back — it is the documented start of a new message anyway. This is what makes the outcome chunk-independent (§7.2 item 4): the same bytes fed whole, in odd-sized chunks or one at a time all end on the same verdict, and garbage prefixed to a valid message can never be reported as COMPLETE.
|
inlineprotectednoexcept |
Settle a field the callback has been offered: skip it if the callback did not want it, suspend it if its bytes ran out.
The callback did not want this field: rewind to the payload — which the declining read left the cursor at anyway — and skip it, resumably, so a long payload nobody asked for is stepped over as it arrives rather than buffered (§6.6.2).
§7: the bytes running out INSIDE the field is a different thing. It is unfinished, not declined, and the two must not be confused — hence the !incomplete_ in the test. Skipping a truncation would rewind into a payload the callback has already parsed into and re-read those bytes under the metadata of whatever innermost field the descent left behind, reporting INVALID for a truncation (Crucible F-0056, corelib-cpp#71).
§6.2.1: what the skip walks past is discounted from the field-span cap — from fieldStart, so the skipped child's own header goes with it. A skip that SUSPENDS discounts what this window walked and the resume (deliverPending) discounts the rest, which is what keeps the verdict independent of the caller's chunking (§7.2 item 4).
| fieldStart | The field's first header byte. |
| payload | The field's first payload byte. |
| fieldId | Its id, for the path entry a suspension records. |
false when the level must return.
|
inlinestaticprotectednoexcept |
Validate a single Fixlen field's length-and-subtype word (§4.6, §6.2).
A well-formed word carries a defined subtype (0–3) whose length is legal for that subtype: a Fp32 payload is exactly 4 bytes, Fp64 exactly 8, and String/Blob any length up to FIXLEN_MAX. Subtypes 0b100..0b111 are reserved. A violation is malformed regardless of what follows (spec §7 INVALID), so it must be rejected rather than mistaken for a truncated (INCOMPLETE) field.
| word | The decoded fixlen_word ((length << 3) | subtype). |
true if the subtype/length pair is legal for a scalar fixlen field.
|
inlinenoexcept |
Fixlen sub-type of the field currently being delivered.
Only meaningful when wire is a fixlen kind. Introspection only, like wire: readString / readBlob state the declared subtype and the stream compares it. Reads no bytes and does not consume the field.
|
inlinestaticprotectednoexcept |
Read one base-128 varint, advancing the cursor (bounds-checked).
| [in,out] | p | Cursor; advanced past the varint on success. |
| end | One past the last readable byte. | |
| [out] | out | Decoded value. |
true on success, false if the buffer ends mid-varint or it overflows 64 bits. On overflow (a varint > 64 bits, §4.1) *overflow is set: that is INVALID regardless of what follows, and callers in callers must distinguish it from a merely-truncated tail.
|
inlinestaticprotectednoexcept |
Read one varint, given that a full varint window is in the buffer.
The caller must have established that at least detail::VARINT_MAX_BYTES bytes are readable at p. That single fact retires both per-byte checks the general path needs: the cursor cannot run past the end inside ten bytes, and the first nine bytes carry at most 63 payload bits, so only the tenth can be overlong (§4.1). With the checks gone the first eight bytes can be taken as one word and unpacked with detail::gather7, leaving only a ninth and tenth byte to guard.
| [in,out] | p | Cursor; advanced past the varint, including on overflow. |
| [out] | out | Decoded value. |
| overflow | Set when the varint is wider than 64 bits (INVALID, §6.3). |
true on success, false on a > 64-bit varint.
|
inlinenoexcept |
Mark the running decode INVALID from inside a deliver callback.
Sets the sticky decode-error flag, so the surrounding feed stops dispatching further fields and returns Error::InvalidMessage (INVALID). For callers that detect malformed content the wire layer cannot judge on its own — e.g. a generated message rejecting an array whose wire element count exceeds its schema count capacity, which is INVALID per spec §3/§7 (generator#100). Idempotent; a no-op outside a feed since every feed clears the flag on entry.
|
inlineprotectednoexcept |
|
inlineprotectednoexcept |
|
inlinestaticprotectednoexcept |
|
delete |
|
defaultnoexcept |
|
inlineprotectednoexcept |
Parse one top-level field header plus the metadata that precedes its payload, into the current-field members.
parseFieldTag + parseFieldMeta, with the one rule that is the top level's own: a Wire::SequenceEnd here closes a sequence that was never opened, which is INVALID (§7). Inside a sequence the same marker is the close, which is why dispatchLevel puts its own test between the two calls.
true when the header is complete and well-formed. On false either error_ (malformed) or incomplete_ (more bytes needed) is set.
|
inlineprotectednoexcept |
Parse the word(s) between a field header and its payload — the fixlen word (§4.6), the array count (§4.7) or both (§4.8).
Shared by the two parse loops for the same reason as parseFieldTag: this is where §4.6's subtype/length pairing, §4.8's element-subtype rule and §6.2's ARRAY_MAX ceiling are enforced, and a second copy of it is a place for one of them to go missing — which is exactly how the nested path lost the ARRAY_MAX check on a fixlen array until #103. A varint or sequence header states no metadata, so it falls through.
true when the metadata is complete and well-formed, with fixLen_, count_ and fixType_ set. On false either error_ or incomplete_ is set.
|
inlineprotectednoexcept |
Parse a field header word into fieldId_ and type_ (§4.3).
The only place a (id << 3) | wire_type word is taken apart. Both parse loops — parseTopLevel through parseFieldHeader, and dispatchLevel inside a sequence — come through here, so the ID_MAX ceiling (§6.2) cannot be present in one and missing from the other.
true when a whole header word was read and its id is legal. On false either error_ (a > 64-bit varint, or an id past ID_MAX) or incomplete_ (the word is cut short) is set.
|
inlineprotectednoexcept |
Deliver every complete top-level field in the current window, leaving p_ at the first byte not consumed.
The same shape as dispatchLevel, and for the same reasons: a level the previous window left open is re-entered rather than re-parsed, either by descending pathId_ to the suspended level or — when this level is it — by continuing the field pendDone_ describes.
|
inlineprotectednoexcept |
|
inlinenoexcept |
How much of the current field earlier chunks already delivered — payload bytes written, or array elements decoded.
Zero on a field's first delivery. A field split across feed calls is continued, not re-parsed (§6.6.2), so a helper sizing the destination has to add what is already in it to what has just arrived; sizing from this chunk alone would ask the codec to fit a value into less room than it has already used.
|
inlinenoexcept |
Read the current field's value, dispatching on value's type.
Call from inside a deliver callback. Handles integers (signed values are un-zig-zagged), bool, float, double, std::string, nested sofab::IStreamMessage objects, and writable contiguous ranges of integers, booleans or floats (excess wire elements past the span's capacity are read and discarded). A bool scalar or element reads every non-zero value as true and is bounded by no width (§4.4). On a malformed or truncated field the stream's error flag is set.
Every destination owns what it receives. There is deliberately no borrowing destination: a fed chunk is the caller's for the duration of feed only (CORELIB_PLAN §6), so a decoded value must survive the caller reusing, overwriting or freeing that memory the moment feed returns.
| T | Type to decode into. |
| [out] | value | Destination for the decoded value. |
|
inlinenoexcept |
Read the current blob field into a caller buffer.
Copies up to maxlen bytes; the field is consumed regardless of how much fit. Call from inside a deliver callback.
Declares a blob like readBlob, so it compares the whole tag first (§7.3): any other field — an integer, a sequence, an array, or another fixlen subtype — is left for the decoder to skip, with dst untouched. That check is what keeps the cursor sane, because fixLen_ only means "payload length" for a scalar fixlen field: it is 0 for a varint field and the per-ELEMENT width for a fixlen array, so consuming on those tags left the parser standing inside the payload and re-reading it as field headers (issue #80).
| dst | Destination buffer. |
| maxlen | Capacity of dst in bytes. |
min(maxlen, payload length)), or 0 when the field was not consumed. Zero is therefore ambiguous on its own — a zero-length blob also copies nothing, and so does a skipped mismatch — so a caller that needs to tell them apart consults consumed().
|
inlinenoexcept |
Read a count-prefixed native array, applying every receiver-side decision at the one word that decides it.
Folds what a caller previously had to spell out in four steps — check the wire tag, check the schema count, check a configured policy cap, reset the destination — into one call, in the only order that is correct:
count (§7.1/§5.2) → INVALID. Malformed input.dynCap, §6.2.1) → LimitExceeded. Deliberately not INVALID: the bytes are fine and the same message decodes under a looser cap. 3b. The destination's own capacity, for a destination that publishes one → InvalidArgument (§6.3's third tier, §6.6.3): a count it cannot hold is refused instead of silently truncated into it (MESSAGE_SPEC §3), and by this point neither the schema nor the deployment has anything left to object to — only this caller's storage.count: N keeps the element default in the slots past the wire count M, which is the array's length — there is no fill-to-N and no trailing elision to undo (§3).elem, §7.1) → INVALID, per element as it is decoded. The sibling of the count bound at step 2: the same class of schema fact, arriving through the same call, and the reason it is applied here rather than by the caller — an element cannot be range-checked after the fact without a wide temporary copy of the whole array. Unarmed by default, so an omitted bound decodes exactly as before.| [out] | dst | Destination range (fixed extent or resizable). |
| schemaCount | Declared count: N, or negative when unbounded. Split into two entry points on the same terms as readString: this one takes the declared count, readArrayCapped takes the receiver cap, and neither has a default. | |
| elem | Declared element range (ElemBound), e.g. ElemBound::of<std::uint8_t>() for items: u8. Ignored for a float element type, which has no narrowing to reject: fp32/fp64 are carried at their own width on the wire. Ignored for a bool element too, which §4.4 bounds by no width at all: every non-zero element is true. | |
| schemaCount | Declared count: N. Required and non-negative; a schema-unbounded array is read through readArrayCapped. |
true when the array was read; false when it was skipped (§7.3) or rejected, with the outcome already recorded on the stream.
|
inlinenoexcept |
Read a schema-**unbounded** count-prefixed array under the receiver's max_dyn_array_count (§6.2.1).
The counterpart of readArray for an array whose schema declares no count. Step 2 of the order above drops out and step 3 decides; the cap is the caller's, used for that one comparison and not retained.
| [out] | dst | Destination range (fixed extent or resizable). |
| dynCap | The caller's max_dyn_array_count. Required and non-negative; a negative value answers Error::InvalidArgument. | |
| elem | Declared element range (ElemBound). |
true when the array was read.
|
inlineprotectednoexcept |
The body both array reads share.
Exactly one of bound / dynCap is non-negative.
Not an entry point. It carries no check that a number was stated — that is the job of readString and readStringCapped, which is why this is not public: a (-1, -1) call is the fail-open shape §6.2.1 forbids, and there is deliberately no way to spell it.
|
inlinenoexcept |
Read the current field as a blob, or skip it (§7.3).
The Fix::Blob counterpart of readString; reads straight into the byte container, with no intermediate std::string. Takes a growable std::vector<uint8_t> or a heap-free FixedBytes, on the same FixedBytes::set_len test.
Refuses in the same three ways, in the same order, as readString — and takes its own §6.2.1 cap the same way. blob and string are separate limits, so the caller passes max_dyn_blob_len here.
Split into two entry points on the same terms as readString: this one takes the declared maxlen, readBlobCapped takes the receiver cap, and neither has a default.
| [out] | value | Destination for the decoded bytes. |
| bound | Declared maxlen. Required and non-negative; a schema-unbounded field is read through readBlobCapped. |
true when the value was read; false when the field was left for the decoder to skip.
|
inlinenoexcept |
Read the current field as a schema-**unbounded** blob under the receiver's max_dyn_blob_len (§6.2.1).
The blob counterpart of readStringCapped; see it for why the capped read is its own entry point. blob and string are separate limits, so the caller passes max_dyn_blob_len here.
| [out] | value | Destination for the decoded bytes. |
| dynCap | The caller's max_dyn_blob_len. Required and non-negative; a negative value answers Error::InvalidArgument. |
true when the value was read; false when the field was left for the decoder to skip.
|
inlineprotectednoexcept |
The body both blob reads share.
Exactly one of bound / dynCap is non-negative.
Not an entry point. It carries no check that a number was stated — that is the job of readString and readStringCapped, which is why this is not public: a (-1, -1) call is the fail-open shape §6.2.1 forbids, and there is deliberately no way to spell it.
|
inlineprotectednoexcept |
Decode the current integer-array payload: count_ varint elements, the first sp.size() of them into sp.
The tag is already known to match (§7.3) and the cursor sits at the first element. On success the field is consumed_; on failure the stream's error_ / incomplete_ says which.
| Bounded | Apply b, the declared element type's value range (§7.1): an element outside it makes the decode INVALID — never masked down to Elem, never kept. false instantiates the plain decode, which is what read alone can do: it sees the destination's width, and a destination width is not a declared width. The two are separate instantiations, so an unbounded array carries no test for a bound it does not have. |
| sp | Destination for the leading elements; the rest of count_ is still parsed, to stay framed. |
| b | The element range, when Bounded. |
|
inlineprotectednoexcept |
Deliver the current fixlen payload into the destination the caller handed over (§6.6.3, second shape).
The one place a string / blob payload reaches a destination, so the §6.6 rule has one implementation and cannot hold in one read and be missing from another. In order:
InvalidArgument — because both bounds that can speak about the message have already spoken: the schema maxlen in the caller above, and any configured receiver cap. It is decided from the header alone, before a byte of payload is consulted, so where the chunk boundaries fall cannot change it.INCOMPLETE, never an error (§5.2).string payload only, and never on skip (§6.4.5 — this function runs only where a value is materialized).| D | Destination: sofab::FixedString / sofab::FixedBytes (static room) or a std::string / std::vector<uint8_t> the caller sized. |
| value | Destination. |
| validateUtf8 | Whether the payload is a string (§6.4). |
true when the payload was delivered and the field consumed.
|
inlineprotectednoexcept |
The chunk-straddling half of readPayload — deliver the piece that has arrived and remember how far the value got.
§6.6.2: "A payload split across fed chunks has to be joined somewhere. That somewhere is storage the caller supplied — the codec copies each piece into it as the piece arrives … A codec <strong>MUST NOT</strong> grow a private accumulator instead." So the piece goes straight where the value belongs and only the length is published, once, at the end — no caller ever sees a half-written value (§6.6.2's "written exactly once, complete").
Cold: it runs only for a field a chunk boundary fell inside.
|
inlinenoexcept |
Read the current field as a string, or skip it (§7.3).
fp32, fp64, string and blob all share Wire::Fixlen, so a plain read cannot tell which one the caller declared. This overload states it: the value is read only when the wire subtype is Fix::String, otherwise the field is left unconsumed — the decoder then skips it exactly like an unknown id, and skipped counts it.
The destination is either a growable one (std::string) or a heap-free FixedString, told apart by FixedString::set_len rather than by name, so a caller's own type works too. Both spell the call identically; only where the bytes land differs.
string → the field is skipped (§7.3), and neither bound below is applied to it: "a skipped field
is never capped" (§6.2.1).bound is declared and the announced length exceeds it → InvalidMessage (MESSAGE_SPEC §7.1). The schema calls these bytes invalid.bound is negative — the schema declares none — and the announced length exceeds dynCap → Error::LimitExceeded (§6.2.1). The bytes are well-formed; this receiver declines to hold that much.All three are decided at the length header, before the destination is sized (§6.2.1's enforcement point, §5.2.3): sofab::readString, the helper that sizes a growable destination, applies the identical gate before it grows anything.
maxlen only; readStringCapped is the schema-unbounded one and takes the §6.2.1 receiver cap only. Exactly one of the two numbers can ever apply — a receiver limit "**MUST NOT** be applied to a field the
schema already bounds" — so the choice belongs in the call's name rather than in a pair of arguments where either may be left out. Neither has a default, and neither reads a negative value as "unlimited": a bound below zero is not a schema-unbounded read, it is a call that stated no bound at all, and it answers Error::InvalidArgument through rejectUnbounded.bound is the caller's, used for this one comparison and not retained. There is no stream-wide fallback of any kind. Passing the number here rather than testing it in front of the call is what keeps case 1 above true: the tag test is inside, so a field the decoder must skip never meets the ceiling.| [out] | value | Destination for the decoded text. |
| bound | Declared maxlen. Required and non-negative; a schema-unbounded field is read through readStringCapped instead. |
true when the value was read; false when the field was left for the decoder to skip.
|
inlinenoexcept |
Read the current field as a schema-**unbounded** string under the receiver's max_dyn_string_len (§6.2.1).
The counterpart of readString for a field whose schema declares no maxlen. It refuses in the same order — tag (§7.3), then the cap (Error::LimitExceeded) — and the cap is the caller's, used for this one comparison and not retained.
It exists as its own entry point rather than as a defaulted argument because a defaulted one can be left out, and a schema-unbounded read with no cap is the sender choosing how much this process holds. There is nothing to default to: §6.2.1 forbids this codec a limit of its own.
| [out] | value | Destination for the decoded text. |
| dynCap | The caller's max_dyn_string_len. Required and non-negative; a negative value is a call that stated no cap and answers Error::InvalidArgument. |
true when the value was read; false when the field was left for the decoder to skip.
|
inlineprotectednoexcept |
The body both string reads share, so the two cannot answer differently.
Exactly one of bound / dynCap is non-negative.
Not an entry point. It carries no check that a number was stated — that is the job of readString and readStringCapped, which is why this is not public: a (-1, -1) call is the fail-open shape §6.2.1 forbids, and there is deliberately no way to spell it.
Take the Entry::Descend or Entry::Resume path.
|
inlinenoexcept |
Refuse the current field because the caller's destination is too short for it (§6.3's third refusal tier, §6.6.3).
The sibling of invalidate and exceedLimit, for the one refusal that is about neither the message nor the deployment: the value broke no schema bound and no configured cap, and simply does not fit the storage this caller handed over. §6.3: "<tt>InvalidMessage</tt> would mark a well-formed message malformed … <tt>LimitExceeded</tt> would promise a limit to raise that was never configured." The surrounding feed stops dispatching and returns Error::InvalidArgument. Idempotent; a no-op outside a feed since every feed clears the flag on entry.
|
inlinenoexcept |
Refuse a wrapper-array element whose index is at or past a bound, in the category §6.3 gives that bound.
MESSAGE_SPEC §5.1 makes a wrapper array's length highest present id + 1, so the element index is the length and is what has to be checked — "A limit **MUST** be enforced … before the container it
indexes into is extended" (§6.2.1). Three bounds can be armed at once and they do not share a verdict, so they are consulted in §6.3's order: the schema count first (InvalidMessage), then the configured receiver cap (LimitExceeded), then the destination's own capacity (InvalidArgument).
| bad | The element index that crossed a bound. |
|
inlinenoexcept |
Refuse the current field because the call stated no bound for it at all (§6.3's InvalidArgument).
The one answer §6.2.1 leaves for a schema-unbounded field read with no receiver cap. This codec has no limit of its own to fall back on, and "an argument a caller may omit is an API affordance, never a licence to
decode uncapped" — so the omission is reported rather than obeyed. It is a mistake in the call, exactly like a destination too short for the value (rejectDestination): the message is well-formed and the deployment configured nothing, so neither InvalidMessage nor LimitExceeded would say anything true about it (§6.3's three tiers).
Reaching it from generated code means a cap was not emitted; reaching it from a hand-written visitor means the wrong entry point was used — the …Capped forms exist so the number cannot be forgotten.
|
inlinevirtualnoexcept |
Drop every byte of decoder state, so the next feed starts a brand-new message.
Discards the buffered partial field, the sticky error/limit flags, the latched terminal verdict (§5.2/§6.3 — this is the only way to clear an INVALID or LimitExceeded stream), the nesting depth and the §7.3 skipped counter. There is no buffer to hand back: the decoder's working state is the fixed-size carry, path and progress it was constructed with (§6.6), so a reset is a handful of stores and the message loop pays no allocator for it.
It does not touch the destination — this class has none; it only dispatches. IStreamObject overrides this to reset the message it owns as well, which is what a caller reusing a decoder wants. A caller driving IStreamInline owns its destinations and must clear them itself.
Required between messages: MESSAGE_SPEC §2 omits an all-default field entirely, so an absent field delivers no callback and leaves the previous message's value in place — including a wrapper-array field, whose collector (StringSeq, BlobSeq, MessageSeq) only clears its destination when the wrapper sequence is actually present.
Reimplemented in sofab::IStreamObject< MessageType >.
|
inlineprotectednoexcept |
|
inlinenoexcept |
true when this delivery re-enters a sequence an earlier feed left open, rather than announcing a new field.
A nested sequence cut by a chunk boundary cannot be resumed from a byte offset — the handler chain that was inside it lives on the C++ stack, and a feed returning unwinds it. The decoder therefore replays the field ids of the open levels, so each handler is asked for the same member again and the chain is rebuilt exactly as it was. Nothing about the field is new: the id, the sequence and everything already decoded inside it are the ones the previous chunks produced.
A handler that only dispatches on the id — every generated deserialize, and any handler written the same way — needs this for nothing: reading the same member again is precisely right, and the codec continues where it stopped. It exists for a handler that keeps a position of its own rather than a schema, which must not advance it twice.
Distinct from progress, which is about the bytes of one field.
|
inlineprotectednoexcept |
Is there room for need bytes in the destination the caller handed over (§6.6.3)?
Two kinds of destination answer differently, and the difference is a fact the type publishes rather than a policy this read picks:
D::capacity()) cannot change between chunks, so the refusal is decided from the header alone — before a byte of payload is consulted — and where the chunk boundaries fall cannot change it;INCOMPLETE (§5.2) instead of being mistaken for a destination that is too small; once the last piece is here the reach IS the announced length, and a destination genuinely too short is refused exactly then.false with rejectDestination raised (InvalidArgument).
|
inlinestaticconstexprprotectednoexcept |
Does this wire type's header state a size the schema can bound?
True for the length-prefixed payload (maxlen) and the three array kinds (count) — exactly the fields whose §7.1 verdict outranks the field-size cap (#86), and exactly the ones exceedsBufferAtHeader derives a size from. A sequence states no size of its own (it accrues in dispatchLevel) and a varint carries no length word at all.
| w | The delivered field's wire type. |
true when a declared maxlen/count could reject this field.
|
inlineprotectednoexcept |
Step over the payload of the current field, resumably.
Called for a field the callback declined. Like every read, it never buffers what it has not finished: a payload cut by a chunk boundary leaves its byte (or element) progress in pendDone_ and is continued on the next feed, and a small item cut in half — a lone varint, an element — is backed up to its own start so the ≤ CARRY_CAP bytes of it can be carried (§6.6.2).
Assumes the cursor sits at the payload's resume point and the field metadata is set.
|
inlinenoexcept |
Number of fields skipped this stream because their wire tag contradicted the type the callback asked for (MESSAGE_SPEC §7.3).
A diagnostic only — it never influences the decode outcome. A non-zero count on an otherwise COMPLETE message means the peer's schema and this one disagree about a field's type (or a hand-written callback asked for the wrong one).
Monotonic over the stream's lifetime — unlike the sticky error flags it is not cleared per feed, so a message dribbled in chunk by chunk still reports every skip it caused. Result::skipped carries the same value out of a one-shot decode.
|
inlineprotectednoexcept |
Walk a sub-sequence nobody asked for, delivering nothing.
Split out of skipPayload because a skipped sequence, like every other construct, has to be re-enterable: when a chunk ends inside one the level is recorded in pathSkip_ and descendResume comes back through here, with no callback to replay.
§7.3: this sequence is not an element of the enclosing wrapper — and the fields INSIDE it are not that wrapper's elements either. Their ids are child ids of a field that never became a value, not array indices, so the element-index bound must not measure them: it is suspended for the whole subtree and restored after. Without this a child id at or past the wrapper's count would trip the §5.1/§7 reject from inside a field §7.3 says is not the array's at all (Crucible F-0051, corelib-cpp#65). The suspension is not specific to a §7.3-mistyped element: an unknown id skipped inside the wrapper reaches the same place and is equally not an element. Format-level rejects (§4.9 depth, over-64-bit varint, ...) still fire inside the subtree — §7.3 subordinates the SCHEMA bound only.
|
inlinestaticprotectednoexcept |
Advance the cursor past one varint without decoding it (bounds-checked).
| [in,out] | p | Cursor; advanced past the varint on success. |
| end | One past the last readable byte. |
true on success, false if the buffer ends mid-varint or it overflows 64 bits. As with getVarint, *overflow is set on a > 64-bit varint (§4.1), so an over-long varint is never mistaken for a truncated tail.
|
inlinestaticprotectednoexcept |
getVarintWindowed without building the value — see skipVarint.
|
inlineprotectednoexcept |
The bytes of the current top-level field seen so far, across every chunk it spans (#26, Limits::max_buffered_field).
Pointer arithmetic alone stopped being enough once a field could span chunks without being buffered: within one window the span is p_ - spanBase_, and what earlier windows already consumed of the same field is carried in spanCarry_. Without that the cap would be a property of the caller's chunking, which §7.2 item 4 forbids.
|
inlineprotectednoexcept |
spanned less what this field spent on skipped subtrees — the number the field-span cap is measured against (§6.2.1).
The cap bounds what the receiver materializes, and spanSkipped_ is exactly what it did not. Saturating rather than wrapping: the two counters are updated in different places, and a cap that ran backwards would be a cap that never fires.
|
inlineprotectednoexcept |
|
inlineprotectednoexcept |
|
inlineprotectednoexcept |
Record that this level's current field is the suspension point.
The innermost level claims suspendDepth_; every level above it then writes its own pathId_ entry as the stack unwinds, so the path is complete by the time feed sees the INCOMPLETE.
| fieldId | Id of this level's field, for the pathId_ entry a level above the suspension records. |
| declined | Whether the field was being skipped rather than read. |
|
inlineprotectednoexcept |
The §7.3 seam: does the delivered field's wire tag match the one the caller's read declares?
A field's tag is its wire type plus, for the fixlen kinds, the subtype — the two are only meaningful together, since fp32, fp64, string and blob all share Wire::Fixlen. Every typed read compares the whole tag here, so half a comparison cannot be written.
On a mismatch the field is left unconsumed: the parser that delivered it — parseTopLevel at the top level, dispatchLevel inside a sequence — then skips it exactly like an unknown id, which is what MESSAGE_SPEC §7.3 requires — this is not an error, and never affects the decode outcome. The skip is counted in skipped_ as a diagnostic.
A read may admit more than one subtype — read(std::string&) takes a string or a blob, since both are fixlen payloads and a std::string is the documented destination for either. That is what the two-subtype overload is for: it is still one comparison of the whole tag, so a refusal counts exactly one skip, never one per candidate.
| wantWire | Wire type the read declares. |
| wantFix | Fixlen subtype it declares; ignored unless wantWire is a fixlen kind and the caller separates the subtypes. |
true when the caller may consume the field.
|
inlinenoexcept |
Wire type of the field currently being delivered.
Valid inside a deliver callback. Introspection only: the typed reads compare the tag themselves and skip a contradicting field (§7.3), so a caller does not need this to be correct — it is here for diagnostics and for code that wants to branch on the delivered form. The type it returns lives in sofab::detail. Reads no bytes and does not consume the field.
|
inlinestaticprotectednoexcept |
|
protected |
Category: a well-formed value did not fit the destination the caller handed over (§6.3's third refusal tier, §6.6.3).
Implies error_.
Lives for exactly one feed, like error_ and limitExceeded_, and is latched into terminal_ as Error::InvalidArgument by the feed that saw it.
|
staticconstexprprotected |
Upper bound of any header-declared need (§6.2 ceilings).
|
protected |
Can the field-span cap provably not fire anywhere in the window being parsed (§6.2.1, #26)? Set once per parseWindow.
Every span the cap measures in one window is at most spanCarry_ plus the window's length, and every header-declared need is at most CAP_NEED_MAX (the §6.2 ceilings: ARRAY_MAX elements of at most FIXLEN_MAX bytes). When the stated budget covers both, exceedsBuffer would answer false for every field of the window, so asking it per field is work with a known answer. This is not an unlimited mode: the receiver's number is still the only input, and a budget that could be reached keeps the per-field check exactly as before.
|
protected |
The prefix of one cut item, carried to the next feed.
This is what replaced the private reassembly accumulator §6.6.2 forbids: "A payload split across fed chunks has to be joined somewhere. That somewhere is storage the caller supplied — the codec copies each piece into it as the piece arrives … A codec <strong>MUST NOT</strong> grow a private accumulator instead." A fixed array of CARRY_CAP bytes cannot be grown, and a sender cannot make it larger by sending different bytes, which is §6.6's whole test.
|
staticconstexprprotected |
Widest prefix of a wire item that can outlive a chunk boundary, derived from this format's own constants (§6.6).
The parse never backs up over a payload — a string, a blob or an array element run is written into the caller's destination piece by piece as the pieces arrive (§6.6.2) — so what a chunk boundary can cut in half is only ever a small item: a field header, the words between it and its payload, a lone varint element, or a fixed-width scalar. The widest of those is an ARRAY_FIXLEN field's prefix: the header word, the element count and a fixlen_word, three varints of at most detail::VARINT_MAX_BYTES each.
That is what makes carry_ bounded working state in §6.6's sense rather than an accumulator: a constant of the specification caps it, no wire number can enlarge it, and it is sized when the decoder is constructed.
|
protected |
|
protected |
|
protected |
|
protected |
The tightest armed element-index bound of the wrapper sequence being read (§5.1); -1 = none.
A fast gate only — it answers "is any bound crossed?" in one compare. Which of §6.3's three tiers a crossing belongs to is decided by rejectElementIndex from the three bounds below, and only once a crossing has actually happened.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Sticky "this feed was refused" flag, and the only one the parse loops test.
Raised by every refusal, whichever of §6.3's three tiers it belongs to: invalidate raises it alone, exceedLimit and rejectDestination raise it alongside their own category flag. That keeps the per-field test in dispatchLevel and parseTopLevel a single load — the categories are read once, by feed, when the parse has already stopped.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
The receiver's byte budget for one top-level field (Limits::max_buffered_field), as this decode was told it.
Deliberately uninitialised here: there is no value this library may pick (§6.2.1), so the only way to reach it is through the constructor below, which every stream has to go through.
|
protected |
Id of the sequence field entered at each open level (§4.9).
A nested sequence cannot be resumed by remembering a byte offset: the handler chain that was descending into it lives on the C++ stack, which a feed returning unwinds. What survives is the path — one field id per open level — and replaying it re-enters exactly the handlers that were open, because each level's deserialize dispatches on the id. At most MAX_DEPTH ids, sized at construction (§6.6).
|
protected |
That level was entered by skipPayload, not by a handler.
|
protected |
A field at suspendDepth_ is half-delivered.
|
protected |
That field's header, kept apart from the live type_ / fixLen_ / count_.
The live metadata belongs to whatever field the parser is looking at now, and re-descending pathId_ overwrites it with each sequence header it replays. The suspended field's own header therefore has to be kept separately and put back once its level is reached again — it is the header the read will be continued under, and re-parsing it is exactly what there are no bytes for.
|
protected |
|
protected |
That field's header, kept apart from the live type_ / fixLen_ / count_.
The live metadata belongs to whatever field the parser is looking at now, and re-descending pathId_ overwrites it with each sequence header it replays. The suspended field's own header therefore has to be kept separately and put back once its level is reached again — it is the header the read will be continued under, and re-parsing it is exactly what there are no bytes for.
|
protected |
That field's header, kept apart from the live type_ / fixLen_ / count_.
The live metadata belongs to whatever field the parser is looking at now, and re-descending pathId_ overwrites it with each sequence header it replays. The suspended field's own header therefore has to be kept separately and put back once its level is reached again — it is the header the read will be continued under, and re-parsing it is exactly what there are no bytes for.
|
protected |
That field's header, kept apart from the live type_ / fixLen_ / count_.
The live metadata belongs to whatever field the parser is looking at now, and re-descending pathId_ overwrites it with each sequence header it replays. The suspended field's own header therefore has to be kept separately and put back once its level is reached again — it is the header the read will be continued under, and re-parsing it is exactly what there are no bytes for.
|
protected |
...and it was declined, so skipPayload resumes it rather than the handler.
|
protected |
That field's header, kept apart from the live type_ / fixLen_ / count_.
The live metadata belongs to whatever field the parser is looking at now, and re-descending pathId_ overwrites it with each sequence header it replays. The suspended field's own header therefore has to be kept separately and put back once its level is reached again — it is the header the read will be continued under, and re-parsing it is exactly what there are no bytes for.
|
protected |
Re-descending pathId_ to reach suspendDepth_.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Is the parse currently inside a skipped sequence subtree (§6.2.1, #129)?
The accruing arm of the field-span cap (beginField) is off while it is set. A skipped subtree is walked, never materialized, so no receiver limit governs it — the same reason skipSequence suspends the element-index bound, and set and restored in the same place, for the same subtree.
|
protected |
Bytes of the current top-level field spent on SKIPPED subtrees (§6.2.1, #129 one level down).
spanned counts the field's raw byte span, which is what the accruing arm of the field-span cap used to measure. Inside a sequence this receiver DOES read, that span also contains every child it does NOT — an unknown id, or one §7.3 declines — and those bytes are walked, never materialized. §6.2.1: "a field the handler skips allocates nothing", so "a decode that steps over an over-cap field it was never going to read stays COMPLETE". spanSkip_ suppresses the check inside such a subtree; this discounts what the subtree cost, so the live field AFTER it — the sequence end included — is measured against the bulk this receiver actually took on and not against the sender's padding. Reset with spanCarry_, and carried across chunks for the same reason it is.
|
protected |
Depth at which the parse is suspended, or -1 when nothing is.
The decoder resumes rather than re-parses, so a field that straddles a chunk boundary is never delivered from the beginning again. Three pieces of fixed-size state describe where it stopped: this depth, pathId_ / pathSkip_ for the sequences that are open above it, and pend_ / pendDone_ for the field itself.
|
protected |
The stream's latched terminal verdict, or Error::None while the stream is still usable (§5.2, §6.3).
error_, limitExceeded_ and argError_ live for exactly one feed; this outlives it. INVALID is terminal — §5.2 answers "can
more bytes change it?" with "no — terminal" — and LimitExceeded is "a
terminal, receiver-local policy rejection" (§6.3). InvalidArgument (§6.3's third tier) is terminal for the same reason the other two are: the field was refused rather than consumed, and letting a later chunk "recover" it would make the verdict depend on where the chunk boundaries fell. So once any of the three is the answer it stays the answer for every later feed, until reset starts a new message. Without the latch the verdict would depend on where the chunk boundaries fell: the offending bytes are consumed and gone, so the next call would start from a clean slate and resynchronize on whatever follows the fault — exactly the divergence §7.2 item 4 forbids.
|
protected |
|
protected |
|
protected |