summaryrefslogtreecommitdiff
path: root/src/util/str.h
blob: 4a0de1ada0dc354413eef7695ccaba08883d0a31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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