aboutsummaryrefslogtreecommitdiff
path: root/include/qapi/qmp/qdict.h
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2017-04-27 16:58:16 -0500
committerMarkus Armbruster <armbru@redhat.com>2017-05-08 20:32:14 +0200
commita92c21591b5bb9543996538f14854ca6b528318b (patch)
tree5d005d08f0fa3daff8767dcf8a2ba77a4edcee1d /include/qapi/qmp/qdict.h
parentde6e7951fe66053dfeaac1a237f7aceb9e079619 (diff)
qobject: Add helper macros for common scalar insertions
Rather than making lots of callers wrap a scalar in a QInt, QString, or QBool, provide helper macros that do the wrapping automatically. Update the Coccinelle script to make mass conversions easy, although the conversion itself will be done as a separate patches to ease review and backport efforts. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20170427215821.19397-6-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'include/qapi/qmp/qdict.h')
-rw-r--r--include/qapi/qmp/qdict.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h
index fe9a4c5c60..188440a6a8 100644
--- a/include/qapi/qmp/qdict.h
+++ b/include/qapi/qmp/qdict.h
@@ -52,6 +52,14 @@ void qdict_destroy_obj(QObject *obj);
#define qdict_put(qdict, key, obj) \
qdict_put_obj(qdict, key, QOBJECT(obj))
+/* Helpers for int, bool, and string */
+#define qdict_put_int(qdict, key, value) \
+ qdict_put(qdict, key, qint_from_int(value))
+#define qdict_put_bool(qdict, key, value) \
+ qdict_put(qdict, key, qbool_from_bool(value))
+#define qdict_put_str(qdict, key, value) \
+ qdict_put(qdict, key, qstring_from_str(value))
+
/* High level helpers */
double qdict_get_double(const QDict *qdict, const char *key);
int64_t qdict_get_int(const QDict *qdict, const char *key);