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

Decode fields at the current nesting level, firing cb for each. More...

#include <sofab.hpp>

Public Member Functions

void operator() (sofab::id id, size_t size, size_t count) const noexcept
 

Public Attributes

void * ctx
 
void(* fn )(void *, sofab::id, size_t, size_t)
 

Detailed Description

Decode fields at the current nesting level, firing cb for each.

For every field the metadata members (type_, fixLen_, count_, ...) are set before cb runs; a field whose value the callback does not read is skipped automatically.

Template Parameters
CbThe callable's own type, so the call is direct. A std::function parameter here cost a construction, a manager-driven destruction and two indirect hops per sub-message read, and the std::function machinery around it accounted for ~13 % of the decode: typical message profile. The two call sites pass a stateless no-op (skipPayload) and a two-pointer lambda (read), so the instantiation count is bounded and the body inlines into both.
Parameters
cbCallback invoked as (fieldId, size, count) per field.
stopAtEndIf true, return at a Wire::SequenceEnd marker (nested level); if false, such a marker is a decode error.

A non-owning reference to a level's per-field callback.

The parse loops call their callback through a template parameter, so the call is direct and inlines (that is deliberate — a std::function parameter there cost ~13 % of decode: typical message). The resume helpers below want the opposite: they run once per chunk boundary, never in the loop, and compiling a copy of each of them into every one of the dozens of dispatchLevel instantiations buys nothing but code size and uncoverable lines. They take this instead — two pointers, one indirect call on a cold path.

Definition at line 3735 of file sofab.hpp.

Member Function Documentation

◆ operator()()

void sofab::IStreamImpl::FieldCb::operator() ( sofab::id  id,
size_t  size,
size_t  count 
) const
inlinenoexcept

Definition at line 3739 of file sofab.hpp.

Member Data Documentation

◆ ctx

void* sofab::IStreamImpl::FieldCb::ctx

Definition at line 3737 of file sofab.hpp.

◆ fn

void(* sofab::IStreamImpl::FieldCb::fn) (void *, sofab::id, size_t, size_t)

Definition at line 3738 of file sofab.hpp.


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