aboutsummaryrefslogtreecommitdiffstats
path: root/qlist.h
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2010-05-10 18:48:35 -0700
committerDavid 'Digit' Turner <digit@android.com>2010-05-11 17:10:19 -0700
commit2910f183ddd5286911bc1e3499ea93cb57de8b75 (patch)
tree43cfd4b9a6697496732722ff7f2fb66d5782597c /qlist.h
parent0119362f0d74ca74f3ea743f6e0e527a9edcc474 (diff)
downloadexternal_qemu-2910f183ddd5286911bc1e3499ea93cb57de8b75.zip
external_qemu-2910f183ddd5286911bc1e3499ea93cb57de8b75.tar.gz
external_qemu-2910f183ddd5286911bc1e3499ea93cb57de8b75.tar.bz2
Upstream: Misc integration - includes qobject.h and related sources
Change-Id: Idfa93ab5c67c95a3bc1869eeaf3a84a75fe24cd6
Diffstat (limited to 'qlist.h')
-rw-r--r--qlist.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/qlist.h b/qlist.h
new file mode 100644
index 0000000..a3261e1
--- /dev/null
+++ b/qlist.h
@@ -0,0 +1,52 @@
+/*
+ * QList data type header.
+ *
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * Authors:
+ * Luiz Capitulino <lcapitulino@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2. See
+ * the COPYING file in the top-level directory.
+ */
+#ifndef QLIST_H
+#define QLIST_H
+
+#include "qobject.h"
+#include "qemu-queue.h"
+#include "qemu-common.h"
+
+typedef struct QListEntry {
+ QObject *value;
+ QTAILQ_ENTRY(QListEntry) next;
+} QListEntry;
+
+typedef struct QList {
+ QObject_HEAD;
+ QTAILQ_HEAD(,QListEntry) head;
+} QList;
+
+#define qlist_append(qlist, obj) \
+ qlist_append_obj(qlist, QOBJECT(obj))
+
+#define QLIST_FOREACH_ENTRY(qlist, var) \
+ for ((var) = ((qlist)->head.tqh_first); \
+ (var); \
+ (var) = ((var)->next.tqe_next))
+
+static inline QObject *qlist_entry_obj(const QListEntry *entry)
+{
+ return entry->value;
+}
+
+QList *qlist_new(void);
+QList *qlist_copy(QList *src);
+void qlist_append_obj(QList *qlist, QObject *obj);
+void qlist_iter(const QList *qlist,
+ void (*iter)(QObject *obj, void *opaque), void *opaque);
+QObject *qlist_pop(QList *qlist);
+QObject *qlist_peek(QList *qlist);
+int qlist_empty(const QList *qlist);
+QList *qobject_to_qlist(const QObject *obj);
+
+#endif /* QLIST_H */