[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [PATCH 04/29] Introduce QDict
From: |
Avi Kivity |
Subject: |
[Qemu-devel] Re: [PATCH 04/29] Introduce QDict |
Date: |
Thu, 20 Aug 2009 10:57:54 +0300 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3 |
On 08/20/2009 02:07 AM, Luiz Capitulino wrote:
QDict is a high-level dictionary data type that can be used to store a
collection of QObjects. A unique key is associated with only one
QObject.
The following functions are available:
- qdict_new() Create a new dictionary
- qdict_add() Add a new 'key:object' pair
qdict_put() is both symmetrical with qdict_get(), and also conveys the
fact that you can replace an existing key/value.
+
+/**
+ * qdict_add_qint(): Add a new QInt into the dictionary
+ *
+ * Add the pair 'key:qint' into qdict. Does nothing if 'key' already
+ * exist.
+ *
+ * NOTE: this function 'steals' a reference to 'qi'
+ */
+void qdict_add_qint(QDict *qdict, const char *key, QInt *qi)
+{
+ qdict_add(qdict, key, QOBJECT(qi));
+}
I think these wrappers are superfluous, they don't really add much value.
+
+/**
+ * qdict_get_int(): Get an int value mapped by 'key'
+ *
+ * This function assumes that 'key' exists and it stores a
+ * QInt object.
+ */
+int qdict_get_int(const QDict *qdict, const char *key)
+{
+ QObject *obj = qdict_get_obj(qdict, key, QTYPE_QINT);
+ return qint_to_int(qobject_to_qint(obj));
+}
This assumption does not hold if the dict came from a user.
--
error compiling committee.c: too many arguments to function
- [Qemu-devel] Re: [PATCH 02/29] Introduce QInt, (continued)
[Qemu-devel] Re: [PATCH 02/29] Introduce QInt, Paolo Bonzini, 2009/08/20
[Qemu-devel] [PATCH 03/29] Introduce QString, Luiz Capitulino, 2009/08/19
[Qemu-devel] [PATCH 04/29] Introduce QDict, Luiz Capitulino, 2009/08/19
- [Qemu-devel] Re: [PATCH 04/29] Introduce QDict,
Avi Kivity <=
[Qemu-devel] Re: [PATCH 04/29] Introduce QDict, Paolo Bonzini, 2009/08/20
Re: [Qemu-devel] [PATCH 04/29] Introduce QDict, Markus Armbruster, 2009/08/24
[Qemu-devel] [PATCH 05/29] Add wrappers to functions used by the Monitor, Luiz Capitulino, 2009/08/19