[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/13] QDict: Introduce functions to retrieve QDictE
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 03/13] QDict: Introduce functions to retrieve QDictEntry values |
Date: |
Tue, 22 Jun 2010 14:40:41 -0300 |
Next commit will introduce a new QDict iteration API which
returns QDictEntry entries, but we don't want users to directly
access its members since QDictEntry should be private to QDict.
In the near future this kind of data type will be turned into a
forward reference.
Signed-off-by: Luiz Capitulino <address@hidden>
---
qdict.c | 21 +++++++++++++++++++++
qdict.h | 2 ++
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/qdict.c b/qdict.c
index 71be2eb..c467763 100644
--- a/qdict.c
+++ b/qdict.c
@@ -83,6 +83,27 @@ static QDictEntry *alloc_entry(const char *key, QObject
*value)
}
/**
+ * qdict_entry_value(): Return qdict entry value
+ *
+ * Return weak reference.
+ */
+QObject *qdict_entry_value(const QDictEntry *entry)
+{
+ return entry->value;
+}
+
+/**
+ * qdict_entry_key(): Return qdict entry key
+ *
+ * Return a *pointer* to the string, it has to be duplicated before being
+ * stored.
+ */
+const char *qdict_entry_key(const QDictEntry *entry)
+{
+ return entry->key;
+}
+
+/**
* qdict_find(): List lookup function
*/
static QDictEntry *qdict_find(const QDict *qdict,
diff --git a/qdict.h b/qdict.h
index dcd2b29..0c8de3c 100644
--- a/qdict.h
+++ b/qdict.h
@@ -34,6 +34,8 @@ typedef struct QDict {
/* Object API */
QDict *qdict_new(void);
+const char *qdict_entry_key(const QDictEntry *entry);
+QObject *qdict_entry_value(const QDictEntry *entry);
size_t qdict_size(const QDict *qdict);
void qdict_put_obj(QDict *qdict, const char *key, QObject *value);
void qdict_del(QDict *qdict, const char *key);
--
1.7.1.359.gd0b8d
- [Qemu-devel] [PATCH v2 00/13]: QMP: Replace client argument checker, Luiz Capitulino, 2010/06/22
- [Qemu-devel] [PATCH 01/13] QDict: Rename 'err_value', Luiz Capitulino, 2010/06/22
- [Qemu-devel] [PATCH 03/13] QDict: Introduce functions to retrieve QDictEntry values,
Luiz Capitulino <=
- [Qemu-devel] [PATCH 02/13] QDict: Small terminology change, Luiz Capitulino, 2010/06/22
- [Qemu-devel] [PATCH 05/13] check-qdict: Introduce test for the new iteration API, Luiz Capitulino, 2010/06/22
- [Qemu-devel] [PATCH 04/13] QDict: Introduce new iteration API, Luiz Capitulino, 2010/06/22
- [Qemu-devel] [PATCH 11/13] QError: Introduce QERR_QMP_UNEXPECTED_INPUT_OBJECT_MEMBER, Luiz Capitulino, 2010/06/22
- [Qemu-devel] [PATCH 10/13] QMP: Drop old client argument checker, Luiz Capitulino, 2010/06/22
- [Qemu-devel] [PATCH 08/13] QMP: New argument checker (first part), Luiz Capitulino, 2010/06/22
- [Qemu-devel] [PATCH 07/13] Monitor: handle optional '-' arg as a bool, Luiz Capitulino, 2010/06/22