]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/iter.qh
Merge branch 'terencehill/menu_languages' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / iter.qh
index 53b3d662992f23668fc77be6e45a4cb91a0422d2..f3214a24865afe3af5ca5c3554777be9dacb122b 100644 (file)
@@ -1,19 +1,40 @@
 #ifndef ITER_H
 #define ITER_H
 
-#define FOREACH_ARRAY(arr, start, end, cond, body) do { \
-    for (int i = start; i < end; ++i) {                 \
-        const noref entity it = arr[i];                 \
-        if (cond) { body }                              \
-    }                                                   \
-} while(0)
+#define FOREACH_ARRAY(arr, start, end, cond, body) \
+       do \
+       { \
+               for (int i = start; i < end; ++i) \
+               { \
+                       const noref entity it = arr[i]; \
+                       if (cond) { body } \
+               } \
+       } \
+       while (0)
 
-#define FOREACH_LIST(list, next, cond, body) do {               \
-    noref int i = 0;                                            \
-    for (entity it = list##_first; it; (it = it.next, ++i)) {   \
-        if (cond) { body }                                      \
-    }                                                           \
-} while(0)
+#define FOREACH_LIST(list, next, cond, body) \
+       do \
+       { \
+               int i = 0; \
+               for (entity it = list##_first; it; (it = it.next, ++i)) \
+               { \
+                       if (cond) { body } \
+               } \
+       } \
+       while (0)
+
+#define FOREACH_WORD(words, cond, body) \
+       do \
+       { \
+               string _words = words; \
+               int i = 0; \
+               for (string _it; (_it = car(_words)); (_words = cdr(_words), ++i)) \
+               { \
+                       const noref string it = _it; \
+                       if (cond) { body } \
+               } \
+       } \
+       while (0)
 
 #define FOREACH(list, cond, body) FOREACH_LIST(list, enemy, cond, body)