diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2015-09-24 11:06:34 +0100 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2015-10-06 08:31:25 +0100 |
commit | d231976e240f2244c60df26a1a6600ecb325506a (patch) | |
tree | c0b3b15dfc4d0bdec97277fd27b2857654a21d36 /json-glib/json-types.h | |
parent | 5185a8f8a58e5b455116eaa8c99c4b4c38a45929 (diff) | |
download | json-glib-d231976e240f2244c60df26a1a6600ecb325506a.tar.gz |
object: Add JsonObjectIter to ease iteration over JsonObject members
This is a stack-allocated iterator object similar to GHashTableIter
which allows allocation-free iteration over the members in a JsonObject.
It differs from json_object_foreach_member() in the order in which it
iterates — for JsonObjectIter the order is undefined.
https://bugzilla.gnome.org/show_bug.cgi?id=755509
Diffstat (limited to 'json-glib/json-types.h')
-rw-r--r-- | json-glib/json-types.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/json-glib/json-types.h b/json-glib/json-types.h index 9acc23b..36519c3 100644 --- a/json-glib/json-types.h +++ b/json-glib/json-types.h @@ -368,6 +368,32 @@ void json_object_foreach_member (JsonObject *object, JsonObjectForeach func, gpointer data); +/** + * JsonObjectIter: + * + * An iterator used to iterate over the members of a #JsonObject. This must + * be allocated on the stack and initialised using json_object_iter_init(). + * The order in which members are returned by the iterator is undefined. The + * iterator is invalidated if its #JsonObject is modified during iteration. + * + * All the fields in the #JsonObjectIter structure are private and should + * never be accessed directly. + * + * Since: UNRELEASED + */ +typedef struct { + /*< private >*/ + gpointer priv[8]; +} JsonObjectIter; + +JSON_AVAILABLE_IN_1_2 +void json_object_iter_init (JsonObjectIter *iter, + JsonObject *object); +JSON_AVAILABLE_IN_1_2 +gboolean json_object_iter_next (JsonObjectIter *iter, + const gchar **member_name, + JsonNode **member_node); + JSON_AVAILABLE_IN_1_0 GType json_array_get_type (void) G_GNUC_CONST; JSON_AVAILABLE_IN_1_0 |