SofaBuffers C++ 0.12.0
Pure-C++20 SofaBuffers — API Documentation
Loading...
Searching...
No Matches
sofab::Limits Struct Reference

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.
 

Detailed Description

The one stream-scoped receiver cap: how many bytes a single top-level field may span.

This IS a §6.2.1 receiver cap, and is treated as one
It is configured by the deployment, not by the schema; it binds only a field the schema leaves unbounded; and its breach is a policy rejection on bytes that are perfectly well-formed — the same message decodes under a looser number. That is precisely §6.3's LimitExceeded, and every rule §6.2.1 states about a receiver limit therefore binds this one:
  • the codec holds no limit of its own. The number arrives as a constructor argument, is the caller's, and is used for this one decode's comparisons — §6.2.1's *"supplied per call **or per decode**, used for that one comparison"*. An IStreamObject / IStreamInline is one decode;
  • there is no default. Limits cannot be default-constructed and the stream constructors do not default it, so a stream cannot come into existence without the deployment having stated a number (§6.2.1: a codec "**MUST NOT** supply a default for one it was not given");
  • there is no unlimited mode. No value of this member is special-cased, and no sentinel switches the check off. A caller that states 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.
The three max_dyn_* caps are not here
max_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.

Definition at line 2814 of file sofab.hpp.

Constructor & Destructor Documentation

◆ Limits()

constexpr sofab::Limits::Limits ( size_t  maxBufferedField)
inlineexplicitconstexprnoexcept

State the cap.

There is no default and no default constructor: §6.2.1 leaves this library no number to invent.

Parameters
maxBufferedFieldThe 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.

Definition at line 2851 of file sofab.hpp.

Member Data Documentation

◆ max_buffered_field

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.

Definition at line 2839 of file sofab.hpp.


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