ProtoCore v0.0.2
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
pc_codec Struct Reference

A wire encoding: the ten writes, the peek, and the nine reads. More...

#include <codec.h>

Public Attributes

void(* put_uint )(pc_span *w, uint64_t v)
 
void(* put_int )(pc_span *w, int64_t v)
 
void(* put_bytes )(pc_span *w, const uint8_t *data, size_t len)
 
void(* put_str )(pc_span *w, const char *s)
 
void(* put_str_n )(pc_span *w, const char *s, size_t len)
 
void(* put_bool )(pc_span *w, bool b)
 
void(* put_null )(pc_span *w)
 
void(* put_float )(pc_span *w, float f)
 
void(* put_array )(pc_span *w, size_t count)
 
void(* put_map )(pc_span *w, size_t count)
 
void(* put_label )(pc_span *w, const char *name, int64_t num)
 Emit a map key, given both spellings of it.
 
pc_codec_type(* peek )(pc_cspan *r)
 
bool(* get_uint )(pc_cspan *r, uint64_t *out)
 
bool(* get_int )(pc_cspan *r, int64_t *out)
 
bool(* get_bytes )(pc_cspan *r, const uint8_t **out, size_t *len)
 
bool(* get_str )(pc_cspan *r, const char **out, size_t *len)
 
bool(* get_array )(pc_cspan *r, size_t *count)
 
bool(* get_map )(pc_cspan *r, size_t *count)
 
bool(* get_bool )(pc_cspan *r, bool *out)
 
bool(* get_null )(pc_cspan *r)
 
bool(* get_float )(pc_cspan *r, float *out)
 

Detailed Description

A wire encoding: the ten writes, the peek, and the nine reads.

Field order is the operation order every format declares and implements in. int, bool and float are keywords, so the members carry the put_ / get_ prefix that says which direction they run in.

Definition at line 65 of file codec.h.

Member Data Documentation

◆ put_uint

void(* pc_codec::put_uint) (pc_span *w, uint64_t v)

Definition at line 68 of file codec.h.

◆ put_int

void(* pc_codec::put_int) (pc_span *w, int64_t v)

Definition at line 69 of file codec.h.

◆ put_bytes

void(* pc_codec::put_bytes) (pc_span *w, const uint8_t *data, size_t len)

Definition at line 70 of file codec.h.

◆ put_str

void(* pc_codec::put_str) (pc_span *w, const char *s)

Definition at line 71 of file codec.h.

◆ put_str_n

void(* pc_codec::put_str_n) (pc_span *w, const char *s, size_t len)

Definition at line 72 of file codec.h.

◆ put_bool

void(* pc_codec::put_bool) (pc_span *w, bool b)

Definition at line 73 of file codec.h.

◆ put_null

void(* pc_codec::put_null) (pc_span *w)

Definition at line 74 of file codec.h.

◆ put_float

void(* pc_codec::put_float) (pc_span *w, float f)

Definition at line 75 of file codec.h.

◆ put_array

void(* pc_codec::put_array) (pc_span *w, size_t count)

Definition at line 76 of file codec.h.

◆ put_map

void(* pc_codec::put_map) (pc_span *w, size_t count)

Definition at line 77 of file codec.h.

◆ put_label

void(* pc_codec::put_label) (pc_span *w, const char *name, int64_t num)

Emit a map key, given both spellings of it.

A spec often names the same field differently per encoding: RFC 8428 labels a SenML base name "bn" in JSON and -2 in CBOR. That is the encoding's business, not the caller's, so the caller hands over both and the format picks the one it is specified to write. Without this the difference leaks upward and every producer keeps one walk per encoding.

Definition at line 87 of file codec.h.

◆ peek

pc_codec_type(* pc_codec::peek) (pc_cspan *r)

Definition at line 90 of file codec.h.

◆ get_uint

bool(* pc_codec::get_uint) (pc_cspan *r, uint64_t *out)

Definition at line 91 of file codec.h.

◆ get_int

bool(* pc_codec::get_int) (pc_cspan *r, int64_t *out)

Definition at line 92 of file codec.h.

◆ get_bytes

bool(* pc_codec::get_bytes) (pc_cspan *r, const uint8_t **out, size_t *len)

Definition at line 93 of file codec.h.

◆ get_str

bool(* pc_codec::get_str) (pc_cspan *r, const char **out, size_t *len)

Definition at line 94 of file codec.h.

◆ get_array

bool(* pc_codec::get_array) (pc_cspan *r, size_t *count)

Definition at line 95 of file codec.h.

◆ get_map

bool(* pc_codec::get_map) (pc_cspan *r, size_t *count)

Definition at line 96 of file codec.h.

◆ get_bool

bool(* pc_codec::get_bool) (pc_cspan *r, bool *out)

Definition at line 97 of file codec.h.

◆ get_null

bool(* pc_codec::get_null) (pc_cspan *r)

Definition at line 98 of file codec.h.

◆ get_float

bool(* pc_codec::get_float) (pc_cspan *r, float *out)

Definition at line 99 of file codec.h.


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