From e549e76806a300bc49a7a5248d5fc32447699c25 Mon Sep 17 00:00:00 2001 From: Al Date: Sat, 25 Jul 2015 13:49:02 -0400 Subject: [PATCH] [utils] string_tree_iterator_foreach_token --- src/string_utils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/string_utils.h b/src/string_utils.h index a3b24427..bfe1f600 100644 --- a/src/string_utils.h +++ b/src/string_utils.h @@ -228,6 +228,16 @@ char *string_tree_iterator_get_string(string_tree_iterator_t *self, uint32_t i); bool string_tree_iterator_done(string_tree_iterator_t *self); void string_tree_iterator_destroy(string_tree_iterator_t *self); + +#define string_tree_iterator_foreach_token(iter, s, code) { \ + string_tree_t *tree = iter->tree; \ + for (int __pi = 0; __pi < iter->num_tokens; __pi++) { \ + (s) = string_tree_get_alternative(tree, __pi, iter->path[__pi]); \ + code; \ + } \ +} + + #ifdef __cplusplus } #endif