File syn_cbor_write.c¶
FileList > src > syntropic > util > syn_cbor_write.c
Go to the source code of this file
CBOR streaming encoder implementation.
#include "syn_cbor_write.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| void | syn_cbor_write_array_begin (SYN_CborWriter * w, size_t count) Open a CBOR array with count items. |
| void | syn_cbor_write_bool (SYN_CborWriter * w, bool v) Write a boolean (0xF4 = false, 0xF5 = true). |
| void | syn_cbor_write_bytes (SYN_CborWriter * w, const uint8_t * data, size_t len) Write a byte string (major type 2). |
| void | syn_cbor_write_float (SYN_CborWriter * w, float v) Write an IEEE 754 single-precision float (major type 7, info=26). |
| void | syn_cbor_write_int (SYN_CborWriter * w, int64_t v) Write a signed integer. |
| void | syn_cbor_write_map_begin (SYN_CborWriter * w, size_t count) Open a CBOR map with count key-value pairs. |
| void | syn_cbor_write_null (SYN_CborWriter * w) Write a null (0xF6). |
| void | syn_cbor_write_text (SYN_CborWriter * w, const char * str, size_t len) Write a UTF-8 text string (major type 3). |
| void | syn_cbor_write_text_cstr (SYN_CborWriter * w, const char * str) Write a null-terminated UTF-8 text string. |
| void | syn_cbor_write_uint (SYN_CborWriter * w, uint64_t v) Write an unsigned integer. |
| void | syn_cbor_writer_init (SYN_CborWriter * w, uint8_t * buf, size_t cap) Initialize a CBOR writer. |
Public Static Functions¶
| Type | Name |
|---|---|
| void | emit_byte (SYN_CborWriter * w, uint8_t b) Emit a single byte to the CBOR output. |
| void | emit_head (SYN_CborWriter * w, uint8_t major, uint64_t val) Encode a CBOR header (major type + argument). |
| void | emit_raw (SYN_CborWriter * w, const void * data, size_t n) Emit N raw bytes. |
Public Functions Documentation¶
function syn_cbor_write_array_begin¶
Open a CBOR array with count items.
Caller must write exactly count items after this call.
Parameters:
wWriter.countNumber of items that follow.
function syn_cbor_write_bool¶
Write a boolean (0xF4 = false, 0xF5 = true).
Parameters:
wWriter.vValue.
function syn_cbor_write_bytes¶
Write a byte string (major type 2).
Parameters:
wWriter.dataPointer to raw bytes.lenByte count.
function syn_cbor_write_float¶
Write an IEEE 754 single-precision float (major type 7, info=26).
Parameters:
wWriter.vFloat value.
function syn_cbor_write_int¶
Write a signed integer.
Positive values are encoded as major type 0 (uint). Negative values are encoded as major type 1.
Parameters:
wWriter.vSigned value to encode.
function syn_cbor_write_map_begin¶
Open a CBOR map with count key-value pairs.
Caller must write exactly count pairs (key item + value item each) after this call.
Parameters:
wWriter.countNumber of key-value pairs that follow.
function syn_cbor_write_null¶
Write a null (0xF6).
Parameters:
wWriter.
function syn_cbor_write_text¶
Write a UTF-8 text string (major type 3).
Parameters:
wWriter.strPointer to string data.lenByte length (not counting any null terminator).
function syn_cbor_write_text_cstr¶
Write a null-terminated UTF-8 text string.
Parameters:
wWriter.strNull-terminated string.
function syn_cbor_write_uint¶
Write an unsigned integer.
Parameters:
wWriter.vValue to encode (CBOR major type 0).
function syn_cbor_writer_init¶
Initialize a CBOR writer.
Parameters:
wWriter to initialize. Must not be NULL.bufOutput buffer. Must not be NULL.capBuffer capacity in bytes.
Public Static Functions Documentation¶
function emit_byte¶
Emit a single byte to the CBOR output.
Parameters:
wCBOR writer.bByte to emit.
function emit_head¶
Encode a CBOR header (major type + argument).
Follows the CBOR additional-info rules for all major types 0-5.
Parameters:
wCBOR writer.majorMajor type (0-7).valArgument value.
function emit_raw¶
Emit N raw bytes.
Parameters:
wCBOR writer.dataSource data.nNumber of bytes.
The documentation for this class was generated from the following file src/syntropic/util/syn_cbor_write.c