Revision acc3b033

b/Makefile
140 140

  
141 141
check-qint: check-qint.o qint.o qemu-malloc.o
142 142
check-qstring: check-qstring.o qstring.o qemu-malloc.o
143
check-qdict: check-qdict.o qdict.o qint.o qstring.o qbool.o qemu-malloc.o qlist.o
143
check-qdict: check-qdict.o qdict.o qfloat.o qint.o qstring.o qbool.o qemu-malloc.o qlist.o
144 144
check-qlist: check-qlist.o qlist.o qint.o qemu-malloc.o
145 145
check-qfloat: check-qfloat.o qfloat.o qemu-malloc.o
146 146
check-qjson: check-qjson.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o qjson.o json-streamer.o json-lexer.o json-parser.o qemu-malloc.o
b/qdict.c
11 11
 */
12 12

  
13 13
#include "qint.h"
14
#include "qfloat.h"
14 15
#include "qdict.h"
15 16
#include "qbool.h"
16 17
#include "qstring.h"
......
175 176
}
176 177

  
177 178
/**
179
 * qdict_get_double(): Get an number mapped by 'key'
180
 *
181
 * This function assumes that 'key' exists and it stores a
182
 * QFloat or QInt object.
183
 *
184
 * Return number mapped by 'key'.
185
 */
186
double qdict_get_double(const QDict *qdict, const char *key)
187
{
188
    QObject *obj = qdict_get(qdict, key);
189

  
190
    assert(obj);
191
    switch (qobject_type(obj)) {
192
    case QTYPE_QFLOAT:
193
        return qfloat_get_double(qobject_to_qfloat(obj));
194
    case QTYPE_QINT:
195
        return qint_get_int(qobject_to_qint(obj));
196
    default:
197
        assert(0);
198
    }
199
}
200

  
201
/**
178 202
 * qdict_get_int(): Get an integer mapped by 'key'
179 203
 *
180 204
 * This function assumes that 'key' exists and it stores a
b/qdict.h
37 37
        qdict_put_obj(qdict, key, QOBJECT(obj))
38 38

  
39 39
/* High level helpers */
40
double qdict_get_double(const QDict *qdict, const char *key);
40 41
int64_t qdict_get_int(const QDict *qdict, const char *key);
41 42
int qdict_get_bool(const QDict *qdict, const char *key);
42 43
QList *qdict_get_qlist(const QDict *qdict, const char *key);

Also available in: Unified diff