MessageVisitor class abstract
A consumer of a SofaBuffers stream (CORELIB_PLAN §5.2, §5.3 — the visitor pattern), and the only decode surface (§5.3.1).
One call per field, made at the field's header — before any payload byte is consumed:
- a scalar arrives as its value: onUnsigned, onSigned, onFp32 (or onFp32Bits for a NaN), onFp64. A varint has to be read to be stepped over, so delivering it costs nothing a skip would not; a scalar the visitor does not want is simply ignored.
- an aggregate — onString, onBlob, onUnsignedArray,
onSignedArray, onFp32Array, onFp64Array — is told its announced byte
length or element count and answers with the destination to decode it
into (an
Inline…wrapper, §6.6.3), ornullto skip it. The codec sets the wrapper'slengthright there and writes the payload into itsstorage; nothing is called when it is whole. Nobody reads a destination whilefeedis still running — the object is complete whenfeed/decodereports DecodeStatus.complete — so a completion call would carry nothing (corelib-c-cpp has none either). - a sequence is entered through onSequenceStart, which returns the
visitor for its fields or
nullto skip it, and left through onSequenceEnd.
The header call is also where every bound on the field is judged, and the
only place (§6.2.1): a schema bound (count/maxlen, MESSAGE_SPEC §7.1) is
refused with invalidate, a receiver cap on a schema-unbounded field with
limitExceeded — both before the destination is chosen, which is the
allocation they exist to prevent, and both dominating a truncated payload
(§5.2). A field answered with null is skipped: no bound applies to it
(§6.2.1 — "a skipped field is never capped"), its payload is stepped over
by its length and never inspected (§6.4 — a skipped string is never
UTF-8-validated), and only the wire's own structure is still checked.
Every default is "not interested": scalars are ignored, aggregates and
sequences skipped. A visitor overrides the calls for the fields it has a
place for. Booleans arrive via onUnsigned (any non-zero is true, §4.4);
a boolean array's destination carries ElemRange.boolean, and the codec
holds its elements as 0/1.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
invalidate(
) → void -
Reject the running decode as
INVALIDfrom inside a callback. -
limitExceeded(
) → void - Reject the running decode as DecodeStatus.limitExceeded from inside a callback — the receiver-cap counterpart of invalidate.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onBlob(
int id, int length) → InlineBytes? -
A
blobfield announcinglengthbytes. Return the destination —capacityat leastlength— ornullto skip it. -
onFp32(
int id, double value) → void -
onFp32Array(
int id, int count) → InlineFloat32Array? -
An fp32 array announcing
countelements, asked once itsfixlen_wordhas been read and validated — so the element kind is the real one, never a collapsed "fixlen" (§4.8). A message that ends between the count and that word is INCOMPLETE: the field cannot be identified yet. -
onFp32Bits(
int id, int bits) → void -
Delivered for an fp32 field whose payload is a NaN, carrying the raw
32-bit IEEE-754 bit pattern so a signaling NaN survives bit-for-bit — a
Dart
doublewould quiet it (CORELIB_PLAN §4.6: never normalize). The default widens to adoubleand forwards to onFp32, so a consumer that does not care about NaN bit patterns needs no change; override this to capture the exact bits (and re-emit them withEncoder.writeFp32Bits). -
onFp64(
int id, double value) → void -
onFp64Array(
int id, int count) → InlineFloat64Array? -
An fp64 array announcing
countelements — see onFp32Array. -
onSequenceEnd(
) → void - The sequence whose fields this visitor received has closed.
-
onSequenceStart(
int id) → MessageVisitor? -
A sequence opened. Return the visitor for its fields (which follows the
same contract, recursively —
thisfor a flat consumer), ornullto skip the whole sub-sequence. -
onSigned(
int id, int value) → void -
onSignedArray(
int id, int count) → InlineInt64Array? -
A signed (zig-zag) integer array announcing
countelements — see onUnsignedArray. -
onString(
int id, int length) → InlineString? -
A
stringfield announcinglengthUTF-8 bytes. Return the destination to decode it into — itscapacityat leastlength— ornullto skip it. -
onUnsigned(
int id, int value) → void -
onUnsignedArray(
int id, int count) → InlineInt64Array? -
An unsigned-integer array announcing
countelements. Return the destination —capacityat leastcount— ornullto skip it. Itsrange, if set, is applied to every element as it is decoded. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited