39 perror(
"Failed to create lite3_ctx *ctx");
51 perror(
"Failed to build message");
54 printf(
"buflen: %zu\n", ctx->buflen);
56 perror(
"Failed to print JSON");
62 perror(
"Failed to get element");
65 printf(
"Element at index 2: %s\n",
LITE3_STR(ctx->buf, element_2));
67 uint32_t element_count;
69 perror(
"Failed to get element count");
72 printf(
"Element count: %u\n", element_count);
76 perror(
"Failed to get element");
79 printf(
"Last element: %s\n",
LITE3_STR(ctx->buf, last_element));
81 printf(
"\nOverwriting index 2 with \"gnu\"\n");
83 perror(
"Failed to set element");
86 printf(
"buflen: %zu\n", ctx->buflen);
88 perror(
"Failed to print JSON");
92 printf(
"\nOverwriting index 3 with \"springbok\"\n");
94 perror(
"Failed to set element");
97 printf(
"buflen: %zu\n", ctx->buflen);
99 perror(
"Failed to print JSON");
static int lite3_ctx_arr_append_str(lite3_ctx *ctx, size_t ofs, const char *__restrict str)
Append string to array.
static int lite3_ctx_arr_get_str(lite3_ctx *ctx, size_t ofs, uint32_t index, lite3_str *out)
Get string value by index.
static int lite3_ctx_arr_set_str(lite3_ctx *ctx, size_t ofs, uint32_t index, const char *__restrict str)
Set string in array.
static int lite3_ctx_init_arr(lite3_ctx *ctx)
Initialize a Lite³ context as an array.
static int lite3_ctx_json_print(lite3_ctx *ctx, size_t ofs)
Print Lite³ buffer as JSON to stdout
static lite3_ctx * lite3_ctx_create(void)
Create context with minimum size.
void lite3_ctx_destroy(lite3_ctx *ctx)
Destroy context.
static int lite3_ctx_count(lite3_ctx *ctx, size_t ofs, uint32_t *out)
Write back the number of object entries or array elements.
#define LITE3_STR(buf, val)
Generational pointer / safe access wrapper.
Lite³ Context API Header.
Struct holding a reference to a string inside a Lite³ buffer.