]> git.proxmox.com Git - qemu.git/commitdiff
QDict: Introduce qdict_get_qdict()
authorLuiz Capitulino <lcapitulino@redhat.com>
Thu, 21 Jan 2010 21:15:39 +0000 (19:15 -0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 26 Jan 2010 21:42:01 +0000 (15:42 -0600)
A helper to retrieve a QDict from a QDict.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qdict.c
qdict.h

diff --git a/qdict.c b/qdict.c
index ba8eef09b7ecfdaad2aca3f0a7c4529ac64f21f4..c6a5a425e5ccaa56b4e331f24f945ab8a5a804d3 100644 (file)
--- a/qdict.c
+++ b/qdict.c
@@ -215,6 +215,19 @@ QList *qdict_get_qlist(const QDict *qdict, const char *key)
     return qobject_to_qlist(qdict_get_obj(qdict, key, QTYPE_QLIST));
 }
 
+/**
+ * qdict_get_qdict(): Get the QDict mapped by 'key'
+ *
+ * This function assumes that 'key' exists and it stores a
+ * QDict object.
+ *
+ * Return QDict mapped by 'key'.
+ */
+QDict *qdict_get_qdict(const QDict *qdict, const char *key)
+{
+    return qobject_to_qdict(qdict_get_obj(qdict, key, QTYPE_QDICT));
+}
+
 /**
  * qdict_get_str(): Get a pointer to the stored string mapped
  * by 'key'
diff --git a/qdict.h b/qdict.h
index 5fef1ea4ea278e662b22b4c3945a41ebf816b209..2eaf6d54d30a5914d8c3ea741c1ab99b0c2ab24a 100644 (file)
--- a/qdict.h
+++ b/qdict.h
@@ -40,6 +40,7 @@ void qdict_iter(const QDict *qdict,
 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);
+QDict *qdict_get_qdict(const QDict *qdict, const char *key);
 const char *qdict_get_str(const QDict *qdict, const char *key);
 int64_t qdict_get_try_int(const QDict *qdict, const char *key,
                           int64_t err_value);