2 * ion/ioncore/region-iter.h
4 * Copyright (c) Tuomo Valkonen 1999-2007.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
12 #ifndef ION_IONCORE_REGION_ITER_H
13 #define ION_IONCORE_REGION_ITER_H
15 #define REGION_FIRST_CHILD(PAR) (((WRegion*)(PAR))->children)
16 #define REGION_LAST_CHILD(PAR) \
17 (REGION_FIRST_CHILD(PAR)==NULL ? NULL \
18 : REGION_PREV_CHILD_WRAP(REGION_FIRST_CHILD(PAR), REGION_FIRST_CHILD(PAR)))
19 #define REGION_NEXT_CHILD(PAR, REG) (((WRegion*)(REG))->p_next)
20 #define REGION_PREV_CHILD(PAR, REG) ((((WRegion*)(REG))->p_prev->p_next) ? \
21 (((WRegion*)(REG))->p_prev) : NULL)
22 #define REGION_NEXT_CHILD_WRAP(PAR, REG) \
23 (((REG) && ((WRegion*)(REG))->p_next) \
24 ? ((WRegion*)(REG))->p_next : REGION_FIRST_CHILD(PAR))
25 #define REGION_PREV_CHILD_WRAP(PAR, REG) \
26 ((REG) ? ((WRegion*)(REG))->p_prev \
27 : REGION_FIRST_CHILD(PAR))
29 #define FOR_ALL_CHILDREN(PAR, REG) \
30 for((REG)=((WRegion*)(PAR))->children; (REG)!=NULL; (REG)=(REG)->p_next)
32 #define FOR_ALL_CHILDREN_W_NEXT(PAR, REG, NEXT) \
33 for((REG)=((WRegion*)(PAR))->children, (NEXT)=((REG)==NULL ? NULL : (REG)->p_next);\
35 (REG)=(NEXT), (NEXT)=((REG)==NULL ? NULL : (REG)->p_next))
37 #endif /* ION_IONCORE_REGION_ITER_H */