template<typename C = std::vector<std::string>>
struct sofab::StringSeq< C >
Collects the elements of a string wrapper-sequence array.
MESSAGE_SPEC §5 lowers an array of strings to a sequence whose child ids are the element indices, so an element is placed at its id rather than appended: a default (empty) element is omitted on the wire (§2), and the gap it leaves is filled with the element default.
The schema bounds ride into the read, so a mis-typed element is skipped under §7.3 instead of being measured against bounds that are not its own, and an over-index element that survives that test is rejected by the stream — at the element header for an element type the header settles, and at the fixlen word for a fixlen one, which is where a string element's subtype becomes known.
- Template Parameters
-
| C | Destination container. std::vector<std::string> for the growable storage mode, InlineVector<FixedString<M>, N> for the heap-free one; anything with clear/size/emplace_back/operator[] whose value_type readString accepts will do. Class template argument deduction makes the spelling identical either way: sofab::StringSeq s{dst, count, maxlen}. |
Definition at line 6686 of file sofab.hpp.
template<typename C = std::vector<std::string>>
§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 6791 of file sofab.hpp.
template<typename C = std::vector<std::string>>
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 6713 of file sofab.hpp.
template<typename C = std::vector<std::string>>
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 6739 of file sofab.hpp.
template<typename C = std::vector<std::string>>
The §6.2.1 receiver cap on one ELEMENT's length, or -1 when the caller supplied none.
dynCap bounds how many elements the array may have; this bounds how long each may be. Both are needed: an array of two elements a gigabyte each is under any index cap. It is consulted only where emax is -1 — a receiver limit "MUST NOT be applied to a field the schema already
bounds" — and, like every cap here, it is passed in and never held. There is no default: a negative value means the caller stated no cap, and an element read under one answers Error::InvalidArgument rather than being read unbounded.
Definition at line 6728 of file sofab.hpp.
template<typename C = std::vector<std::string>>
The declared element type, published to the stream (§7.3).
The §5.1/§7 over-index reject applies only to an element whose header agrees with this — one that contradicts it is not this array's element at all and is skipped like an unknown id, bound or no bound. The stream picks these up exactly as it picks up cap; they are compile-time constants, so no constructor signature changes.
Definition at line 6752 of file sofab.hpp.
template<typename C = std::vector<std::string>>
The declared element type, published to the stream (§7.3).
The §5.1/§7 over-index reject applies only to an element whose header agrees with this — one that contradicts it is not this array's element at all and is skipped like an unknown id, bound or no bound. The stream picks these up exactly as it picks up cap; they are compile-time constants, so no constructor signature changes.
Definition at line 6750 of file sofab.hpp.