NAME
hyle/value.h - 16-byte hyle value type and JSON serialization.
SYNOPSIS
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include 'ctx.h'
Data Structures
16-byte hyle value.
Identifies one stored row in a hyle source.
Enumerations
Functions
Construct a null value.
Construct a boolean value.
Construct a 64-bit signed integer value.
Construct a double-precision float value.
Construct a pooled string value from a C string.
Construct an empty array value.
Construct an empty map value.
Read back the characters of a string value.
Append an element to an array value.
Read one element of an array value.
Number of elements in an array value.
Set a key in a map value.
Read one entry of a map value.
Serialize a value to JSON.
Detailed Description
16-byte hyle value type and JSON serialization.
Values allocate against a hyle_ctx_t pool; accessors and JSON output live here alongside the boxed constructors.
Enumeration Type Documentation
enum hyle_val_type_t
Enumerator
- HYLE_NULL
- Null value.
- HYLE_BOOL
- Boolean value.
- HYLE_INT
- 64-bit signed integer value.
- HYLE_FLOAT
- Double-precision floating point value.
- HYLE_STRING
- Pool-allocated string value.
- HYLE_ARRAY
- Ordered array of values.
- HYLE_MAP
- String-keyed map of values.
Function Documentation
hyle_val_t hyle_val_array (hyle_ctx_t * ctx)
Construct an empty array value.
Parameters
ctx Context pool to allocate from.
Returns
A value of type HYLE_ARRAY.
hyle_val_t hyle_val_array_get (hyle_ctx_t * ctx, hyle_val_t arr, size_t idx)
Read one element of an array value.
Parameters
ctx Context pool that owns the values.
arr Array value.
idx Element index.
Returns
Element value, or HYLE_NULL when out of range.
size_t hyle_val_array_len (hyle_ctx_t * ctx, hyle_val_t arr)
Number of elements in an array value.
Parameters
ctx Context pool that owns the value.
arr Array value.
Returns
Element count.
void hyle_val_array_push (hyle_ctx_t * ctx, hyle_val_t arr, hyle_val_t elem)
Append an element to an array value.
Parameters
ctx Context pool that owns the values.
arr Array value.
elem Element to append (copied into the pool).
hyle_val_t hyle_val_bool (bool b)
Construct a boolean value.
Parameters
b Source boolean.
Returns
A value of type HYLE_BOOL.
hyle_val_t hyle_val_float (double f)
Construct a double-precision float value.
Parameters
f Source float.
Returns
A value of type HYLE_FLOAT.
hyle_val_t hyle_val_int (int64_t i)
Construct a 64-bit signed integer value.
Parameters
i Source integer.
Returns
A value of type HYLE_INT.
hyle_val_t hyle_val_map (hyle_ctx_t * ctx)
Construct an empty map value.
Parameters
ctx Context pool to allocate from.
Returns
A value of type HYLE_MAP.
hyle_val_t hyle_val_map_get (hyle_ctx_t * ctx, hyle_val_t map, const char * key)
Read one entry of a map value.
Parameters
ctx Context pool that owns the values.
map Map value.
key NUL-terminated key string.
Returns
Entry value, or HYLE_NULL when absent.
void hyle_val_map_set (hyle_ctx_t * ctx, hyle_val_t map, const char * key, hyle_val_t val)
Set a key in a map value.
Parameters
ctx Context pool that owns the values.
map Map value.
key NUL-terminated key string.
val Value to store under key (copied into the pool).
hyle_val_t hyle_val_null (void )
Construct a null value.
Returns
A value of type HYLE_NULL.
hyle_val_t hyle_val_string (hyle_ctx_t * ctx, const char * s)
Construct a pooled string value from a C string.
Parameters
ctx Context pool to allocate from.
s NUL-terminated source string.
Returns
A value of type HYLE_STRING.
const char * hyle_val_string_get (hyle_ctx_t * ctx, hyle_val_t v)
Read back the characters of a string value.
Parameters
ctx Context pool that owns the value.
v String value.
Returns
NUL-terminated string (pool owned) or NULL for non-strings.
char * hyle_val_to_json (hyle_ctx_t * ctx, hyle_val_t v)
Serialize a value to JSON.
Parameters
ctx Context pool that owns the value.
v Value to serialize.
Returns
malloc'd JSON string; caller frees with free().
Author
Generated automatically by Doxygen for libhyle from the source code.