Lite³
A JSON-Compatible Zero-Copy Serialization Format
Loading...
Searching...
No Matches
Object / Array Initialization

Object / array initialization. More...

Functions

int lite3_init_obj (unsigned char *buf, size_t *__restrict out_buflen, size_t bufsz)
 Initialize a Lite³ buffer as an object.
 
int lite3_init_arr (unsigned char *buf, size_t *__restrict out_buflen, size_t bufsz)
 Initialize a Lite³ buffer as an array.
 

Detailed Description

Object / array initialization.

The JSON standard requires that the root-level type always be an 'object' or 'array'. This also applies to Lite³.

Before data can be inserted into an empty buffer, it must first be initialized as object or array.

Function Documentation

◆ lite3_init_arr()

int lite3_init_arr ( unsigned char *  buf,
size_t *__restrict  out_buflen,
size_t  bufsz 
)

Initialize a Lite³ buffer as an array.

The number of bytes written to *buf never exceeds bufsz. The available buffer space must be at least LITE3_NODE_SIZE.

Returns
0 on success
< 0 on error
Note
This function can also be used to reset an existing Lite³ message; the root node is simply replaced with an empty array.
Parameters
[in]bufbuffer pointer
[out]out_buflenbuffer used length
[in]bufszbuffer max size

◆ lite3_init_obj()

int lite3_init_obj ( unsigned char *  buf,
size_t *__restrict  out_buflen,
size_t  bufsz 
)

Initialize a Lite³ buffer as an object.

The number of bytes written to *buf never exceeds bufsz. The available buffer space must be at least LITE3_NODE_SIZE.

Returns
0 on success
< 0 on error
Note
This function can also be used to reset an existing Lite³ message; the root node is simply replaced with an empty object.
Parameters
[in]bufbuffer pointer
[out]out_buflenbuffer used length
[in]bufszbuffer max size