]> git.proxmox.com Git - qemu.git/commitdiff
QDict: Introduce functions to retrieve QDictEntry values
authorLuiz Capitulino <lcapitulino@redhat.com>
Mon, 7 Jun 2010 19:53:51 +0000 (16:53 -0300)
committerLuiz Capitulino <lcapitulino@redhat.com>
Thu, 1 Jul 2010 17:27:13 +0000 (14:27 -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 <lcapitulino@redhat.com>
qdict.c
qdict.h

diff --git a/qdict.c b/qdict.c
index 71be2ebcd84177bf04a17426d2681f7fb30c49b2..c4677636e3f3b001d4ba928f58823e9bfd84aebf 100644 (file)
--- a/qdict.c
+++ b/qdict.c
@@ -82,6 +82,27 @@ static QDictEntry *alloc_entry(const char *key, QObject *value)
     return entry;
 }
 
+/**
+ * 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
  */
diff --git a/qdict.h b/qdict.h
index dcd2b29780a5f6b7b91aa6392d5ad41b760ae7cd..0c8de3c9c26a2e0f9e5095a76973f0a6ccdca884 100644 (file)
--- 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);