File:  [Qemu by Fabrice Bellard] / qemu / qdict.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:34:47 2018 UTC (3 years, 5 months ago) by root
Branches: qemu, MAIN
CVS tags: qemu0125, qemu0124, qemu0123, qemu0122, qemu0121, qemu0120, HEAD
qemu 0.12.0

    1: #ifndef QDICT_H
    2: #define QDICT_H
    3: 
    4: #include "qobject.h"
    5: #include "qlist.h"
    6: #include "qemu-queue.h"
    7: #include <stdint.h>
    8: 
    9: #define QDICT_HASH_SIZE 512
   10: 
   11: typedef struct QDictEntry {
   12:     char *key;
   13:     QObject *value;
   14:     QLIST_ENTRY(QDictEntry) next;
   15: } QDictEntry;
   16: 
   17: typedef struct QDict {
   18:     QObject_HEAD;
   19:     size_t size;
   20:     QLIST_HEAD(,QDictEntry) table[QDICT_HASH_SIZE];
   21: } QDict;
   22: 
   23: /* Object API */
   24: QDict *qdict_new(void);
   25: size_t qdict_size(const QDict *qdict);
   26: void qdict_put_obj(QDict *qdict, const char *key, QObject *value);
   27: void qdict_del(QDict *qdict, const char *key);
   28: int qdict_haskey(const QDict *qdict, const char *key);
   29: QObject *qdict_get(const QDict *qdict, const char *key);
   30: QDict *qobject_to_qdict(const QObject *obj);
   31: void qdict_iter(const QDict *qdict,
   32:                 void (*iter)(const char *key, QObject *obj, void *opaque),
   33:                 void *opaque);
   34: 
   35: /* Helper to qdict_put_obj(), accepts any object */
   36: #define qdict_put(qdict, key, obj) \
   37:         qdict_put_obj(qdict, key, QOBJECT(obj))
   38: 
   39: /* High level helpers */
   40: int64_t qdict_get_int(const QDict *qdict, const char *key);
   41: int qdict_get_bool(const QDict *qdict, const char *key);
   42: QList *qdict_get_qlist(const QDict *qdict, const char *key);
   43: const char *qdict_get_str(const QDict *qdict, const char *key);
   44: int64_t qdict_get_try_int(const QDict *qdict, const char *key,
   45:                           int64_t err_value);
   46: const char *qdict_get_try_str(const QDict *qdict, const char *key);
   47: 
   48: #endif /* QDICT_H */

unix.superglobalmegacorp.com