From patchwork Wed Jan 20 16:08:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 43305 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4A34DB7CC1 for ; Thu, 21 Jan 2010 03:24:10 +1100 (EST) Received: from localhost ([127.0.0.1]:58022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXdDH-0005au-RT for incoming@patchwork.ozlabs.org; Wed, 20 Jan 2010 11:15:23 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NXd6g-0002j8-72 for qemu-devel@nongnu.org; Wed, 20 Jan 2010 11:08:34 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NXd6a-0002ce-HK for qemu-devel@nongnu.org; Wed, 20 Jan 2010 11:08:32 -0500 Received: from [199.232.76.173] (port=38149 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXd6Y-0002cO-Tw for qemu-devel@nongnu.org; Wed, 20 Jan 2010 11:08:27 -0500 Received: from oxygen.pond.sub.org ([213.239.205.148]:57854) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NXd6X-0002cY-5v for qemu-devel@nongnu.org; Wed, 20 Jan 2010 11:08:25 -0500 Received: from blackfin.pond.sub.org (pD9E3BC04.dip.t-dialin.net [217.227.188.4]) by oxygen.pond.sub.org (Postfix) with ESMTPA id D1374276D75 for ; Wed, 20 Jan 2010 17:08:22 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id 36BB7F0; Wed, 20 Jan 2010 17:08:22 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 20 Jan 2010 17:08:16 +0100 Message-Id: <1264003702-17329-3-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.6.6 In-Reply-To: <1264003702-17329-1-git-send-email-armbru@redhat.com> References: <1264003702-17329-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [Qemu-devel] [PATCH v2 2/8] QDict: New qdict_get_double() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Helper function just like qdict_get_int(), just for QFloat/double. Signed-off-by: Markus Armbruster --- 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);