]> git.proxmox.com Git - qemu.git/blobdiff - qdict.c
Update version and changelog for release
[qemu.git] / qdict.c
diff --git a/qdict.c b/qdict.c
index 0e04cb1feded31435acbaf17bd5fcd419f3eff2d..ba8eef09b7ecfdaad2aca3f0a7c4529ac64f21f4 100644 (file)
--- a/qdict.c
+++ b/qdict.c
@@ -12,6 +12,7 @@
 
 #include "qint.h"
 #include "qdict.h"
+#include "qbool.h"
 #include "qstring.h"
 #include "qobject.h"
 #include "qemu-queue.h"
@@ -121,9 +122,8 @@ void qdict_put_obj(QDict *qdict, const char *key, QObject *value)
         /* allocate a new entry */
         entry = alloc_entry(key, value);
         QLIST_INSERT_HEAD(&qdict->table[hash], entry, next);
+        qdict->size++;
     }
-
-    qdict->size++;
 }
 
 /**
@@ -188,6 +188,33 @@ int64_t qdict_get_int(const QDict *qdict, const char *key)
     return qint_get_int(qobject_to_qint(obj));
 }
 
+/**
+ * qdict_get_bool(): Get a bool mapped by 'key'
+ *
+ * This function assumes that 'key' exists and it stores a
+ * QBool object.
+ *
+ * Return bool mapped by 'key'.
+ */
+int qdict_get_bool(const QDict *qdict, const char *key)
+{
+    QObject *obj = qdict_get_obj(qdict, key, QTYPE_QBOOL);
+    return qbool_get_int(qobject_to_qbool(obj));
+}
+
+/**
+ * qdict_get_qlist(): Get the QList mapped by 'key'
+ *
+ * This function assumes that 'key' exists and it stores a
+ * QList object.
+ *
+ * Return QList mapped by 'key'.
+ */
+QList *qdict_get_qlist(const QDict *qdict, const char *key)
+{
+    return qobject_to_qlist(qdict_get_obj(qdict, key, QTYPE_QLIST));
+}
+
 /**
  * qdict_get_str(): Get a pointer to the stored string mapped
  * by 'key'