41#ifndef PROTOCORE_FRAME_H
42#define PROTOCORE_FRAME_H
103#define PC_STR {PC_FK_STR, 0, 0, nullptr}
104#define PC_U32 {PC_FK_U32, 0, 0, nullptr}
105#define PC_U64 {PC_FK_U64, 0, 0, nullptr}
106#define PC_I64 {PC_FK_I64, 0, 0, nullptr}
107#define PC_CH {PC_FK_CH, 0, 0, nullptr}
108#define PC_JSON {PC_FK_JSON, 0, 0, nullptr}
109#define PC_XML {PC_FK_XML, 0, 0, nullptr}
110#define PC_END {PC_FK_END, 0, 0, nullptr}
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.
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.
pc_fk
Field kinds. The value is an opcode, so this is deliberately a plain byte enum.
@ PC_FK_G
double, printf %.<width>g (width 0 means 6)
@ PC_FK_OCT
uint64_t, octal zero-padded to width
@ PC_FK_JSON
const char *, emitted as a quoted JSON string literal
@ PC_FK_LIT
literal text from lit; takes no argument
@ PC_FK_HEX
uint64_t, lowercase hex zero-padded to width
@ PC_FK_FIX
double, printf %.<width>f
@ PC_FK_I64
int64_t, signed decimal
@ PC_FK_DEC
uint32_t, decimal zero-padded to width
@ PC_FK_U32
uint32_t, plain decimal
@ PC_FK_U64
uint64_t, plain decimal
@ PC_FK_END
terminator; takes no argument
@ PC_FK_STR
const char * (NULL renders as empty)
@ PC_FK_XML
const char *, XML-escaped
Bounded no-heap string builder that fails closed on overflow (one shared copy).
One field of a frame. Frames are static const pc_field[], so they live in rodata.
const char * lit
PC_FK_LIT only.
uint8_t width
min digits (DEC/HEX/OCT), significant digits (G), decimals (FIX)
uint16_t len
PC_FK_LIT: byte length of lit; gated by check_frame_specs.py.