mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
QDict: Introduce new iteration API
It's composed of functions qdict_first() and qdict_next(), plus functions to access QDictEntry values. This API was suggested by Markus Armbruster <armbru@redhat.com> and it offers full control over the iteration process. The usage is simple, the following example prints all keys in 'qdict' (it's hopefully better than any English description): QDict *qdict; const QDictEntry *ent; [...] for (ent = qdict_first(qdict); ent; ent = qdict_next(qdict, ent)) { printf("%s ", qdict_entry_key(ent)); } Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
0d078b2ade
commit
f2b07f35d2
2 changed files with 39 additions and 0 deletions
2
qdict.h
2
qdict.h
|
@ -45,6 +45,8 @@ QDict *qobject_to_qdict(const QObject *obj);
|
|||
void qdict_iter(const QDict *qdict,
|
||||
void (*iter)(const char *key, QObject *obj, void *opaque),
|
||||
void *opaque);
|
||||
const QDictEntry *qdict_first(const QDict *qdict);
|
||||
const QDictEntry *qdict_next(const QDict *qdict, const QDictEntry *entry);
|
||||
|
||||
/* Helper to qdict_put_obj(), accepts any object */
|
||||
#define qdict_put(qdict, key, obj) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue