|
Lite³
A JSON-Compatible Zero-Copy Serialization Format
|
Utility functions. More...
Macros | |
| #define | lite3_ctx_get_type(ctx, ofs, key) |
| Find value by key and return value type. | |
| #define | lite3_ctx_get_type_size(ctx, ofs, key, out) |
| Find value by key and write back type size. | |
| #define | lite3_ctx_exists(ctx, ofs, key) |
| Attempt to find a key. | |
| #define | lite3_ctx_is_null(ctx, ofs, key) |
| Find value by key and test for null type. | |
| #define | lite3_ctx_is_bool(ctx, ofs, key) |
| Find value by key and test for bool type. | |
| #define | lite3_ctx_is_i64(ctx, ofs, key) |
| Find value by key and test for integer type. | |
| #define | lite3_ctx_is_f64(ctx, ofs, key) |
| Find value by key and test for floating point type. | |
| #define | lite3_ctx_is_bytes(ctx, ofs, key) |
| Find value by key and test for bytes type. | |
| #define | lite3_ctx_is_str(ctx, ofs, key) |
| Find value by key and test for string type. | |
| #define | lite3_ctx_is_obj(ctx, ofs, key) |
| Find value by key and test for object type. | |
| #define | lite3_ctx_is_arr(ctx, ofs, key) |
| Find value by key and test for array type. | |
Functions | |
| static void | lite3_ctx_print (lite3_ctx *ctx) |
| View the internal structure of a Lite³ buffer. | |
| static enum lite3_type | lite3_ctx_get_root_type (lite3_ctx *ctx) |
| Get the root type of a Lite³ buffer. | |
| static enum lite3_type | lite3_ctx_arr_get_type (lite3_ctx *ctx, size_t ofs, uint32_t index) |
| Find array value by index and return value type. | |
| static int | lite3_ctx_count (lite3_ctx *ctx, size_t ofs, uint32_t *out) |
| Write back the number of object entries or array elements. | |
Utility functions.
The ofs (offset) field is used to target an object or array inside the Lite³ buffer. To target the root-level object/array, use ofs == 0.
| #define lite3_ctx_exists | ( | ctx, | |
| ofs, | |||
| key | |||
| ) |
Attempt to find a key.
| [in] | ctx | (lite3_ctx *) context pointer |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
true on success false on failure Definition at line 1292 of file lite3_context_api.h.
| #define lite3_ctx_get_type | ( | ctx, | |
| ofs, | |||
| key | |||
| ) |
Find value by key and return value type.
| [in] | ctx | (lite3_ctx *) context pointer |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
lite3_type on success LITE3_TYPE_INVALID on error (key cannot be found) Definition at line 1231 of file lite3_context_api.h.
| #define lite3_ctx_get_type_size | ( | ctx, | |
| ofs, | |||
| key, | |||
| out | |||
| ) |
Find value by key and write back type size.
| [in] | ctx | (lite3_ctx *) context pointer |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
| [out] | out | (size *) type size |
LITE3_TYPE_BYTES or LITE3_TYPE_STRING, the number of bytes (including NULL-terminator for string) are written back. Definition at line 1271 of file lite3_context_api.h.
| #define lite3_ctx_is_arr | ( | ctx, | |
| ofs, | |||
| key | |||
| ) |
Find value by key and test for array type.
| [in] | ctx | (lite3_ctx *) context pointer |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
true if the value matches the type false if the type does not match or the key cannot be found Definition at line 1477 of file lite3_context_api.h.
| #define lite3_ctx_is_bool | ( | ctx, | |
| ofs, | |||
| key | |||
| ) |
Find value by key and test for bool type.
| [in] | ctx | (lite3_ctx *) context pointer |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
true if the value matches the type false if the type does not match or the key cannot be found Definition at line 1350 of file lite3_context_api.h.
| #define lite3_ctx_is_bytes | ( | ctx, | |
| ofs, | |||
| key | |||
| ) |
Find value by key and test for bytes type.
| [in] | ctx | (lite3_ctx *) context pointer |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
true if the value matches the type false if the type does not match or the key cannot be found Definition at line 1413 of file lite3_context_api.h.
| #define lite3_ctx_is_f64 | ( | ctx, | |
| ofs, | |||
| key | |||
| ) |
Find value by key and test for floating point type.
| [in] | ctx | (lite3_ctx *) context pointer |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
true if the value matches the type false if the type does not match or the key cannot be found Definition at line 1392 of file lite3_context_api.h.
| #define lite3_ctx_is_i64 | ( | ctx, | |
| ofs, | |||
| key | |||
| ) |
Find value by key and test for integer type.
| [in] | ctx | (lite3_ctx *) context pointer |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
true if the value matches the type false if the type does not match or the key cannot be found Definition at line 1371 of file lite3_context_api.h.
| #define lite3_ctx_is_null | ( | ctx, | |
| ofs, | |||
| key | |||
| ) |
Find value by key and test for null type.
| [in] | ctx | (lite3_ctx *) context pointer |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
true if the value matches the type false if the type does not match or the key cannot be found Definition at line 1329 of file lite3_context_api.h.
| #define lite3_ctx_is_obj | ( | ctx, | |
| ofs, | |||
| key | |||
| ) |
Find value by key and test for object type.
| [in] | ctx | (lite3_ctx *) context pointer |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
true if the value matches the type false if the type does not match or the key cannot be found Definition at line 1455 of file lite3_context_api.h.
| #define lite3_ctx_is_str | ( | ctx, | |
| ofs, | |||
| key | |||
| ) |
Find value by key and test for string type.
| [in] | ctx | (lite3_ctx *) context pointer |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
true if the value matches the type false if the type does not match or the key cannot be found Definition at line 1434 of file lite3_context_api.h.
|
inlinestatic |
Find array value by index and return value type.
| [in] | ctx | (lite3_ctx *) context pointer |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | index | (uint32_t) array index |
lite3_type on success LITE3_TYPE_INVALID on error (index out of bounds) Definition at line 1252 of file lite3_context_api.h.
|
inlinestatic |
Write back the number of object entries or array elements.
This function can be called on objects and arrays.
| [in] | ctx | context pointer |
| [in] | ofs | start offset (0 == root) |
| [out] | out | number of object entries or array elements |
Definition at line 1311 of file lite3_context_api.h.
|
inlinestatic |
Get the root type of a Lite³ buffer.
| [in] | ctx | (lite3_ctx *) context pointer |
lite3_type on success (LITE3_TYPE_OBJECT or LITE3_TYPE_ARRAY) LITE3_TYPE_INVALID on error (empty/uninitialized buffer) Definition at line 1214 of file lite3_context_api.h.
|
inlinestatic |
View the internal structure of a Lite³ buffer.
Requires LITE3_DEBUG enabled. See Library Configuration Options.
Definition at line 1201 of file lite3_context_api.h.