root / qdict.h @ 8d0eb050
History | View | Annotate | Download (1.2 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 | 72cf2d4f | Blue Swirl | #include "qemu-queue.h" |
6 | fb08dde0 | Luiz Capitulino | #include <stdint.h> |
7 | fb08dde0 | Luiz Capitulino | |
8 | fb08dde0 | Luiz Capitulino | #define QDICT_HASH_SIZE 512 |
9 | fb08dde0 | Luiz Capitulino | |
10 | fb08dde0 | Luiz Capitulino | typedef struct QDictEntry { |
11 | fb08dde0 | Luiz Capitulino | char *key;
|
12 | fb08dde0 | Luiz Capitulino | QObject *value; |
13 | 72cf2d4f | Blue Swirl | QLIST_ENTRY(QDictEntry) next; |
14 | fb08dde0 | Luiz Capitulino | } QDictEntry; |
15 | fb08dde0 | Luiz Capitulino | |
16 | fb08dde0 | Luiz Capitulino | typedef struct QDict { |
17 | fb08dde0 | Luiz Capitulino | QObject_HEAD; |
18 | fb08dde0 | Luiz Capitulino | size_t size; |
19 | 72cf2d4f | Blue Swirl | QLIST_HEAD(,QDictEntry) table[QDICT_HASH_SIZE]; |
20 | fb08dde0 | Luiz Capitulino | } QDict; |
21 | fb08dde0 | Luiz Capitulino | |
22 | fb08dde0 | Luiz Capitulino | /* Object API */
|
23 | fb08dde0 | Luiz Capitulino | QDict *qdict_new(void);
|
24 | fb08dde0 | Luiz Capitulino | size_t qdict_size(const QDict *qdict);
|
25 | fb08dde0 | Luiz Capitulino | void qdict_put_obj(QDict *qdict, const char *key, QObject *value); |
26 | fb08dde0 | Luiz Capitulino | void qdict_del(QDict *qdict, const char *key); |
27 | fb08dde0 | Luiz Capitulino | int qdict_haskey(const QDict *qdict, const char *key); |
28 | fb08dde0 | Luiz Capitulino | QObject *qdict_get(const QDict *qdict, const char *key); |
29 | fb08dde0 | Luiz Capitulino | QDict *qobject_to_qdict(const QObject *obj);
|
30 | fb08dde0 | Luiz Capitulino | |
31 | fb08dde0 | Luiz Capitulino | /* Helper to qdict_put_obj(), accepts any object */
|
32 | fb08dde0 | Luiz Capitulino | #define qdict_put(qdict, key, obj) \
|
33 | fb08dde0 | Luiz Capitulino | qdict_put_obj(qdict, key, QOBJECT(obj)) |
34 | fb08dde0 | Luiz Capitulino | |
35 | fb08dde0 | Luiz Capitulino | /* High level helpers */
|
36 | fb08dde0 | Luiz Capitulino | int64_t qdict_get_int(const QDict *qdict, const char *key); |
37 | fb08dde0 | Luiz Capitulino | const char *qdict_get_str(const QDict *qdict, const char *key); |
38 | fb08dde0 | Luiz Capitulino | int64_t qdict_get_try_int(const QDict *qdict, const char *key, |
39 | fb08dde0 | Luiz Capitulino | int64_t err_value); |
40 | fb08dde0 | Luiz Capitulino | const char *qdict_get_try_str(const QDict *qdict, const char *key); |
41 | fb08dde0 | Luiz Capitulino | |
42 | fb08dde0 | Luiz Capitulino | #endif /* QDICT_H */ |