|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
Layer 6 (Presentation) - zero-heap MessagePack encoder and decoder. More...
#include "protocore_config.h"Go to the source code of this file.
Layer 6 (Presentation) - zero-heap MessagePack encoder and decoder.
A streaming encoder that writes directly into a caller-provided buffer (no heap), the MessagePack-format sibling of the CBOR / JSON writers. Each value is emitted in the shortest MessagePack form (fixint / fixstr / fixarray / fixmap where possible). Emit definite-length arrays and maps by writing the header (MsgPack.put_array / MsgPack.put_map with the item count) then that many items (twice that for a map: key, value, key, value, ...).
Overflow is tracked, not crashed on: writes past the buffer set the span's overflow flag and stop, while the span's pos keeps counting the bytes the full payload would need, so a caller can size the buffer and check spat.ok().
The decoder is a cursor: MsgPack.peek() reports the next object's type and the MsgPack.get_* calls consume it (strings and binary point into the source buffer, no copy). Any malformed or out-of-bounds read sets a sticky error - check spat.cok(). ext and the unused 0xc1 byte are reported as INVALID.
Definition in file msgpack.h.