ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
protocore_codec Struct Reference

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

#include <codec.h>

Public Attributes

void(* put_uint )(mmgr_span *w, uint64_t v)
 
void(* put_int )(mmgr_span *w, int64_t v)
 
void(* put_bytes )(mmgr_span *w, const uint8_t *data, size_t len)
 
void(* put_str )(mmgr_span *w, const char *s)
 
void(* put_str_n )(mmgr_span *w, const char *s, size_t len)
 
void(* put_bool )(mmgr_span *w, proto_bool b)
 
void(* put_null )(mmgr_span *w)
 
void(* put_float )(mmgr_span *w, float f)
 
void(* put_array )(mmgr_span *w, size_t count)
 
void(* put_map )(mmgr_span *w, size_t count)
 
void(* put_label )(mmgr_span *w, const char *name, int64_t num)
 Emit a map key, given both spellings of it.
 
protocore_codec_type(* peek )(mmgr_cspan *r)
 
proto_bool(* get_uint )(mmgr_cspan *r, uint64_t *out)
 
proto_bool(* get_int )(mmgr_cspan *r, int64_t *out)
 
proto_bool(* get_bytes )(mmgr_cspan *r, const uint8_t **out, size_t *len)
 
proto_bool(* get_str )(mmgr_cspan *r, const char **out, size_t *len)
 
proto_bool(* get_array )(mmgr_cspan *r, size_t *count)
 
proto_bool(* get_map )(mmgr_cspan *r, size_t *count)
 
proto_bool(* get_bool )(mmgr_cspan *r, proto_bool *out)
 
proto_bool(* get_null )(mmgr_cspan *r)
 
proto_bool(* get_float )(mmgr_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 59 of file codec.h.

Member Data Documentation

◆ put_uint

void(* protocore_codec::put_uint) (mmgr_span *w, uint64_t v)

Definition at line 62 of file codec.h.

◆ put_int

void(* protocore_codec::put_int) (mmgr_span *w, int64_t v)

Definition at line 63 of file codec.h.

◆ put_bytes

void(* protocore_codec::put_bytes) (mmgr_span *w, const uint8_t *data, size_t len)

Definition at line 64 of file codec.h.

◆ put_str

void(* protocore_codec::put_str) (mmgr_span *w, const char *s)

Definition at line 65 of file codec.h.

◆ put_str_n

void(* protocore_codec::put_str_n) (mmgr_span *w, const char *s, size_t len)

Definition at line 66 of file codec.h.

◆ put_bool

void(* protocore_codec::put_bool) (mmgr_span *w, proto_bool b)

Definition at line 67 of file codec.h.

◆ put_null

void(* protocore_codec::put_null) (mmgr_span *w)

Definition at line 68 of file codec.h.

◆ put_float

void(* protocore_codec::put_float) (mmgr_span *w, float f)

Definition at line 69 of file codec.h.

◆ put_array

void(* protocore_codec::put_array) (mmgr_span *w, size_t count)

Definition at line 70 of file codec.h.

◆ put_map

void(* protocore_codec::put_map) (mmgr_span *w, size_t count)

Definition at line 71 of file codec.h.

◆ put_label

void(* protocore_codec::put_label) (mmgr_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 81 of file codec.h.

◆ peek

protocore_codec_type(* protocore_codec::peek) (mmgr_cspan *r)

Definition at line 84 of file codec.h.

◆ get_uint

proto_bool(* protocore_codec::get_uint) (mmgr_cspan *r, uint64_t *out)

Definition at line 85 of file codec.h.

◆ get_int

proto_bool(* protocore_codec::get_int) (mmgr_cspan *r, int64_t *out)

Definition at line 86 of file codec.h.

◆ get_bytes

proto_bool(* protocore_codec::get_bytes) (mmgr_cspan *r, const uint8_t **out, size_t *len)

Definition at line 87 of file codec.h.

◆ get_str

proto_bool(* protocore_codec::get_str) (mmgr_cspan *r, const char **out, size_t *len)

Definition at line 88 of file codec.h.

◆ get_array

proto_bool(* protocore_codec::get_array) (mmgr_cspan *r, size_t *count)

Definition at line 89 of file codec.h.

◆ get_map

proto_bool(* protocore_codec::get_map) (mmgr_cspan *r, size_t *count)

Definition at line 90 of file codec.h.

◆ get_bool

proto_bool(* protocore_codec::get_bool) (mmgr_cspan *r, proto_bool *out)

Definition at line 91 of file codec.h.

◆ get_null

proto_bool(* protocore_codec::get_null) (mmgr_cspan *r)

Definition at line 92 of file codec.h.

◆ get_float

proto_bool(* protocore_codec::get_float) (mmgr_cspan *r, float *out)

Definition at line 93 of file codec.h.


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