From 28b9d2236753645a96e94fb35724e16d93876206 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Thu, 25 Jan 2024 21:50:14 +0100 Subject: Update unival interface --- source/kit/unival.h | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'source') diff --git a/source/kit/unival.h b/source/kit/unival.h index 63868d5..e0362b1 100644 --- a/source/kit/unival.h +++ b/source/kit/unival.h @@ -1,5 +1,5 @@ -#ifndef KIT_UV_H -#define KIT_UV_H +#ifndef KIT_UNIVAL_H +#define KIT_UNIVAL_H #include "string_builder.h" #include "input_stream.h" @@ -19,15 +19,18 @@ enum { KIT_UV_COMPOSITE, }; -enum { KIT_UV_ENCODE_BZIP = 1 }; -enum { KIT_UV_PRINT_PRETTY = 1, KIT_UV_PRINT_JSON = 2 }; +enum { + KIT_UV_ENCODE_BZIP = 1, + KIT_UV_PRINT_PRETTY = 1, + KIT_UV_PRINT_JSON = 2, +}; -typedef struct kit_uv_data kit_unival_t; +typedef struct kit_unival_ kit_unival_t; typedef KIT_DA(kit_unival_t) kit_da_unival_t; typedef KIT_DA(u8) kit_uv_bytes_t; -struct kit_uv_data { +struct kit_unival_ { i8 type; union { i8 boolean; @@ -48,28 +51,33 @@ typedef struct { kit_unival_t *value; } kit_uv_decode_result_t; +kit_uv_decode_result_t kit_uv_decode(kit_is_handle_t is, + kit_allocator_t *alloc); + typedef struct { s32 status; kit_uv_bytes_t value; } kit_uv_encode_result_t; -typedef struct { - s32 status; - kit_str_builder_t value; -} kit_uv_print_result_t; - -kit_uv_decode_result_t kit_uv_decode(kit_is_handle_t is, - kit_allocator_t *alloc); kit_uv_encode_result_t kit_uv_encode(kit_unival_t *value, kit_allocator_t *alloc, i32 flags); + kit_uv_decode_result_t kit_uv_parse(kit_is_handle_t is, kit_allocator_t *alloc); + kit_uv_decode_result_t kit_uv_parse_json(kit_is_handle_t is, kit_allocator_t *alloc); -kit_uv_print_result_t kit_uv_print(kit_unival_t *value, - kit_allocator_t *alloc, i32 flags); -void kit_uv_destroy(kit_unival_t *value); + +typedef struct { + s32 status; + kit_str_builder_t value; +} kit_uv_print_result_t; + +kit_uv_print_result_t kit_uv_print(kit_unival_t *value, + kit_allocator_t *alloc, i32 flags); + +void kit_uv_destroy(kit_unival_t *value); #ifdef __cplusplus } -- cgit v1.2.3