|
SofaBuffers C++ 0.12.0
Pure-C++20 SofaBuffers — API Documentation
|
The one stream-scoped receiver cap: how many bytes a single top-level field may span. More...
#include <sofab.hpp>
Public Member Functions | |
| constexpr | Limits (size_t maxBufferedField) noexcept |
| State the cap. | |
Public Attributes | |
| size_t | max_buffered_field |
| Cap on how many bytes a single top-level field may span, in bytes. | |
The one stream-scoped receiver cap: how many bytes a single top-level field may span.
LimitExceeded, and every rule §6.2.1 states about a receiver limit therefore binds this one:SIZE_MAX has stated the platform's own ceiling — the check still runs and simply never fires — which is a number the caller chose, not a mode the codec offers. §6.2 ceilings are never reported through Error::LimitExceeded in this library.max_dyn_* caps are not heremax_dyn_array_count, max_dyn_string_len and max_dyn_blob_len are not members of this struct and never were the stream's to hold. Each is a parameter on the call that reads the field it bounds — the dynCap of IStreamImpl::readStringCapped, IStreamImpl::readBlobCapped, IStreamImpl::readArrayCapped and of a wrapper-array collector. They are per field, so they belong on the read; this one is per stream, because a field's span accrues across chunks and across a sequence's children, where no single read exists to carry it.
|
inlineexplicitconstexprnoexcept |
State the cap.
There is no default and no default constructor: §6.2.1 leaves this library no number to invent.
| maxBufferedField | The deployment's byte budget for one top-level field. Generated code passes SOFAB_MAX_DYN_BUFFERED_FIELD; a hand-written caller states its own. SIZE_MAX is a legal choice and means "this receiver's budget is the platform's ceiling" — a number the caller stated, not a mode this library offers. |
| size_t sofab::Limits::max_buffered_field |
Cap on how many bytes a single top-level field may span, in bytes.
A receiver policy on the size of a field, not on a buffer: the decoder holds no buffer a field could grow (§6.6). It is what bounds the one shape the three per-read max_dyn_* caps cannot see — a sequence whose bulk accrues field by field, which no single count or length word announces.
Checked the moment the size becomes known – at the header for a fixlen or fixlen-array payload, as it accrues for a sequence – so an oversized claim fails before its payload is buffered, and even if that payload never arrives.
It binds only a field the schema leaves unbounded: a declared maxlen/count decides first, and its violation is Error::InvalidMessage rather than Error::LimitExceeded (§6.2.1/§6.3). An over-cap field is therefore still handed to the deliver callback – the only place that bound is known – but with its payload withheld, so it can be judged without being materialised.
Bytes are never clamped or truncated; the feed() simply fails.