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