bglibs: striter.h Source File

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);
30 int striter_valid(striter*);
31 int striter_advance(striter*);
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
striter::start
unsigned start
Definition: striter.h:20
str::s
char * s
Definition: str.h:36
striter::len
unsigned len
Definition: striter.h:24
striter_valid
int striter_valid(striter *)
Definition: iter_valid.c:5
striter
Definition: striter.h:15
striter::str
const struct str * str
Definition: striter.h:18
striter::sep
char sep
Definition: striter.h:26
str
Definition: str.h:30
striter::startptr
const char * startptr
Definition: striter.h:22
striter_advance
int striter_advance(striter *)
Definition: iter_advance.c:5
striter_start
void striter_start(striter *iter, const struct str *s, char sep)
Definition: iter_start.c:5