|
Lite³
A JSON-Compatible Zero-Copy Serialization Format
|
Create and use iterators for objects/arrays. More...
Macros | |
| #define | LITE3_ITER_ITEM |
Return value of lite3_ctx_iter_next(); iterator produced an item, continue;. | |
| #define | LITE3_ITER_DONE |
Return value of lite3_ctx_iter_next(); iterator finished; stop. | |
Functions | |
| static int | lite3_ctx_iter_create (lite3_ctx *ctx, size_t ofs, lite3_iter *out) |
| Create a lite3 iterator for the given object or array. | |
| static int | lite3_ctx_iter_next (lite3_ctx *ctx, 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.
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_ctx_iter_next(); iterator finished; stop.
Definition at line 2046 of file lite3_context_api.h.
| #define LITE3_ITER_ITEM |
Return value of lite3_ctx_iter_next(); iterator produced an item, continue;.
Definition at line 2044 of file lite3_context_api.h.
|
inlinestatic |
Create a lite3 iterator for the given object or array.
| [in] | ctx | context pointer |
| [in] | ofs | start offset (0 == root) |
| [out] | out | iterator struct pointer |
Definition at line 2055 of file lite3_context_api.h.
|
inlinestatic |
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_ctx_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] | ctx | context pointer |
| [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) |
Definition at line 2082 of file lite3_context_api.h.