|
Lite³
A JSON-Compatible Zero-Copy Serialization Format
|
Create and use iterators for objects/arrays. More...
Data Structures | |
| struct | lite3_iter |
| Struct containing iterator state. More... | |
Macros | |
| #define | LITE3_ITER_ITEM |
Return value of lite3_iter_next(); iterator produced an item, continue;. | |
| #define | LITE3_ITER_DONE |
Return value of lite3_iter_next(); iterator finished; stop. | |
Functions | |
| static int | lite3_iter_create (const unsigned char *buf, size_t buflen, size_t ofs, lite3_iter *out) |
| Create a lite3 iterator for the given object or array. | |
| int | lite3_iter_next (const unsigned char *buf, size_t buflen, lite3_iter *iter, lite3_str *out_key, size_t *out_val_ofs) |
| Get the next item from a lite3 iterator. | |
Create and use iterators for objects/arrays.
Iter 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.
| #define LITE3_ITER_DONE |
Return value of lite3_iter_next(); iterator finished; stop.
| #define LITE3_ITER_ITEM |
Return value of lite3_iter_next(); iterator produced an item, continue;.
|
inlinestatic |
| int lite3_iter_next | ( | const unsigned char * | buf, |
| size_t | buflen, | ||
| lite3_iter * | iter, | ||
| lite3_str * | out_key, | ||
| size_t * | out_val_ofs | ||
| ) |
Get the next item from a lite3 iterator.
To use in conjunctions with lite3_val functions, the *out_val_ofs can be casted to (lite3_val *).
LITE3_ITER_ITEM (== 1) on item produced LITE3_ITER_DONE (== 0) on success (no more items) out_key should always be passed as NULL.lite3_set_xxxx() will immediately invalidate the iterator. If you need to make changes to the buffer, first prepare your changes, then apply them afterwards in one batch. | [in] | buf | buffer pointer |
| [in] | buflen | buffer used length |
| [in] | iter | iterator struct pointer |
| [out] | out_key | current key (if not needed, pass NULL) |
| [out] | out_val_ofs | current value offset (if not needed, pass NULL) |