|
| template<typename W > |
| void | det_bw_init (W *w, uint8_t *buf, size_t cap) |
| | Bind a write cursor to buf (capacity cap) and reset it.
|
| |
| template<typename W > |
| size_t | det_bw_len (const W *w) |
| | Bytes the payload needs so far (keeps counting past cap on overflow).
|
| |
| template<typename W > |
| bool | det_bw_ok (const W *w) |
| | True while every write has fit in the buffer.
|
| |
| template<typename W > |
| void | det_bw_put (W *w, uint8_t b) |
| | Append one byte; on overflow set the flag but keep counting pos.
|
| |
| template<typename W > |
| void | det_bw_put_be (W *w, uint64_t val, int nbytes) |
| | Append the low nbytes of val, big-endian (network order).
|
| |
| template<typename R > |
| void | det_br_init (R *r, const uint8_t *buf, size_t len) |
| | Bind a read cursor to buf (length len) at offset 0.
|
| |
| template<typename R > |
| bool | det_br_ok (const R *r) |
| | True while no malformed / out-of-bounds read has occurred.
|
| |
| template<typename R > |
| bool | det_br_take_be (R *r, size_t nbytes, uint64_t *out) |
| | Read nbytes big-endian immediately after the tag byte at pos, advancing past the tag and the argument (pos += 1 + nbytes).
|
| |
Shared byte-cursor mechanics for the binary codecs (one source of truth).
CBOR and MessagePack (and any future binary codec) kept their own copies of the exact same write cursor ({buf, cap, pos, overflow} with bounds-checked put + big-endian put) and read cursor ({buf, len, pos, err} with a big-endian take). The subtle invariants - keep counting pos past cap on overflow so the caller can size the buffer; sticky err; network (big-endian) byte order - now live here once, so a bug is fixed in one place and every codec inherits it.
Header-only and templated on the cursor type, so each codec keeps its own public struct (CborWriter, MsgpackReader, ...) - these helpers just require the matching field names. No .cpp to wire into the per-env test src filters.
- Author
- Douglas Quigg (dstroy0)
- Date
- 2026
Definition in file bytes.h.