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

Collects a struct/union or nested-array wrapper sequence into a growable container. More...

#include <seq.hpp>

Inheritance diagram for sofab::MessageSeq< Container >:
[legend]
Collaboration diagram for sofab::MessageSeq< 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.
 
long cap = -1
 Schema count N, or -1 when the schema declares none.
 
DynCap dynCap {}
 §6.2.1 receiver cap on the index; required where cap is -1.
 
long elemCount = -1
 A ROW element's own schema count, or -1. Ignored for message elements.
 
DynCap dynElemCount {}
 §6.2.1 receiver cap on a row's element count; required where elemCount is -1.
 

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::MessageSeq< Container >

Collects a struct/union or nested-array wrapper sequence into a growable container.

The heap counterpart of FixedMessageSeq, for the allow_dynamic storage mode, and the object counterpart of StringSeq: the schema's count still binds, it just is not the container's capacity any more, so it is carried in cap. Placement, gap fill and the §7.3 skip are FixedMessageSeq's, unchanged and documented there; only the bound moves. Named to match sofab::MessageSeq in corelib-cpp so both C++ outputs read alike — the generator emits one call site for the two.

A growable row is bounded by the wire count alone: unlike an inline row it publishes no capacity, and the schema count of the inner array is not something the outer collector is told.

Growing the container may reallocate it, which the deferred decoder would not survive if it moved a destination already bound. It cannot: an element is placed only when its own child field opens, i.e. once the element before it has closed and every target inside it has been filled. That is the same reasoning read(std::vector<std::string>&) relies on; FixedMessageSeq does not need it at all, since inline storage never moves.

Template Parameters
ContainerGrowable container of messages, or of rows.

Definition at line 253 of file seq.hpp.

Member Typedef Documentation

◆ Elem

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

Element type: an IStreamMessage, or a row container.

Definition at line 256 of file seq.hpp.

Member Function Documentation

◆ deserialize()

template<typename Container >
void sofab::MessageSeq< 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 269 of file seq.hpp.

Here is the call graph for this function:

Field Documentation

◆ cap

Schema count N, or -1 when the schema declares none.

Definition at line 264 of file seq.hpp.

◆ dynCap

§6.2.1 receiver cap on the index; required where cap is -1.

Definition at line 265 of file seq.hpp.

◆ dynElemCount

template<typename Container >
DynCap sofab::MessageSeq< Container >::dynElemCount {}

§6.2.1 receiver cap on a row's element count; required where elemCount is -1.

Definition at line 267 of file seq.hpp.

◆ elemCount

template<typename Container >
long sofab::MessageSeq< Container >::elemCount = -1

A ROW element's own schema count, or -1. Ignored for message elements.

Definition at line 266 of file seq.hpp.

◆ elemFix

template<typename Container >
constexpr int sofab::MessageSeq< Container >::elemFix = seq_elem_fix_v<Elem>
staticconstexpr

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

Definition at line 261 of file seq.hpp.

◆ elemWire

template<typename Container >
constexpr int sofab::MessageSeq< Container >::elemWire = seq_elem_wire_v<Elem>
staticconstexpr

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

Definition at line 259 of file seq.hpp.

◆ out

Destination, bound by IStreamImpl::readSequence.

Definition at line 263 of file seq.hpp.


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