diff options
Diffstat (limited to 'include/slice.h')
-rw-r--r-- | include/slice.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/slice.h b/include/slice.h new file mode 100644 index 0000000..26f9fd7 --- /dev/null +++ b/include/slice.h @@ -0,0 +1,27 @@ +#ifndef CMONKEY_SLICE_H +#define CMONKEY_SLICE_H + +#include <sys/types.h> + +struct slice { + const char *str; + size_t start; + size_t end; +}; + +struct slice slice_new(const char *str, size_t start, size_t end); + +struct slice slice_fullstr(const char *str); + +void slice_set(struct slice *, const char *str, size_t start, size_t end); + +size_t slice_len(const struct slice *); + +/* Returns 0 if equal, 1 if a > b, -1 if a < b */ +int slice_cmp(const struct slice *restrict a, const struct slice *restrict b); + +void slice_cpy(struct slice *dst, const struct slice *src); + +char *slice_sprint(struct slice *, char *str); + +#endif |