SofaBuffers C++ 0.12.0
Pure-C++20 SofaBuffers — API Documentation
Loading...
Searching...
No Matches
sofab::BlobSeq< C > Struct Template Reference

The blob counterpart of StringSeq; see it for the placement and bound rules. More...

#include <sofab.hpp>

Inheritance diagram for sofab::BlobSeq< C >:
[legend]
Collaboration diagram for sofab::BlobSeq< C >:
[legend]

Public Member Functions

 BlobSeq (C &o, long capacity, long elemMax, long indexCap, long elemLenCap) noexcept
 
void prepare () noexcept
 §7.4: the sequence IS the array's value, so a repeated field id replaces it whole.
 
void deserialize (IStreamImpl &is, sofab::id id, size_t size, size_t) noexcept override
 Consume one of this message's fields from istream.
 
- Public Member Functions inherited from sofab::IStreamMessage
virtual ~IStreamMessage ()=default
 

Public Attributes

C & out
 
long cap
 
long emax
 
long dynCap
 The configured receiver cap on the element index (max_dyn_array_count, §6.2.1); negative means none.
 
long elemDynCap
 The §6.2.1 receiver cap on one ELEMENT's length, or -1 when the caller supplied none.
 

Static Public Attributes

static constexpr long elemDestCap = detail::destCapacity<C>()
 The destination's own capacity, or -1 for a growable container.
 
static constexpr int elemWire = static_cast<int>(detail::Wire::Fixlen)
 The declared element type, published to the stream (§7.3).
 
static constexpr int elemFix = static_cast<int>(detail::Fix::Blob)
 The declared element type, published to the stream (§7.3).
 

Detailed Description

template<typename C = std::vector<std::vector<uint8_t>>>
struct sofab::BlobSeq< C >

The blob counterpart of StringSeq; see it for the placement and bound rules.

Template Parameters
CDestination container — std::vector<std::vector<uint8_t>> or InlineVector<FixedBytes<M>, N>; deduced from the constructor.

Definition at line 6841 of file sofab.hpp.

Constructor & Destructor Documentation

◆ BlobSeq()

template<typename C = std::vector<std::vector<uint8_t>>>
sofab::BlobSeq< C >::BlobSeq ( C &  o,
long  capacity,
long  elemMax,
long  indexCap,
long  elemLenCap 
)
inlineexplicitnoexcept

Parameters
oDestination vector; elements are placed at their index id.
capacitySchema count N, or -1 for an unbounded array. An element id at or past N is INVALID (§5.1/§7) once the element has passed the §7.3 type test, rejected before the container grows — which also bounds an over-index allocation.
elemMaxElement maxlen, or -1. A longer element is INVALID (§7.1), never truncated.
indexCapThe caller's max_dyn_array_count (dynCap), or -1 when none was supplied — there is no fallback, so no index cap then applies. An element id at or past it is Error::LimitExceeded, decided before the container grows.
elemLenCapThe caller's max_dyn_string_len / max_dyn_blob_len for one element (elemDynCap), or -1 when none was supplied. Consulted only where elemMax is -1.

Definition at line 6860 of file sofab.hpp.

Member Function Documentation

◆ deserialize()

template<typename C = std::vector<std::vector<uint8_t>>>
void sofab::BlobSeq< C >::deserialize ( IStreamImpl &  istream,
sofab::id  id,
size_t  size,
size_t  count 
)
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
istreamStream positioned at the field's value.
idIdentifier of the field being delivered.
sizePayload length (fixlen) or element size (fixlen array), in bytes.
countElement count for array fields, otherwise 0.

Implements sofab::IStreamMessage.

Definition at line 6868 of file sofab.hpp.

◆ prepare()

template<typename C = std::vector<std::vector<uint8_t>>>
void sofab::BlobSeq< C >::prepare ( )
inlinenoexcept

§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 6866 of file sofab.hpp.

Member Data Documentation

◆ cap

template<typename C = std::vector<std::vector<uint8_t>>>
long sofab::BlobSeq< C >::cap

Definition at line 6844 of file sofab.hpp.

◆ dynCap

template<typename C = std::vector<std::vector<uint8_t>>>
long sofab::BlobSeq< C >::dynCap

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 6847 of file sofab.hpp.

◆ elemDestCap

template<typename C = std::vector<std::vector<uint8_t>>>
constexpr long sofab::BlobSeq< C >::elemDestCap = detail::destCapacity<C>()
staticconstexpr

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 6849 of file sofab.hpp.

◆ elemDynCap

template<typename C = std::vector<std::vector<uint8_t>>>
long sofab::BlobSeq< C >::elemDynCap

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 6857 of file sofab.hpp.

◆ elemFix

template<typename C = std::vector<std::vector<uint8_t>>>
constexpr int sofab::BlobSeq< C >::elemFix = static_cast<int>(detail::Fix::Blob)
staticconstexpr

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 6854 of file sofab.hpp.

◆ elemWire

template<typename C = std::vector<std::vector<uint8_t>>>
constexpr int sofab::BlobSeq< C >::elemWire = static_cast<int>(detail::Wire::Fixlen)
staticconstexpr

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 6852 of file sofab.hpp.

◆ emax

template<typename C = std::vector<std::vector<uint8_t>>>
long sofab::BlobSeq< C >::emax

Definition at line 6845 of file sofab.hpp.

◆ out

template<typename C = std::vector<std::vector<uint8_t>>>
C& sofab::BlobSeq< C >::out

Definition at line 6843 of file sofab.hpp.


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