diff options
Diffstat (limited to 'src/util/str.h')
| -rw-r--r-- | src/util/str.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/util/str.h b/src/util/str.h new file mode 100644 index 0000000..4a0de1a --- /dev/null +++ b/src/util/str.h @@ -0,0 +1,24 @@ +#ifndef ANIMTOOL_STR_H_ +#define ANIMTOOL_STR_H_ + +#include "container.h" + +typedef arraybuf(char) strbuf; +typedef array(char) str; + +#define S(x) ((str) { sizeof (x) - 1, (x) }) +#define PSTR(x) (int) (x).len, (x).ptr + +#define NULTERM(S, BUF) char BUF[(S).len+1]; memcpy(BUF, (S).ptr, (S).len); BUF[(S).len] = '\0'; + +size_t str_find(str s, str tokens); +str str_walk(str *s, str sep); +str str_eat(str s, str tokens); +str str_advance(str s, size_t x); +bool str_start(str s, str start); +str str_intro(char *s); +bool str_parse_int(str s, long *x); +bool str_parse_double(str s, double *x); +bool str_split(str s, str sep, str *a, str *b); + +#endif |
