SofaBuffers C/C++ 0.12.0
API Documentation
Loading...
Searching...
No Matches
sofab::FixedMessageSeq< Container > Struct Template Reference

Collects a struct/union or nested-array wrapper sequence into inline storage. More...

#include <seq.hpp>

Inheritance diagram for sofab::FixedMessageSeq< Container >:
[legend]
Collaboration diagram for sofab::FixedMessageSeq< Container >:
[legend]

Public Types

using Elem = typename Container::value_type
 Element type: an IStreamMessage, or a row container.
 

Public Member Functions

void deserialize (IStreamImpl &is, sofab_id_t id, size_t, size_t count) noexcept override
 Dispatch one decoded field to the appropriate read.
 

Data Fields

Container * out = nullptr
 Destination, bound by IStreamImpl::readSequence.
 

Static Public Attributes

static constexpr int elemWire = seq_elem_wire_v<Elem>
 Declared element wire type, or -1 (seq_elem_wire_v).
 
static constexpr int elemFix = seq_elem_fix_v<Elem>
 Declared element fixlen sub-type, or -1 (seq_elem_fix_v).
 

Detailed Description

template<typename Container>
struct sofab::FixedMessageSeq< Container >

Collects a struct/union or nested-array wrapper sequence into inline storage.

The object counterpart of FixedStringSeq: same placement rule, same bound, filling elements that are messages (a struct or union) or rows of native scalars (a matrix) rather than FixedString slots. Bind it the way its four siblings are bound, through IStreamImpl::readSequence.

An element is placed at its index id, never appended. MESSAGE_SPEC §5.1 makes the element's child id the array index, and the ids may have gaps: an interior element equal to the element default is left off the wire by a conformant encoder (§2), so the container is grown with default elements up to the id and the value stored there. Appending instead would silently shorten the array by every gap — elements at id 0 and id 2 are the 3-element array [a, default, c], not [a, c] — and would turn a reopened element id into a second element instead of continuing the first (§7.4). The array's last element is always on the wire, so the decoded length (highest present id + 1) is exact; the schema count is a capacity and never adds an element the wire did not carry.

An index at or past the fixed capacity N is a schema-bound violation (§5.1/§7) and is rejected with IStreamImpl::invalidate, before the fill loop. That also bounds an over-index amplification: InlineVector reuses its last slot once full, so an unguarded fill loop would spin forever on such an index (issue #126), and no announced index can make the receiver reserve anything.

An element whose wire type contradicts the declared one is skipped exactly like an unknown id (§7.3), which means it must leave the container untouched — so that decision, too, comes before the fill.

Inline storage never reallocates, so an element bound earlier stays address-stable while later slots grow, which the deferred C decoder relies on.

Template Parameters
ContainerInline vector of messages, or of rows.

Definition at line 169 of file seq.hpp.

Member Typedef Documentation

◆ Elem

template<typename Container >
using sofab::FixedMessageSeq< Container >::Elem = typename Container::value_type

Element type: an IStreamMessage, or a row container.

Definition at line 172 of file seq.hpp.

Member Function Documentation

◆ deserialize()

template<typename Container >
void sofab::FixedMessageSeq< Container >::deserialize ( IStreamImpl &  _istream,
sofab_id_t  _id,
size_t  _size,
size_t  _count 
)
inlineoverridevirtualnoexcept

Dispatch one decoded field to the appropriate read.

Called for each field of this message; implementations typically switch on _id and call _istream.read(member).

Parameters
_istreamStream to bind the field's destination on.
_idField identifier.
_sizeField value size in bytes (e.g. string/blob length).
_countNumber of array elements (for array fields).

Implements sofab::IStreamMessage.

Definition at line 186 of file seq.hpp.

Here is the call graph for this function:

Field Documentation

◆ elemFix

Declared element fixlen sub-type, or -1 (seq_elem_fix_v).

Definition at line 177 of file seq.hpp.

◆ elemWire

Declared element wire type, or -1 (seq_elem_wire_v).

Definition at line 175 of file seq.hpp.

◆ out

Destination, bound by IStreamImpl::readSequence.

Definition at line 184 of file seq.hpp.


The documentation for this struct was generated from the following file: