blob: ae6098c4f686e87fbae1d76ed3d18c32296f1f9f (
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
25
26
27
|
#ifndef PKGIT_STRING_H
#define PKGIT_STRING_H
#include <stddef.h>
typedef struct {
char* data;
size_t len;
} str_s;
typedef struct {
char* data;
size_t cap;
size_t len;
} str;
#define format_string(s) (int)((s).len), (s).data
// Usage: printf("%.*s", format_string(ss));
void print_slice(str_s s);
str_s slice_from_cstr(char* cstr);
int slice_eq(str_s a, str_s b);
int slice_starts_with(str_s slice, str_s prefix);
str_s slice_take(str_s slice, size_t n);
str_s slice_drop(str_s slice, size_t n);
str_s slice_trim(str_s slice);
#endif
|