00001 00012 #ifndef NXS_HEADERS_LOOP 00013 #define NXS_HEADERS_LOOP 00014 00015 #ifdef HAVE_CONFIG_H 00016 #include "config.h" 00017 #endif 00018 00019 #include <stdbool.h> 00020 #include <stddef.h> 00021 00028 #define nxs_do_onbreak(_cond, _expr) \ 00029 nxs_for_onbreak(bool _nxs_b = true, _nxs_b, _nxs_b = (_cond), _expr) 00030 00054 #define nxs_for_eachbreak(_init, _cond, _each) \ 00055 nxs_for_onbreak(_init, _cond, _each, _each) 00056 00079 #define nxs_for_onbreak(_init, _cond, _each, _expr) \ 00080 for (bool _nxs_brokeOut = true, _nxs_cond = true;_nxs_cond; \ 00081 _nxs_cond = false, _nxs_brokeOut && ((_expr), 1)) \ 00082 for (_init;_nxs_cond = (_cond);_nxs_brokeOut = false, (_each)) 00083 00098 #define nxs_foreach_array(_var, _array) \ 00099 for (size_t _nxs_i = 0;_nxs_i < sizeof(_array) / sizeof(*_array); \ 00100 ++_nxs_i) \ 00101 for (bool _nxs_b = true;_nxs_b;) \ 00102 for (_var = (_array)[_nxs_i];_nxs_b;_nxs_b = false) 00103 00118 #define nxs_forreach_array(_var, _array) \ 00119 for (size_t _nxs_i = sizeof(_array) / sizeof(*_array) - 1, \ 00120 _nxs_j = 1;_nxs_j;_nxs_i = (_nxs_i > 0 ? (_nxs_i - 1) : 0)) \ 00121 for (bool _nxs_ba = true;_nxs_ba;_nxs_j = _nxs_i, \ 00122 _nxs_ba = false) \ 00123 for (bool _nxs_bb = true;_nxs_bb;) \ 00124 for (_var = (_array)[_nxs_i];_nxs_bb;_nxs_bb = false) 00125 00132 #define nxs_while_onbreak(_cond, _expr) \ 00133 nxs_for_onbreak(, _cond, , _expr) 00134 00136 #endif