61 template <
typename Elem>
63 [] ()
constexpr ->
int
65 if constexpr (std::is_base_of_v<IStreamMessage, Elem>)
69 else if constexpr (
requires {
typename Elem::value_type; })
71 using RowElem =
typename Elem::value_type;
72 if constexpr (std::is_same_v<RowElem, float> || std::is_same_v<RowElem, double>)
76 else if constexpr (std::is_integral_v<RowElem>)
78 return static_cast<int>(
102 template <
typename Elem>
104 [] ()
constexpr ->
int
106 if constexpr (!std::is_base_of_v<IStreamMessage, Elem>
107 &&
requires {
typename Elem::value_type; })
109 using RowElem =
typename Elem::value_type;
110 if constexpr (std::is_same_v<RowElem, float>)
114 else if constexpr (std::is_same_v<RowElem, double>)
168 template <
typename Container>
172 using Elem =
typename Container::value_type;
180 "FixedMessageSeq needs a heap-free container: its capacity IS the "
181 "schema bound this collector applies. Use sofab::MessageSeq, with an "
182 "explicit cap, for a growable one.");
195 if (
static_cast<int>(
is.wire()) !=
elemWire)
return;
199 if (
static_cast<int>(
is.fixType()) !=
elemFix)
return;
206 while (
out->size() <=
static_cast<size_t>(
id)) (
void)
out->emplace_back();
208 if constexpr (std::is_base_of_v<IStreamMessage, Elem>)
252 template <
typename Container>
256 using Elem =
typename Container::value_type;
273 if (
static_cast<int>(
is.wire()) !=
elemWire)
return;
277 if (
static_cast<int>(
is.fixType()) !=
elemFix)
return;
289 while (
out->size() <=
static_cast<size_t>(
id)) (
void)
out->emplace_back();
291 if constexpr (std::is_base_of_v<IStreamMessage, Elem>)
354 template <
typename Container,
typename Reader>
358 using Elem =
typename Container::value_type;
361 static constexpr int elemWire =
static_cast<int>(Reader::wire());
364 "FixedRowSeq needs a heap-free container: its capacity IS the "
365 "schema bound this collector applies. Use sofab::RowSeq, with an "
366 "explicit cap, for a growable one.");
373 if (
static_cast<int>(
is.wire()) !=
elemWire)
return;
379 while (
out->size() <=
static_cast<size_t>(
id)) (
void)
out->emplace_back();
389 template <
long Count>
431 static_assert(
Count >= -1,
"Count is a schema count, or -1 for runtime bounds");
434 using Elem =
typename Container::value_type;
437 static constexpr int elemWire =
static_cast<int>(Reader::wire());
444 if (
static_cast<int>(
is.wire()) !=
elemWire)
return;
445 if constexpr (
Count >= 0)
447 if (
static_cast<size_t>(
id) >=
static_cast<size_t>(
Count))
453 else if (
seqRefuse(
is,
static_cast<size_t>(
id) + 1, this->cap, this->dynCap))
457 while (
out->size() <=
static_cast<size_t>(
id)) (
void)
out->emplace_back();
A CORELIB_PLAN §6.2.1 receiver cap, exactly as the caller states it.
constexpr std::size_t value() const noexcept
The stated maximum. Meaningless unless stated.
constexpr bool stated() const noexcept
Whether the caller stated a number at all.
Base input stream: incrementally decodes fed bytes into bound targets.
Base class for decodable message objects.
uint32_t sofab_id_t
Field identifier type.
constexpr int seq_elem_wire_v
Wire type an element of type Elem arrives with, or -1 for none.
@ ArrayUnsigned
Count-prefixed array of unsigned varints.
@ ArraySigned
Count-prefixed array of zig-zag varints.
@ ArrayFixlen
Count-prefixed array of fixed-size elements.
@ SequenceStart
Opens a nested sub-message.
bool bitsEqual(const T *a, std::size_t na, const T *b, std::size_t nb) noexcept
True iff both float arrays have the same length and the same bit pattern at every index.
bool seqRefuse(IStreamImpl &is, size_t n, long schemaBound, DynCap dynCap) noexcept
Apply a collector's message-side bounds and report the verdict.
constexpr int seq_elem_fix_v
Fixlen sub-type an element of type Elem arrives with, or -1.
sofab_id_t id
Field identifier type (alias of sofab_id_t).
@ Fp32
32-bit IEEE-754 float.
@ Fp64
64-bit IEEE-754 double.
SofaBuffers C++ - Input and output stream decoder for Sofab messages.
Collects a struct/union or nested-array wrapper sequence into inline storage.
static constexpr int elemWire
Declared element wire type, or -1 (seq_elem_wire_v).
void deserialize(IStreamImpl &is, sofab_id_t id, size_t, size_t count) noexcept override
Dispatch one decoded field to the appropriate read.
static constexpr int elemFix
Declared element fixlen sub-type, or -1 (seq_elem_fix_v).
typename Container::value_type Elem
Element type: an IStreamMessage, or a row container.
Container * out
Destination, bound by IStreamImpl::readSequence.
Collects a wrapper sequence of rows the stream cannot read on its own, into inline storage.
Reader readRow
The row read.
void deserialize(IStreamImpl &is, sofab_id_t id, size_t, size_t count) noexcept override
Dispatch one decoded field to the appropriate read.
static constexpr int elemWire
Declared row wire type (§7.3), from Reader.
typename Container::value_type Elem
Row type: the container's element.
Container * out
Destination, bound by IStreamImpl::readSequence.
Collects a struct/union or nested-array wrapper sequence into a growable container.
void deserialize(IStreamImpl &is, sofab_id_t id, size_t, size_t count) noexcept override
Dispatch one decoded field to the appropriate read.
Container * out
Destination, bound by IStreamImpl::readSequence.
DynCap dynElemCount
§6.2.1 receiver cap on a row's element count; required where elemCount is -1.
static constexpr int elemFix
Declared element fixlen sub-type, or -1 (seq_elem_fix_v).
static constexpr int elemWire
Declared element wire type, or -1 (seq_elem_wire_v).
long elemCount
A ROW element's own schema count, or -1. Ignored for message elements.
long cap
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.
typename Container::value_type Elem
Element type: an IStreamMessage, or a row container.
The index bounds of a RowSeq whose schema count is not a template argument: the schema count and the ...
Collects a wrapper sequence of rows the stream cannot read on its own, into a growable container.
typename Container::value_type Elem
Row type: the container's element.
static constexpr int elemWire
Declared row wire type (§7.3), from Reader.
void deserialize(IStreamImpl &is, sofab_id_t id, size_t, size_t count) noexcept override
Dispatch one decoded field to the appropriate read.
Reader readRow
The row read.
Container * out
Destination, bound by IStreamImpl::readSequence.