4 * Copyright (C) 2009 Red Hat Inc.
7 * Luiz Capitulino <lcapitulino@redhat.com>
9 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
10 * See the COPYING.LIB file in the top-level directory.
16 #include "qapi/qmp/qobject.h"
17 #include "qemu/queue.h"
19 typedef struct QListEntry
{
21 QTAILQ_ENTRY(QListEntry
) next
;
25 struct QObjectBase_ base
;
26 QTAILQ_HEAD(,QListEntry
) head
;
29 #define qlist_append(qlist, obj) \
30 qlist_append_obj(qlist, QOBJECT(obj))
32 void qlist_append_bool(QList
*qlist
, bool value
);
33 void qlist_append_int(QList
*qlist
, int64_t value
);
34 void qlist_append_null(QList
*qlist
);
35 void qlist_append_str(QList
*qlist
, const char *value
);
37 #define QLIST_FOREACH_ENTRY(qlist, var) \
38 for ((var) = ((qlist)->head.tqh_first); \
40 (var) = ((var)->next.tqe_next))
42 static inline QObject
*qlist_entry_obj(const QListEntry
*entry
)
47 QList
*qlist_new(void);
48 QList
*qlist_copy(QList
*src
);
49 void qlist_append_obj(QList
*qlist
, QObject
*obj
);
50 void qlist_iter(const QList
*qlist
,
51 void (*iter
)(QObject
*obj
, void *opaque
), void *opaque
);
52 QObject
*qlist_pop(QList
*qlist
);
53 QObject
*qlist_peek(QList
*qlist
);
54 int qlist_empty(const QList
*qlist
);
55 size_t qlist_size(const QList
*qlist
);
56 bool qlist_is_equal(const QObject
*x
, const QObject
*y
);
57 void qlist_destroy_obj(QObject
*obj
);
59 static inline const QListEntry
*qlist_first(const QList
*qlist
)
61 return QTAILQ_FIRST(&qlist
->head
);
64 static inline const QListEntry
*qlist_next(const QListEntry
*entry
)
66 return QTAILQ_NEXT(entry
, next
);