aboutsummaryrefslogtreecommitdiffstats
path: root/qdict.c
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2010-05-10 23:26:01 -0700
committerDavid 'Digit' Turner <digit@android.com>2010-05-11 17:56:30 -0700
commit9251866320b5f8329a043bb56b3a794f78d12849 (patch)
treeca005574fbc5833f93d55ce72881780aa7e78aaf /qdict.c
parent1da50d3beb2a75f619fa56278cb195703361e261 (diff)
downloadexternal_qemu-9251866320b5f8329a043bb56b3a794f78d12849.zip
external_qemu-9251866320b5f8329a043bb56b3a794f78d12849.tar.gz
external_qemu-9251866320b5f8329a043bb56b3a794f78d12849.tar.bz2
Upstream: integrate various misc. minor changes
Change-Id: I7d3eca1350f980d93f9f3198fa5250fb776de729
Diffstat (limited to 'qdict.c')
-rw-r--r--qdict.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/qdict.c b/qdict.c
index c6a5a42..7d1469d 100644
--- a/qdict.c
+++ b/qdict.c
@@ -11,6 +11,7 @@
*/
#include "qint.h"
+#include "qfloat.h"
#include "qdict.h"
#include "qbool.h"
#include "qstring.h"
@@ -175,6 +176,29 @@ static QObject *qdict_get_obj(const QDict *qdict, const char *key,
}
/**
+ * qdict_get_double(): Get an number mapped by 'key'
+ *
+ * This function assumes that 'key' exists and it stores a
+ * QFloat or QInt object.
+ *
+ * Return number mapped by 'key'.
+ */
+double qdict_get_double(const QDict *qdict, const char *key)
+{
+ QObject *obj = qdict_get(qdict, key);
+
+ assert(obj);
+ switch (qobject_type(obj)) {
+ case QTYPE_QFLOAT:
+ return qfloat_get_double(qobject_to_qfloat(obj));
+ case QTYPE_QINT:
+ return qint_get_int(qobject_to_qint(obj));
+ default:
+ assert(0);
+ }
+}
+
+/**
* qdict_get_int(): Get an integer mapped by 'key'
*
* This function assumes that 'key' exists and it stores a