Patchwork [2/5] QDict: Introduce qdict_get_qdict()

login
register
mail settings
Submitter Luiz Capitulino
Date Jan. 20, 2010, 4:39 p.m.
Message ID <1264005551-12989-3-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/43311/
State New
Headers show

Comments

Luiz Capitulino - Jan. 20, 2010, 4:39 p.m.
A helper to retrieve a QDict from a QDict.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 qdict.c |   13 +++++++++++++
 qdict.h |    1 +
 2 files changed, 14 insertions(+), 0 deletions(-)

Patch

diff --git a/qdict.c b/qdict.c
index ba8eef0..c6a5a42 100644
--- a/qdict.c
+++ b/qdict.c
@@ -216,6 +216,19 @@  QList *qdict_get_qlist(const QDict *qdict, const char *key)
 }
 
 /**
+ * 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 5fef1ea..2eaf6d5 100644
--- 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);