Utility functions.
More...
|
| #define | lite3_get_type(buf, buflen, ofs, key) |
| | Find value by key and return value type.
|
| |
| #define | lite3_get_type_size(buf, buflen, ofs, key, out) |
| | Find value by key and write back type size.
|
| |
| #define | lite3_exists(buf, buflen, ofs, key) |
| | Attempt to find a key.
|
| |
| #define | lite3_is_null(buf, buflen, ofs, key) |
| | Find value by key and test for null type.
|
| |
| #define | lite3_is_bool(buf, buflen, ofs, key) |
| | Find value by key and test for bool type.
|
| |
| #define | lite3_is_i64(buf, buflen, ofs, key) |
| | Find value by key and test for integer type.
|
| |
| #define | lite3_is_f64(buf, buflen, ofs, key) |
| | Find value by key and test for floating point type.
|
| |
| #define | lite3_is_bytes(buf, buflen, ofs, key) |
| | Find value by key and test for bytes type.
|
| |
| #define | lite3_is_str(buf, buflen, ofs, key) |
| | Find value by key and test for string type.
|
| |
| #define | lite3_is_obj(buf, buflen, ofs, key) |
| | Find value by key and test for object type.
|
| |
| #define | lite3_is_arr(buf, buflen, ofs, key) |
| | Find value by key and test for array type.
|
| |
|
| static int | lite3_count (unsigned char *buf, size_t buflen, size_t ofs, uint32_t *out) |
| | Write back the number of object entries or array elements.
|
| |
Utility functions.
Get functions read buflen to know the currently used portion of the buffer.
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.
- Warning
- Read-only operations are thread-safe. This includes all utility funtions. Mixing reads and writes however is not thread-safe.
◆ lite3_exists
| #define lite3_exists |
( |
|
buf, |
|
|
|
buflen, |
|
|
|
ofs, |
|
|
|
key |
|
) |
| |
Attempt to find a key.
- Parameters
-
| [in] | buf | (const unsigned char *) buffer pointer |
| [in] | buflen | (size_t) buffer used length |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
- Returns
true on success
-
false on failure
Definition at line 1820 of file lite3.h.
◆ lite3_get_type
| #define lite3_get_type |
( |
|
buf, |
|
|
|
buflen, |
|
|
|
ofs, |
|
|
|
key |
|
) |
| |
Find value by key and return value type.
- Parameters
-
| [in] | buf | (const unsigned char *) buffer pointer |
| [in] | buflen | (size_t) buffer used length |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
- Returns
- lite3_type on success
-
LITE3_TYPE_INVALID on error (key cannot be found)
Definition at line 1754 of file lite3.h.
◆ lite3_get_type_size
| #define lite3_get_type_size |
( |
|
buf, |
|
|
|
buflen, |
|
|
|
ofs, |
|
|
|
key, |
|
|
|
out |
|
) |
| |
Find value by key and write back type size.
- Parameters
-
| [in] | buf | (const unsigned char *) buffer pointer |
| [in] | buflen | (size_t) buffer used length |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
| [out] | out | (size *) type size |
- Returns
- 0 on success
-
< 0 on error
- Note
- For variable sized types like
LITE3_TYPE_BYTES or LITE3_TYPE_STRING, the number of bytes (including NULL-terminator for string) are written back.
Definition at line 1786 of file lite3.h.
◆ lite3_is_arr
| #define lite3_is_arr |
( |
|
buf, |
|
|
|
buflen, |
|
|
|
ofs, |
|
|
|
key |
|
) |
| |
Find value by key and test for array type.
- Parameters
-
| [in] | buf | (const unsigned char *) buffer pointer |
| [in] | buflen | (size_t) buffer used length |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
- Returns
true if the value matches the type
-
false if the type does not match or the key cannot be found
Definition at line 2063 of file lite3.h.
◆ lite3_is_bool
| #define lite3_is_bool |
( |
|
buf, |
|
|
|
buflen, |
|
|
|
ofs, |
|
|
|
key |
|
) |
| |
Find value by key and test for bool type.
- Parameters
-
| [in] | buf | (const unsigned char *) buffer pointer |
| [in] | buflen | (size_t) buffer used length |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
- Returns
true if the value matches the type
-
false if the type does not match or the key cannot be found
Definition at line 1901 of file lite3.h.
◆ lite3_is_bytes
| #define lite3_is_bytes |
( |
|
buf, |
|
|
|
buflen, |
|
|
|
ofs, |
|
|
|
key |
|
) |
| |
Find value by key and test for bytes type.
- Parameters
-
| [in] | buf | (const unsigned char *) buffer pointer |
| [in] | buflen | (size_t) buffer used length |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
- Returns
true if the value matches the type
-
false if the type does not match or the key cannot be found
Definition at line 1982 of file lite3.h.
◆ lite3_is_f64
| #define lite3_is_f64 |
( |
|
buf, |
|
|
|
buflen, |
|
|
|
ofs, |
|
|
|
key |
|
) |
| |
Find value by key and test for floating point type.
- Parameters
-
| [in] | buf | (const unsigned char *) buffer pointer |
| [in] | buflen | (size_t) buffer used length |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
- Returns
true if the value matches the type
-
false if the type does not match or the key cannot be found
Definition at line 1955 of file lite3.h.
◆ lite3_is_i64
| #define lite3_is_i64 |
( |
|
buf, |
|
|
|
buflen, |
|
|
|
ofs, |
|
|
|
key |
|
) |
| |
Find value by key and test for integer type.
- Parameters
-
| [in] | buf | (const unsigned char *) buffer pointer |
| [in] | buflen | (size_t) buffer used length |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
- Returns
true if the value matches the type
-
false if the type does not match or the key cannot be found
Definition at line 1928 of file lite3.h.
◆ lite3_is_null
| #define lite3_is_null |
( |
|
buf, |
|
|
|
buflen, |
|
|
|
ofs, |
|
|
|
key |
|
) |
| |
Find value by key and test for null type.
- Parameters
-
| [in] | buf | (const unsigned char *) buffer pointer |
| [in] | buflen | (size_t) buffer used length |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
- Returns
true if the value matches the type
-
false if the type does not match or the key cannot be found
Definition at line 1874 of file lite3.h.
◆ lite3_is_obj
| #define lite3_is_obj |
( |
|
buf, |
|
|
|
buflen, |
|
|
|
ofs, |
|
|
|
key |
|
) |
| |
Find value by key and test for object type.
- Parameters
-
| [in] | buf | (const unsigned char *) buffer pointer |
| [in] | buflen | (size_t) buffer used length |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
- Returns
true if the value matches the type
-
false if the type does not match or the key cannot be found
Definition at line 2036 of file lite3.h.
◆ lite3_is_str
| #define lite3_is_str |
( |
|
buf, |
|
|
|
buflen, |
|
|
|
ofs, |
|
|
|
key |
|
) |
| |
Find value by key and test for string type.
- Parameters
-
| [in] | buf | (const unsigned char *) buffer pointer |
| [in] | buflen | (size_t) buffer used length |
| [in] | ofs | (size_t) start offset (0 == root) |
| [in] | key | (const char *) key |
- Returns
true if the value matches the type
-
false if the type does not match or the key cannot be found
Definition at line 2009 of file lite3.h.
◆ lite3_count()
| static int lite3_count |
( |
unsigned char * |
buf, |
|
|
size_t |
buflen, |
|
|
size_t |
ofs, |
|
|
uint32_t * |
out |
|
) |
| |
|
inlinestatic |
Write back the number of object entries or array elements.
This function can be called on objects and arrays.
- Returns
- 0 on success
-
< 0 on error
- Parameters
-
| [in] | buf | buffer pointer |
| [in] | buflen | buffer used length |
| [in] | ofs | start offset (0 == root) |
| [out] | out | number of object entries or array elements |
Definition at line 1844 of file lite3.h.