.TH "hyle/value.h" 3 "libhyle" \" -*- nroff -*- .ad l .nh .SH NAME hyle/value.h \- 16-byte hyle value type and JSON serialization\&. .SH SYNOPSIS .br .PP \fR#include \fP .br \fR#include \fP .br \fR#include \fP .br \fR#include 'ctx\&.h'\fP .br .SS "Data Structures" .in +1c .ti -1c .RI "struct \fBhyle_val_t\fP" .br .RI "16-byte hyle value\&. " .ti -1c .RI "struct \fBhyle_row_t\fP" .br .RI "Identifies one stored row in a hyle source\&. " .in -1c .SS "Enumerations" .in +1c .ti -1c .RI "enum \fBhyle_val_type_t\fP { \fBHYLE_NULL\fP = 0, \fBHYLE_BOOL\fP, \fBHYLE_INT\fP, \fBHYLE_FLOAT\fP, \fBHYLE_STRING\fP, \fBHYLE_ARRAY\fP, \fBHYLE_MAP\fP }" .br .in -1c .SS "Functions" .in +1c .ti -1c .RI "\fBhyle_val_t\fP \fBhyle_val_null\fP (void)" .br .RI "Construct a null value\&. " .ti -1c .RI "\fBhyle_val_t\fP \fBhyle_val_bool\fP (bool b)" .br .RI "Construct a boolean value\&. " .ti -1c .RI "\fBhyle_val_t\fP \fBhyle_val_int\fP (int64_t i)" .br .RI "Construct a 64-bit signed integer value\&. " .ti -1c .RI "\fBhyle_val_t\fP \fBhyle_val_float\fP (double f)" .br .RI "Construct a double-precision float value\&. " .ti -1c .RI "\fBhyle_val_t\fP \fBhyle_val_string\fP (\fBhyle_ctx_t\fP *ctx, const char *s)" .br .RI "Construct a pooled string value from a C string\&. " .ti -1c .RI "\fBhyle_val_t\fP \fBhyle_val_array\fP (\fBhyle_ctx_t\fP *ctx)" .br .RI "Construct an empty array value\&. " .ti -1c .RI "\fBhyle_val_t\fP \fBhyle_val_map\fP (\fBhyle_ctx_t\fP *ctx)" .br .RI "Construct an empty map value\&. " .ti -1c .RI "const char * \fBhyle_val_string_get\fP (\fBhyle_ctx_t\fP *ctx, \fBhyle_val_t\fP v)" .br .RI "Read back the characters of a string value\&. " .ti -1c .RI "void \fBhyle_val_array_push\fP (\fBhyle_ctx_t\fP *ctx, \fBhyle_val_t\fP arr, \fBhyle_val_t\fP elem)" .br .RI "Append an element to an array value\&. " .ti -1c .RI "\fBhyle_val_t\fP \fBhyle_val_array_get\fP (\fBhyle_ctx_t\fP *ctx, \fBhyle_val_t\fP arr, size_t idx)" .br .RI "Read one element of an array value\&. " .ti -1c .RI "size_t \fBhyle_val_array_len\fP (\fBhyle_ctx_t\fP *ctx, \fBhyle_val_t\fP arr)" .br .RI "Number of elements in an array value\&. " .ti -1c .RI "void \fBhyle_val_map_set\fP (\fBhyle_ctx_t\fP *ctx, \fBhyle_val_t\fP map, const char *key, \fBhyle_val_t\fP val)" .br .RI "Set a key in a map value\&. " .ti -1c .RI "\fBhyle_val_t\fP \fBhyle_val_map_get\fP (\fBhyle_ctx_t\fP *ctx, \fBhyle_val_t\fP map, const char *key)" .br .RI "Read one entry of a map value\&. " .ti -1c .RI "char * \fBhyle_val_to_json\fP (\fBhyle_ctx_t\fP *ctx, \fBhyle_val_t\fP v)" .br .RI "Serialize a value to JSON\&. " .in -1c .SH "Detailed Description" .PP 16-byte hyle value type and JSON serialization\&. Values allocate against a \fBhyle_ctx_t\fP pool; accessors and JSON output live here alongside the boxed constructors\&. .SH "Enumeration Type Documentation" .PP .SS "enum \fBhyle_val_type_t\fP" .PP \fBEnumerator\fP .in +1c .TP \f(BIHYLE_NULL \fP Null value\&. .TP \f(BIHYLE_BOOL \fP Boolean value\&. .TP \f(BIHYLE_INT \fP 64-bit signed integer value\&. .TP \f(BIHYLE_FLOAT \fP Double-precision floating point value\&. .TP \f(BIHYLE_STRING \fP Pool-allocated string value\&. .TP \f(BIHYLE_ARRAY \fP Ordered array of values\&. .TP \f(BIHYLE_MAP \fP String-keyed map of values\&. .SH "Function Documentation" .PP .SS "\fBhyle_val_t\fP hyle_val_array (\fBhyle_ctx_t\fP * ctx)" .PP Construct an empty array value\&. .PP \fBParameters\fP .RS 4 \fIctx\fP Context pool to allocate from\&. .RE .PP \fBReturns\fP .RS 4 A value of type HYLE_ARRAY\&. .RE .PP .SS "\fBhyle_val_t\fP hyle_val_array_get (\fBhyle_ctx_t\fP * ctx, \fBhyle_val_t\fP arr, size_t idx)" .PP Read one element of an array value\&. .PP \fBParameters\fP .RS 4 \fIctx\fP Context pool that owns the values\&. .br \fIarr\fP Array value\&. .br \fIidx\fP Element index\&. .RE .PP \fBReturns\fP .RS 4 Element value, or HYLE_NULL when out of range\&. .RE .PP .SS "size_t hyle_val_array_len (\fBhyle_ctx_t\fP * ctx, \fBhyle_val_t\fP arr)" .PP Number of elements in an array value\&. .PP \fBParameters\fP .RS 4 \fIctx\fP Context pool that owns the value\&. .br \fIarr\fP Array value\&. .RE .PP \fBReturns\fP .RS 4 Element count\&. .RE .PP .SS "void hyle_val_array_push (\fBhyle_ctx_t\fP * ctx, \fBhyle_val_t\fP arr, \fBhyle_val_t\fP elem)" .PP Append an element to an array value\&. .PP \fBParameters\fP .RS 4 \fIctx\fP Context pool that owns the values\&. .br \fIarr\fP Array value\&. .br \fIelem\fP Element to append (copied into the pool)\&. .RE .PP .SS "\fBhyle_val_t\fP hyle_val_bool (bool b)" .PP Construct a boolean value\&. .PP \fBParameters\fP .RS 4 \fIb\fP Source boolean\&. .RE .PP \fBReturns\fP .RS 4 A value of type HYLE_BOOL\&. .RE .PP .SS "\fBhyle_val_t\fP hyle_val_float (double f)" .PP Construct a double-precision float value\&. .PP \fBParameters\fP .RS 4 \fIf\fP Source float\&. .RE .PP \fBReturns\fP .RS 4 A value of type HYLE_FLOAT\&. .RE .PP .SS "\fBhyle_val_t\fP hyle_val_int (int64_t i)" .PP Construct a 64-bit signed integer value\&. .PP \fBParameters\fP .RS 4 \fIi\fP Source integer\&. .RE .PP \fBReturns\fP .RS 4 A value of type HYLE_INT\&. .RE .PP .SS "\fBhyle_val_t\fP hyle_val_map (\fBhyle_ctx_t\fP * ctx)" .PP Construct an empty map value\&. .PP \fBParameters\fP .RS 4 \fIctx\fP Context pool to allocate from\&. .RE .PP \fBReturns\fP .RS 4 A value of type HYLE_MAP\&. .RE .PP .SS "\fBhyle_val_t\fP hyle_val_map_get (\fBhyle_ctx_t\fP * ctx, \fBhyle_val_t\fP map, const char * key)" .PP Read one entry of a map value\&. .PP \fBParameters\fP .RS 4 \fIctx\fP Context pool that owns the values\&. .br \fImap\fP Map value\&. .br \fIkey\fP NUL-terminated key string\&. .RE .PP \fBReturns\fP .RS 4 Entry value, or HYLE_NULL when absent\&. .RE .PP .SS "void hyle_val_map_set (\fBhyle_ctx_t\fP * ctx, \fBhyle_val_t\fP map, const char * key, \fBhyle_val_t\fP val)" .PP Set a key in a map value\&. .PP \fBParameters\fP .RS 4 \fIctx\fP Context pool that owns the values\&. .br \fImap\fP Map value\&. .br \fIkey\fP NUL-terminated key string\&. .br \fIval\fP Value to store under key (copied into the pool)\&. .RE .PP .SS "\fBhyle_val_t\fP hyle_val_null (void )" .PP Construct a null value\&. .PP \fBReturns\fP .RS 4 A value of type HYLE_NULL\&. .RE .PP .SS "\fBhyle_val_t\fP hyle_val_string (\fBhyle_ctx_t\fP * ctx, const char * s)" .PP Construct a pooled string value from a C string\&. .PP \fBParameters\fP .RS 4 \fIctx\fP Context pool to allocate from\&. .br \fIs\fP NUL-terminated source string\&. .RE .PP \fBReturns\fP .RS 4 A value of type HYLE_STRING\&. .RE .PP .SS "const char * hyle_val_string_get (\fBhyle_ctx_t\fP * ctx, \fBhyle_val_t\fP v)" .PP Read back the characters of a string value\&. .PP \fBParameters\fP .RS 4 \fIctx\fP Context pool that owns the value\&. .br \fIv\fP String value\&. .RE .PP \fBReturns\fP .RS 4 NUL-terminated string (pool owned) or NULL for non-strings\&. .RE .PP .SS "char * hyle_val_to_json (\fBhyle_ctx_t\fP * ctx, \fBhyle_val_t\fP v)" .PP Serialize a value to JSON\&. .PP \fBParameters\fP .RS 4 \fIctx\fP Context pool that owns the value\&. .br \fIv\fP Value to serialize\&. .RE .PP \fBReturns\fP .RS 4 malloc'd JSON string; caller frees with free()\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for libhyle from the source code\&.