|
SofaBuffers C/C++ 0.12.0
API Documentation
|
Namespaces | |
| namespace | detail |
Data Structures | |
| class | DynCap |
| A CORELIB_PLAN §6.2.1 receiver cap, exactly as the caller states it. More... | |
| struct | FixedBlobSeq |
| class | FixedBytes |
Fixed-capacity, heap-free byte blob of up to N bytes. More... | |
| struct | FixedMessageSeq |
| Collects a struct/union or nested-array wrapper sequence into inline storage. More... | |
| struct | FixedRowSeq |
| Collects a wrapper sequence of rows the stream cannot read on its own, into inline storage. More... | |
| class | FixedString |
Fixed-capacity, heap-free string of up to N characters. More... | |
| struct | FixedStringSeq |
Collects a string wrapper sequence into inline storage. More... | |
| class | InlineVector |
Fixed-capacity, heap-free sequence of up to N elements of type T. More... | |
| struct | is_fixed_bytes |
| Trait: true only for FixedBytes specializations. More... | |
| struct | is_fixed_bytes< FixedBytes< N > > |
| struct | is_fixed_string |
| Trait: true only for FixedString specializations. More... | |
| struct | is_fixed_string< FixedString< N > > |
| class | IStreamImpl |
| Base input stream: incrementally decodes fed bytes into bound targets. More... | |
| class | IStreamInline |
| Input stream driven by a user-supplied per-field callback. More... | |
| class | IStreamInto |
| Decoder that decodes into a message instance the CALLER owns. More... | |
| class | IStreamMessage |
| Base class for decodable message objects. More... | |
| class | IStreamObject |
| Self-contained decoder that owns a message instance. More... | |
| struct | Message |
| A message that both encodes and decodes: exactly OStreamMessage + IStreamMessage. More... | |
| struct | MessageSeq |
| Collects a struct/union or nested-array wrapper sequence into a growable container. More... | |
| class | OStreamImpl |
| Base output stream: encodes fields into a caller-provided buffer. More... | |
| class | OStreamInline |
| Output stream backed by an inline, fixed-size buffer. More... | |
| class | OStreamMessage |
| Base class for serializable message objects. More... | |
| class | OStreamObject |
| Self-contained encoder that owns a message and an inline buffer. More... | |
| class | OStreamObjectOffset |
| OStreamObject variant parameterized by offset only. More... | |
| class | OStreamView |
| Output stream over a buffer the caller already owns. More... | |
| struct | RowSeq |
| Collects a wrapper sequence of rows the stream cannot read on its own, into a growable container. More... | |
| struct | RowSeqBounds |
The index bounds of a RowSeq whose schema count is not a template argument: the schema count and the §6.2.1 receiver cap, as runtime members, exactly as MessageSeq carries them. More... | |
| struct | RowSeqBounds<-1 > |
The index bounds of a RowSeq whose schema count is not a template argument: the schema count and the §6.2.1 receiver cap, as runtime members, exactly as MessageSeq carries them. More... | |
| struct | wire_int |
| The integer type an element travels as on the wire: identity for an integer, the declared underlying type for an enumeration. More... | |
| struct | wire_int< E, true > |
| Enumeration case of wire_int: the declared underlying type. More... | |
Concepts | |
| concept | HasMaxSize |
| Detects the CORELIB_PLAN §6.1.1 spelling of the worst-case size. | |
| concept | HasLegacyMaxSize |
| Detects the pre-0.11 spelling. Deprecated; see OutputMessage. | |
| concept | OutputMessage |
| Concept: a serializable message type usable with OStreamObject. | |
| concept | InputMessage |
Concept: a decodable message type usable with IStreamObject and the nested-message IStreamImpl::read() overload. | |
| concept | HasFixedCapacity |
Detects a container that states its own fixed capacity: the condition behind fixed_capacity_v. | |
Typedefs | |
| template<typename E > | |
| using | wire_int_t = typename wire_int< E >::type |
| Alias for wire_int. | |
| using | id = sofab_id_t |
| Field identifier type (alias of sofab_id_t). | |
Enumerations | |
| enum class | Error { None = SOFAB_RET_OK , Incomplete = SOFAB_RET_INCOMPLETE , BufferFull = SOFAB_RET_E_BUFFER_FULL , InvalidArgument = SOFAB_RET_E_ARGUMENT , InvalidMessage = SOFAB_RET_E_INVALID_MSG , LimitExceeded = SOFAB_RET_E_LIMIT_EXCEEDED } |
| Result/error code returned by the stream APIs (wraps sofab_ret_t). More... | |
| enum class | Wire : uint8_t { Unsigned = SOFAB_TYPE_VARINT_UNSIGNED , Signed = SOFAB_TYPE_VARINT_SIGNED , Fixlen = SOFAB_TYPE_FIXLEN , ArrayUnsigned = SOFAB_TYPE_VARINTARRAY_UNSIGNED , ArraySigned = SOFAB_TYPE_VARINTARRAY_SIGNED , ArrayFixlen = SOFAB_TYPE_FIXLENARRAY , SequenceStart = SOFAB_TYPE_SEQUENCE_START , SequenceEnd = SOFAB_TYPE_SEQUENCE_END } |
| Wire type of a decoded field (the 3-bit type tag of its header). More... | |
| enum class | Fix : uint8_t { Fp32 = SOFAB_FIXLENTYPE_FP32 , Fp64 = SOFAB_FIXLENTYPE_FP64 , String = SOFAB_FIXLENTYPE_STRING , Blob = SOFAB_FIXLENTYPE_BLOB } |
| Sub-type of a length-prefixed (Wire::Fixlen) payload. More... | |
Functions | |
| template<typename T > | |
| 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. | |
| template<typename A , typename B > | |
| bool | bitsEqual (const A &a, const B &b) noexcept |
Container form of bitsEqual: anything contiguous that std::data / std::size accept and that holds float or double. | |
| bool | seqRefuse (IStreamImpl &is, size_t n, long schemaBound, DynCap dynCap) noexcept |
| Apply a collector's message-side bounds and report the verdict. | |
| template<typename C > | |
| std::span< const typename C::value_type > | trimTail (const C &a) noexcept |
| Narrow a fixed-count array to its non-default prefix, for encode. | |
Variables | |
| template<typename Elem > | |
| constexpr int | seq_elem_wire_v |
Wire type an element of type Elem arrives with, or -1 for none. | |
| template<typename Elem > | |
| constexpr int | seq_elem_fix_v |
Fixlen sub-type an element of type Elem arrives with, or -1. | |
| constexpr int | API_VERSION = 1 |
| SofaBuffers C++ API version (mirrors SOFAB_API_VERSION). | |
| constexpr bool | ENCODE_BOUNDS = SOFAB_CPP_HAVE_ENCODE_BOUNDS != 0 |
Whether generated encode refuses an over-bound value (SOFAB_CPP_HAVE_ENCODE_BOUNDS; off with SOFAB_DISABLE_ENCODE_BOUNDS). | |
| template<typename > | |
| constexpr bool | always_false_v = false |
Always-false trait used to trigger a dependent static_assert in a discarded if constexpr branch (so it only fires when instantiated). | |
| template<typename T > | |
| constexpr bool | is_fixed_string_v |
| Convenience value for is_fixed_string. | |
| template<typename T > | |
| constexpr bool | is_fixed_bytes_v |
| Convenience value for is_fixed_bytes. | |
| template<class T > | |
| constexpr size_t | max_size_v |
The worst-case encoded size of a generated message, whichever spelling it declares. Prefers MAX_SIZE. | |
| template<typename C > | |
| constexpr long | fixed_capacity_v = -1 |
| Compile-time capacity a heap-free container publishes, or -1. | |
| template<HasFixedCapacity C> | |
| constexpr long | fixed_capacity_v< C > = static_cast<long>(C::capacity()) |
Field identifier type (alias of sofab_id_t).
|
strong |
Result/error code returned by the stream APIs (wraps sofab_ret_t).
| Enumerator | |
|---|---|
| None | Success (a complete message boundary). |
| Incomplete | Consumed bytes end inside a field or with an open sequence: a valid but partial decode. NOT an error — the caller owns end-of-input and may feed more bytes. Distinct from |
| BufferFull | Output buffer overflowed during encoding. |
| InvalidArgument | A field id out of range, a scalar width that is not 1/2/4/8 — or a destination too short for the value it was handed (§6.6.3): the third of the three ways a value can be refused, and the one that is a mistake in the call. |
| InvalidMessage | Malformed message encountered while decoding. |
| LimitExceeded | A configured receiver limit (§6.2.1) was. exceeded on a schema-**unbounded** field. The bytes are well-formed and decode under a looser limit, so this is deliberately not This corelib never decides it. §6.2.1 gives the limits to generated code — "the visitor
decides. The codec never invents a limit of its
own and never clamps to one" — and leaves the codec "the report and the category". This enumerator is the category; the report is the |
|
strong |
Sub-type of a length-prefixed (Wire::Fixlen) payload.
Part of the public API: returned by IStreamImpl::fixType. MESSAGE_SPEC §7.3 bounds the decode-side type check at wire type plus this subtype, since fp32 / fp64 / string / blob all share the Wire::Fixlen wire type. Mirrors sofab_fixlentype_t and matches corelib-cpp's sofab::Fix.
| Enumerator | |
|---|---|
| Fp32 | 32-bit IEEE-754 float. |
| Fp64 | 64-bit IEEE-754 double. |
| String | UTF-8 text. |
| Blob | Opaque byte string. |
|
strong |
Wire type of a decoded field (the 3-bit type tag of its header).
Part of the public API: returned by IStreamImpl::wire. The enumerator values are the wire tags themselves, so this mirrors sofab_type_t while exposing the same sofab::Wire surface as the sibling corelib-cpp — a generator emits one IStreamImpl::wire guard shape for both.
|
inlinenoexcept |
Container form of bitsEqual: anything contiguous that std::data / std::size accept and that holds float or double.
Takes a mutable field (std::vector, InlineVector, std::array) and a constant default (a temporary of the same type, a std::span, a std::initializer_list) alike, and the two need not be the same container type — only the same element type.
Definition at line 81 of file floats.hpp.
|
inlinenoexcept |
True iff both float arrays have the same length and the same bit pattern at every index.
The length is compared first (early exit); the elements are then compared with one block memcmp over n * sizeof(T) bytes, so there is no IEEE == anywhere. Nothing is allocated or modified.
| T | float (32-bit pattern) or double (64-bit pattern). |
| a | First array, or any pointer when na is 0. |
| na | Length of a in elements. |
| b | Second array, or any pointer when nb is 0. |
| nb | Length of b in elements. |
Definition at line 58 of file floats.hpp.
|
inlinenoexcept |
Apply a collector's message-side bounds and report the verdict.
The collectors below are the static helper layer (§6.6.1): they ship here for reuse, the generated layer owns them, and no codec path calls them — IStreamImpl::readSequence hands control to the caller's collector exactly as it hands control to any other handler. So a bound applied here is generated code's bound, not the codec's, and §6.2.1's "the codec never invents a limit of its own" is kept: every number below arrives in a field the generated layer sets.
A wrapper array is the one shape that has nowhere else to put it. It announces no count and fires no callback per element, so the caller has no point at which to check, and §6.2.1 puts the enforcement point on the element index, before the container is extended.
| is | The stream, for the verdict. |
| n | The index + 1, or the element length. |
| schemaBound | The schema's count / maxlen, or -1. Exceeding it is Error::InvalidMessage. |
| dynCap | The §6.2.1 receiver cap. Consulted only where schemaBound is -1. Exceeding it is Error::LimitExceeded; leaving it unstated there is Error::InvalidArgument, because §6.2.1 has no unlimited mode for it to mean instead. |
true when the element was refused. Definition at line 3845 of file sofab.hpp.
Narrow a fixed-count array to its non-default prefix, for encode.
count: N as a capacity and the wire count M as the array's length, so nothing may be elided: [1,2,3,0,0] and [1,2,3] are different values, and trimming the tail silently shortens the array. There is no fill-back on decode either. This helper is retained only so generated code emitted before the change still compiles; new code must not call it, and it goes away with the generator that emits it. (Its C counterpart, _array_trim_count in object.c, is already gone.)The superseded contract it implements: a count: N array's canonical encoding carries M = one past the last element that differs from the element default, and the decoder refills [M, N).
Elements compare by byte image, never operator==: -0.0 == 0.0 holds in C++, but -0.0 is a distinct value that must survive the round-trip, and a NaN payload likewise never matches the default.
| a | Contiguous container of trivially-copyable elements. |
[0, M). Definition at line 3967 of file sofab.hpp.
SofaBuffers C++ API version (mirrors SOFAB_API_VERSION).
|
inlineconstexpr |
Whether generated encode refuses an over-bound value (SOFAB_CPP_HAVE_ENCODE_BOUNDS; off with SOFAB_DISABLE_ENCODE_BOUNDS).
Compile-time capacity a heap-free container publishes, or -1.
InlineVector, FixedString and FixedBytes all declare capacity() static constexpr, which is what tells them apart from std::vector — whose capacity() is a per-object, runtime quantity and so cannot be called on the type.
count / maxlen, so its capacity is numerically that bound. Whether it is read as that bound depends on whether the caller was told the bound some other way, and the two callers in this header differ:cap at all, by design: their static_assert says the container's capacity is the schema bound they were generated for, because there is no other channel to state it on. For them it is §6.3's first tier, and an element past it is Error::InvalidMessage (MESSAGE_SPEC §7.1).Both are correct, and the difference is not about the number — it is about which channel states it. A collector generated for a bound carries it in the only place it has; a read is told it outright, and applies it through IStreamImpl::refuseSchema (or IStreamImpl::refuseCap, on the …Capped entry point) before it sizes anything.
| C | Container type. |
|
inlineconstexpr |
Convenience value for is_fixed_bytes.
Convenience value for is_fixed_string.
The worst-case encoded size of a generated message, whichever spelling it declares. Prefers MAX_SIZE.
Fixlen sub-type an element of type Elem arrives with, or -1.
The companion to seq_elem_wire_v for the one wire type that is not self-describing: fp32 and fp64 rows share Wire::ArrayFixlen, so §7.3 only separates them at the sub-type. -1 wherever the wire type already settles the element kind.
| Elem | Element type (an IStreamMessage, or a row container). |
Wire type an element of type Elem arrives with, or -1 for none.
MESSAGE_SPEC §7.3 bounds an element by the wire type its declared type implies, and the collectors below must apply that check before they touch the destination — one step earlier than IStreamImpl::read or IStreamImpl::readArray would settle it for themselves. The two must not be able to disagree, so the choice made here mirrors readArray's exactly: a struct/union element is a nested sequence, and a native-scalar row is the array wire type its element kind selects.
-1 means the element type implies no single wire type; the check is then left to the read, which still refuses to bind a contradicting field.
| Elem | Element type (an IStreamMessage, or a row container). |