summaryrefslogtreecommitdiff
path: root/src/util/str.h
diff options
context:
space:
mode:
authorLizzy Fleckenstein <lizzy@vlhl.dev>2026-04-12 20:57:06 +0200
committerLizzy Fleckenstein <lizzy@vlhl.dev>2026-04-12 20:59:39 +0200
commite5af28536bfb0f4c9131df56d2009ba5196f5e3a (patch)
tree3ab928f961a1ccd8440b070d7b57f79146457e8c /src/util/str.h
downloadanimtool-e5af28536bfb0f4c9131df56d2009ba5196f5e3a.tar.xz
init
Diffstat (limited to 'src/util/str.h')
-rw-r--r--src/util/str.h24
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