qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 2/8] QDict: New qdict_get_double()


From: Markus Armbruster
Subject: [Qemu-devel] [PATCH v2 2/8] QDict: New qdict_get_double()
Date: Wed, 20 Jan 2010 17:08:16 +0100

Helper function just like qdict_get_int(), just for QFloat/double.

Signed-off-by: Markus Armbruster <address@hidden>
---
 qdict.c |   15 +++++++++++++++
 qdict.h |    1 +
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/qdict.c b/qdict.c
index ba8eef0..de278b1 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,20 @@ 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 object.
+ *
+ * Return number mapped by 'key'.
+ */
+double qdict_get_double(const QDict *qdict, const char *key)
+{
+    QObject *obj = qdict_get_obj(qdict, key, QTYPE_QFLOAT);
+    return qfloat_get_double(qobject_to_qfloat(obj));
+}
+
+/**
  * qdict_get_int(): Get an integer mapped by 'key'
  *
  * This function assumes that 'key' exists and it stores a
diff --git a/qdict.h b/qdict.h
index 5fef1ea..5649ccf 100644
--- a/qdict.h
+++ b/qdict.h
@@ -37,6 +37,7 @@ void qdict_iter(const QDict *qdict,
         qdict_put_obj(qdict, key, QOBJECT(obj))
 
 /* High level helpers */
+double qdict_get_double(const QDict *qdict, const char *key);
 int64_t qdict_get_int(const QDict *qdict, const char *key);
 int qdict_get_bool(const QDict *qdict, const char *key);
 QList *qdict_get_qlist(const QDict *qdict, const char *key);
-- 
1.6.6





reply via email to

[Prev in Thread] Current Thread [Next in Thread]