ProtoCore v0.0.2
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
frame.cpp File Reference

The one frame engine. Walks a pc_field spec, pulls one argument per valued field. More...

Go to the source code of this file.

Macros

#define PC_FRAME_SCAN_LITERALS   0
 

Functions

PC_OPTIMIZE_O2 size_t pc_frame_vbuild (char *out, size_t cap, const pc_field *spec, va_list ap)
 va_list form, for a caller that already has one.
 
size_t pc_frame_build (char *out, size_t cap, const pc_field *spec,...)
 Build spec into out (capacity cap), taking one variadic argument per valued field.
 
size_t pc_frame_append (char *out, size_t cap, const pc_field *spec,...)
 Append spec to the NUL-terminated contents already in out.
 

Detailed Description

The one frame engine. Walks a pc_field spec, pulls one argument per valued field.

Deliberately thin: every conversion is an already-tested pc_sb appender, so this file adds a dispatch loop and the fail-closed contract, not new formatting logic. That is the point of the spec - the number of places that can get a conversion wrong stays at one no matter how many frames the library declares.

Definition in file frame.cpp.

Macro Definition Documentation

◆ PC_FRAME_SCAN_LITERALS

#define PC_FRAME_SCAN_LITERALS   0

Definition at line 18 of file frame.cpp.

Function Documentation

◆ pc_frame_vbuild()

PC_OPTIMIZE_O2 size_t pc_frame_vbuild ( char *  out,
size_t  cap,
const pc_field spec,
va_list  ap 
)

◆ pc_frame_build()

size_t pc_frame_build ( char *  out,
size_t  cap,
const pc_field spec,
  ... 
)

Build spec into out (capacity cap), taking one variadic argument per valued field.

Returns
bytes written, or 0 if the frame did not fit (in which case out is set empty).

Definition at line 100 of file frame.cpp.

References pc_frame_vbuild().

◆ pc_frame_append()

size_t pc_frame_append ( char *  out,
size_t  cap,
const pc_field spec,
  ... 
)

Append spec to the NUL-terminated contents already in out.

The append idiom this library uses for header and cookie accumulation: on overflow the buffer is rewound to its previous length, so a frame is added whole or not at all and a half-written line never reaches the wire.

Returns
the new total length, or 0 if the frame did not fit (previous contents preserved).

Definition at line 109 of file frame.cpp.

References pc_frame_vbuild().