Lines Matching defs:qdict

15 #include "qapi/qmp/qdict.h"
36 QDict *qdict;
38 qdict = g_malloc0(sizeof(*qdict));
39 QOBJECT_INIT(qdict, &qdict_type);
41 return qdict;
86 * qdict_entry_value(): Return qdict entry value
96 * qdict_entry_key(): Return qdict entry key
109 static QDictEntry *qdict_find(const QDict *qdict,
114 QLIST_FOREACH(entry, &qdict->table[bucket], next)
124 * Insert the pair 'key:value' into 'qdict', if 'key' already exists
132 void qdict_put_obj(QDict *qdict, const char *key, QObject *value)
138 entry = qdict_find(qdict, key, bucket);
146 QLIST_INSERT_HEAD(&qdict->table[bucket], entry, next);
147 qdict->size++;
157 QObject *qdict_get(const QDict *qdict, const char *key)
161 entry = qdict_find(qdict, key, tdb_hash(key) % QDICT_BUCKET_MAX);
170 int qdict_haskey(const QDict *qdict, const char *key)
173 return (qdict_find(qdict, key, bucket) == NULL ? 0 : 1);
179 size_t qdict_size(const QDict *qdict)
181 return qdict->size;
187 static QObject *qdict_get_obj(const QDict *qdict, const char *key,
192 obj = qdict_get(qdict, key);
207 double qdict_get_double(const QDict *qdict, const char *key)
209 QObject *obj = qdict_get(qdict, key);
230 int64_t qdict_get_int(const QDict *qdict, const char *key)
232 QObject *obj = qdict_get_obj(qdict, key, QTYPE_QINT);
244 int qdict_get_bool(const QDict *qdict, const char *key)
246 QObject *obj = qdict_get_obj(qdict, key, QTYPE_QBOOL);
258 QList *qdict_get_qlist(const QDict *qdict, const char *key)
260 return qobject_to_qlist(qdict_get_obj(qdict, key, QTYPE_QLIST));
271 QDict *qdict_get_qdict(const QDict *qdict, const char *key)
273 return qobject_to_qdict(qdict_get_obj(qdict, key, QTYPE_QDICT));
285 const char *qdict_get_str(const QDict *qdict, const char *key)
287 QObject *obj = qdict_get_obj(qdict, key, QTYPE_QSTRING);
298 int64_t qdict_get_try_int(const QDict *qdict, const char *key,
303 obj = qdict_get(qdict, key);
317 int qdict_get_try_bool(const QDict *qdict, const char *key, int def_value)
321 obj = qdict_get(qdict, key);
336 const char *qdict_get_try_str(const QDict *qdict, const char *key)
340 obj = qdict_get(qdict, key);
353 void qdict_iter(const QDict *qdict,
361 QLIST_FOREACH(entry, &qdict->table[i], next)
366 static QDictEntry *qdict_next_entry(const QDict *qdict, int first_bucket)
371 if (!QLIST_EMPTY(&qdict->table[i])) {
372 return QLIST_FIRST(&qdict->table[i]);
380 * qdict_first(): Return first qdict entry for iteration.
382 const QDictEntry *qdict_first(const QDict *qdict)
384 return qdict_next_entry(qdict, 0);
388 * qdict_next(): Return next qdict entry in an iteration.
390 const QDictEntry *qdict_next(const QDict *qdict, const QDictEntry *entry)
397 ret = qdict_next_entry(qdict, bucket + 1);
444 void qdict_del(QDict *qdict, const char *key)
448 entry = qdict_find(qdict, key, tdb_hash(key) % QDICT_BUCKET_MAX);
452 qdict->size--;
462 QDict *qdict;
465 qdict = qobject_to_qdict(obj);
468 QDictEntry *entry = QLIST_FIRST(&qdict->table[i]);
477 g_free(qdict);
480 static void qdict_do_flatten(QDict *qdict, QDict *target, const char *prefix)
487 entry = qdict_first(qdict);
491 next = qdict_next(qdict, entry);
516 qdict_del(qdict, entry->key);
519 entry = qdict_first(qdict);
532 void qdict_flatten(QDict *qdict)
534 qdict_do_flatten(qdict, qdict, NULL);