4 * Copyright (C) 2009 Red Hat Inc.
7 * Luiz Capitulino <lcapitulino@redhat.com>
9 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
10 * See the COPYING.LIB file in the top-level directory.
18 #include "qemu-queue.h"
21 #define QDICT_HASH_SIZE 512
23 typedef struct QDictEntry
{
26 QLIST_ENTRY(QDictEntry
) next
;
29 typedef struct QDict
{
32 QLIST_HEAD(,QDictEntry
) table
[QDICT_HASH_SIZE
];
36 QDict
*qdict_new(void);
37 size_t qdict_size(const QDict
*qdict
);
38 void qdict_put_obj(QDict
*qdict
, const char *key
, QObject
*value
);
39 void qdict_del(QDict
*qdict
, const char *key
);
40 int qdict_haskey(const QDict
*qdict
, const char *key
);
41 QObject
*qdict_get(const QDict
*qdict
, const char *key
);
42 QDict
*qobject_to_qdict(const QObject
*obj
);
43 void qdict_iter(const QDict
*qdict
,
44 void (*iter
)(const char *key
, QObject
*obj
, void *opaque
),
47 /* Helper to qdict_put_obj(), accepts any object */
48 #define qdict_put(qdict, key, obj) \
49 qdict_put_obj(qdict, key, QOBJECT(obj))
51 /* High level helpers */
52 double qdict_get_double(const QDict
*qdict
, const char *key
);
53 int64_t qdict_get_int(const QDict
*qdict
, const char *key
);
54 int qdict_get_bool(const QDict
*qdict
, const char *key
);
55 QList
*qdict_get_qlist(const QDict
*qdict
, const char *key
);
56 QDict
*qdict_get_qdict(const QDict
*qdict
, const char *key
);
57 const char *qdict_get_str(const QDict
*qdict
, const char *key
);
58 int64_t qdict_get_try_int(const QDict
*qdict
, const char *key
,
60 const char *qdict_get_try_str(const QDict
*qdict
, const char *key
);