From 9251866320b5f8329a043bb56b3a794f78d12849 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Mon, 10 May 2010 23:26:01 -0700 Subject: Upstream: integrate various misc. minor changes Change-Id: I7d3eca1350f980d93f9f3198fa5250fb776de729 --- qdict.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'qdict.c') 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 -- cgit v1.1