CToon C 0.6.1
A C99 TOON/JSON serialization library
Loading...
Searching...
No Matches
ctoon_obj_iter Struct Reference

#include <ctoon.h>

Collaboration diagram for ctoon_obj_iter:

Data Fields

size_t idx
 
size_t max
 
ctoon_valcur
 
ctoon_valobj
 

Detailed Description

A TOON object iterator.

Example

ctoon_val *key, *val;
while ((key = ctoon_obj_iter_next(&iter))) {
your_func(key, val);
}
static ctoon_val * ctoon_obj_iter_get_val(ctoon_val *key)
Definition ctoon.h:5312
static ctoon_val * ctoon_obj_iter_next(ctoon_obj_iter *iter)
Definition ctoon.h:5302
static ctoon_obj_iter ctoon_obj_iter_with(ctoon_val *obj)
Definition ctoon.h:5292
ctoon_val * obj
Definition ctoon.h:1889

If the ordering of the keys is known at compile-time, you can use this method to speed up value lookups:

// {"k1":1, "k2": 3, "k3": 3}
ctoon_val *key, *val;
ctoon_val *v1 = ctoon_obj_iter_get(&iter, "k1");
ctoon_val *v3 = ctoon_obj_iter_get(&iter, "k3");
static ctoon_val * ctoon_obj_iter_get(ctoon_obj_iter *iter, const char *key)
Definition ctoon.h:5316
See also
ctoon_obj_iter_get() and ctoon_obj_iter_getn()

Definition at line 1885 of file ctoon.h.

Field Documentation

◆ cur

ctoon_val* ctoon_obj_iter::cur

next key

Definition at line 1888 of file ctoon.h.

◆ idx

size_t ctoon_obj_iter::idx

next key's index

Definition at line 1886 of file ctoon.h.

◆ max

size_t ctoon_obj_iter::max

maximum key index (obj.size)

Definition at line 1887 of file ctoon.h.

◆ obj

ctoon_val* ctoon_obj_iter::obj

the object being iterated

Definition at line 1889 of file ctoon.h.


The documentation for this struct was generated from the following file: