bglibs
striter.h
1 #ifndef STR_ITER__H__
2 #define STR_ITER__H__
3 
4 struct str;
5 
15 typedef struct
16 {
18  const struct str* str;
20  unsigned start;
22  const char* startptr;
24  unsigned len;
26  char sep;
27 } striter;
28 
29 void striter_start(striter* iter, const struct str* s, char sep);
32 
34 #define str_copyiter(STR,ITER) str_copyb(STR,(ITER)->startptr,(ITER)->len)
35 
37 #define str_catiter(STR,ITER) str_catb(STR,(ITER)->startptr,(ITER)->len)
38 
40 #define obuf_putiter(OBUF,ITER) obuf_write(OBUF,(ITER)->startptr,(ITER)->len)
41 
43 #define striter_loop(ITER,STR,SEP) for(striter_start(ITER,STR,SEP);striter_valid(ITER);striter_advance(ITER))
44 
47 #endif
unsigned start
Definition: striter.h:20
char * s
Definition: str.h:36
unsigned len
Definition: striter.h:24
int striter_valid(striter *)
Definition: iter_valid.c:5
Definition: striter.h:15
const struct str * str
Definition: striter.h:18
char sep
Definition: striter.h:26
Definition: str.h:30
const char * startptr
Definition: striter.h:22
int striter_advance(striter *)
Definition: iter_advance.c:5
void striter_start(striter *iter, const struct str *s, char sep)
Definition: iter_start.c:5