diff options
author | Markus Armbruster <armbru@redhat.com> | 2010-01-27 17:16:38 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-02-03 12:36:25 -0600 |
commit | acc3b0336c24a0f8c2a9638fb7ae8580484b59ca (patch) | |
tree | 95e0f7991107d0d01f66a1e8bcdf829de5cc1d44 /qdict.c | |
parent | 9fec543fa69b03b82b5ffe4d1bf280701efaad1e (diff) |
QDict: New qdict_get_double()
Helper function just like qdict_get_int(), just for QFloat/double.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qdict.c')
-rw-r--r-- | qdict.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -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 |