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.
16 #include "qapi/qmp/qobject.h"
17 #include "qemu/queue.h"
19 #define QDICT_BUCKET_MAX 512
21 typedef struct QDictEntry
{
24 QLIST_ENTRY(QDictEntry
) next
;
28 struct QObjectBase_ base
;
30 QLIST_HEAD(,QDictEntry
) table
[QDICT_BUCKET_MAX
];
33 void qdict_unref(QDict
*q
);
35 G_DEFINE_AUTOPTR_CLEANUP_FUNC(QDict
, qdict_unref
)
38 QDict
*qdict_new(void);
39 const char *qdict_entry_key(const QDictEntry
*entry
);
40 QObject
*qdict_entry_value(const QDictEntry
*entry
);
41 size_t qdict_size(const QDict
*qdict
);
42 void qdict_put_obj(QDict
*qdict
, const char *key
, QObject
*value
);
43 void qdict_del(QDict
*qdict
, const char *key
);
44 int qdict_haskey(const QDict
*qdict
, const char *key
);
45 QObject
*qdict_get(const QDict
*qdict
, const char *key
);
46 const QDictEntry
*qdict_first(const QDict
*qdict
);
47 const QDictEntry
*qdict_next(const QDict
*qdict
, const QDictEntry
*entry
);
49 /* Helper to qdict_put_obj(), accepts any object */
50 #define qdict_put(qdict, key, obj) \
51 qdict_put_obj(qdict, key, QOBJECT(obj))
53 void qdict_put_bool(QDict
*qdict
, const char *key
, bool value
);
54 void qdict_put_int(QDict
*qdict
, const char *key
, int64_t value
);
55 void qdict_put_null(QDict
*qdict
, const char *key
);
56 void qdict_put_str(QDict
*qdict
, const char *key
, const char *value
);
58 double qdict_get_double(const QDict
*qdict
, const char *key
);
59 int64_t qdict_get_int(const QDict
*qdict
, const char *key
);
60 bool qdict_get_bool(const QDict
*qdict
, const char *key
);
61 QList
*qdict_get_qlist(const QDict
*qdict
, const char *key
);
62 QDict
*qdict_get_qdict(const QDict
*qdict
, const char *key
);
63 const char *qdict_get_str(const QDict
*qdict
, const char *key
);
64 int64_t qdict_get_try_int(const QDict
*qdict
, const char *key
,
66 bool qdict_get_try_bool(const QDict
*qdict
, const char *key
, bool def_value
);
67 const char *qdict_get_try_str(const QDict
*qdict
, const char *key
);
69 QDict
*qdict_clone_shallow(const QDict
*src
);