template<typename C, typename Reader>
struct sofab::RowSeq< C, Reader >
Collects a wrapper sequence whose elements are rows the stream cannot read on its own — a row that is itself a wrapper sequence (array<array<string>>, array<array<struct>>, deeper), or a row that must bind through a view of its elements (an enum or boolean row).
MessageSeq hands each element to IStreamImpl::read, which reads a message or a span of native scalars and nothing else. A row of strings is neither, so its read has to be stated by the caller: that is Reader, and it is the only part of a row collector that differs between schemas. Everything else is the wrapper-array rule every collector here applies, in the same order:
- §7.3 first. An element whose wire type contradicts the row's is not an element of this array at all. It is skipped like an unknown id, before the index bound — so it cannot breach it — and before the placement, so the destination is left exactly as it was. The row's wire type is published as elemWire, so the stream runs the same test one step earlier, at the element header, and applies the bound only to an element that survives it.
- §5.1 index bound, in §6.3's three categories (detail::seqIndexAdmitted): the schema
count (cap, InvalidMessage), else the receiver cap (dynCap, LimitExceeded), and the destination's own capacity (elemDestCap).
- Placement. The element id IS the index: the container is grown with default rows up to it and the row is read in place at
dest[id].
- §7.4. A repeated field id replaces the array whole, via prepare.
- Template Parameters
-
| C | Destination container of rows — std::vector<Row> or InlineVector<Row, N>; deduced from the constructor. |
| Reader | The row read, one level down. A default-constructible type with
static constexpr detail::Wire wire(), the wire type a row of this schema arrives with — SequenceStart for a row that is a wrapper sequence, the array wire type of the backing integer for an enum or boolean row; and
void operator()(IStreamImpl &, typename C::value_type &), reading the row that was placed.
|
wire() is a function rather than a constant because a local class — which is where generated code declares the reader, next to the field it reads — may not have static data members.
- Example
struct Row {
}
};
Base of the input streams: decodes fields from fed bytes.
Wire
Wire type stored in the low 3 bits of every field header.
@ SequenceStart
Opens a nested sub-message.
bool read(IStreamImpl &is, T &dst) noexcept
IStreamImpl::read with the destination sized first — the generated layer's untyped read.
Collects a wrapper sequence whose elements are rows the stream cannot read on its own — a row that is...
Collects the elements of a string wrapper-sequence array.
Definition at line 7181 of file sofab.hpp.
template<typename C , typename Reader >
|
|
inlineoverridevirtualnoexcept |
Consume one of this message's fields from istream.
Invoked once per field of the message; use id to dispatch and IStreamImpl::read to pull the value.
- Parameters
-
| istream | Stream positioned at the field's value. |
| id | Identifier of the field being delivered. |
| size | Payload length (fixlen) or element size (fixlen array), in bytes. |
| count | Element count for array fields, otherwise 0. |
Implements sofab::IStreamMessage.
Definition at line 7219 of file sofab.hpp.
template<typename C , typename Reader >
§7.4 replace-whole, and absent ⇒ never called:
§7.4: the sequence IS the array's value, so a repeated field id replaces it whole.
IStreamImpl::read calls this once the SequenceStart tag matched, so a §7.3-skipped occurrence cannot wipe a valid earlier one.
- Warning
- It runs only when the wrapper sequence is present. Since MESSAGE_SPEC §2 omits an all-default array field, an absent field reaches no collector at all and
out is left exactly as it was — so a destination reused across messages must be reset by its owner first (IStreamObject::reset, §5.1 "supplying a
cleanly initialised destination is the application's
responsibility"). This is not the collector's call to make: it never learns that the field was absent.
Definition at line 7217 of file sofab.hpp.
template<typename C , typename Reader >
The configured receiver cap on the element index (max_dyn_array_count, §6.2.1); negative means none.
A wrapper array carries no count header, so there is no count word for a cap to bind: "for a <strong>sequence array</strong> it surfaces the <strong>index</strong> of the
element in hand — a wrapper array's length is <em>highest present id + 1</em>
(MESSAGE_SPEC §5.1), so the index is what has to be checked, there being
no count header to check." An id at or past this is Error::LimitExceeded, decided before out is extended, so an announced index never becomes an allocation.
Deliberately not StringSeq::cap — cap is the schema count and its breach is InvalidMessage — the bytes contradict the schema both peers agreed on — while this is a policy rejection the same bytes survive under a looser cap, and §6.2.1 forbids folding the two. It is also ignored while cap is armed, since a receiver limit "MUST NOT be
applied to a field the schema already bounds". The number itself is generated code's to supply (§6.2.1: "The numbers and the allocation are
not the codec's"). There is no default: the constructor takes it, and a collector built without one does not compile. (corelib-cpp#124)
Definition at line 7192 of file sofab.hpp.
template<typename C , typename Reader >
The destination's own capacity, or -1 for a growable container.
§6.3's third tier: an index the container cannot hold, with neither the schema nor the deployment objecting, is Error::InvalidArgument. For a fixed-capacity container this is also what keeps the placement loop below terminating — InlineVector::emplace_back reuses the last slot once full, so out.size() would never pass a large id.
Definition at line 7197 of file sofab.hpp.