summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2009-12-10 17:15:53 -0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-12-12 08:17:31 -0600
commitdb830f26cbe996d1f9ea74c18ce558eedbf9bcab (patch)
tree3f651b8c3a9b2e1edf3a34ae70f98dabd6b75598 /qdict.c
parentMakefile: move QObject objs to their own entry (diff)
downloadqemu-kvm-db830f26cbe996d1f9ea74c18ce558eedbf9bcab.tar.gz
qemu-kvm-db830f26cbe996d1f9ea74c18ce558eedbf9bcab.tar.bz2
qemu-kvm-db830f26cbe996d1f9ea74c18ce558eedbf9bcab.zip
QDict: Introduce qdict_get_qbool()
This is a helper function that does type checking before retrieving a QBool from the dictionary. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> (cherry picked from commit cd4dde36ae8e7bd8e02839533c5708011bf994cf)
Diffstat (limited to 'qdict.c')
-rw-r--r--qdict.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/qdict.c b/qdict.c
index 0e04cb1fe..45e08bec9 100644
--- a/qdict.c
+++ b/qdict.c
@@ -12,6 +12,7 @@
#include "qint.h"
#include "qdict.h"
+#include "qbool.h"
#include "qstring.h"
#include "qobject.h"
#include "qemu-queue.h"
@@ -189,6 +190,20 @@ int64_t qdict_get_int(const QDict *qdict, const char *key)
}
/**
+ * qdict_get_bool(): Get a bool mapped by 'key'
+ *
+ * This function assumes that 'key' exists and it stores a
+ * QBool object.
+ *
+ * Return bool mapped by 'key'.
+ */
+int qdict_get_bool(const QDict *qdict, const char *key)
+{
+ QObject *obj = qdict_get_obj(qdict, key, QTYPE_QBOOL);
+ return qbool_get_int(qobject_to_qbool(obj));
+}
+
+/**
* qdict_get_str(): Get a pointer to the stored string mapped
* by 'key'
*