summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-09-11 15:51:51 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-09-11 15:51:51 +0000
commit4074c22a1304d262c99d16bb4b674e8ec2aef18a (patch)
tree217187ef48db0fb9121f82bbe1be0cc4db927600
parent54ede0b9816b34ffcf5e93f8283ecb61d50356dd (diff)
downloadlasso-4074c22a1304d262c99d16bb4b674e8ec2aef18a.tar.gz
lasso-4074c22a1304d262c99d16bb4b674e8ec2aef18a.tar.xz
lasso-4074c22a1304d262c99d16bb4b674e8ec2aef18a.zip
Core: add new macros to traverse lists
* lasso/utils.h: lasso_foreach_full_begin(_type, _data, _iter, _list) traverse GList* _list, using _iter as iteration variable extract data field to variable _data of type _type.
-rw-r--r--lasso/utils.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/lasso/utils.h b/lasso/utils.h
index 1c765ed9..269a9f87 100644
--- a/lasso/utils.h
+++ b/lasso/utils.h
@@ -418,6 +418,26 @@
#define lasso_foreach(_iter, _list) \
for (_iter = (_list); _iter; _iter = g_list_next(_iter))
+/**
+ * lasso_foreach_full_begin:
+ * @_type: the type of the variable @_data
+ * @_data: the name of the variable to define to store data values
+ * @_iter: the name of the variable to define to store the iterator
+ * @_list: the GList* to iterate
+ *
+ * Traverse a GList* @_list, using @_iter as iteration variable extract data field to variable
+ * @_data of type @_type.
+ */
+#define lasso_foreach_full_begin(_type, _data, _iter, _list) \
+ { \
+ _type _data = NULL; \
+ GList *_iter = NULL; \
+ for (_iter = (_list); _iter && ((_data = _iter->data), 1); _iter = g_list_next(_iter)) \
+ {
+
+#define lasso_foreach_full_end() \
+ } }
+
/* Declare type of element in a container */
#ifndef OFTYPE
#define OFTYPE(x)