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