diff options
Diffstat (limited to 'src/string_view.h')
-rwxr-xr-x | src/string_view.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/string_view.h b/src/string_view.h new file mode 100755 index 0000000..4dbbaaf --- /dev/null +++ b/src/string_view.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef BDL_STRINGVIEW_H | ||
2 | #define BDL_STRINGVIEW_H | ||
3 | |||
4 | #include "common.h" | ||
5 | |||
6 | typedef struct StringView { | ||
7 | char *start; | ||
8 | size_t n; | ||
9 | } StringView; | ||
10 | |||
11 | // Consume a character in the stream. | ||
12 | char sv_next(StringView *sv); | ||
13 | |||
14 | // Check what is the current character in the stream. | ||
15 | char sv_peek(const StringView *sv); | ||
16 | |||
17 | // Compare if the arguments are the same. | ||
18 | bool sv_equal(const StringView *a, const StringView *b); | ||
19 | |||
20 | // Write a character to the given output stream. | ||
21 | void sv_write(const StringView *sv); | ||
22 | |||
23 | #define STRING(STR) (StringView){(STR), sizeof(STR) - 1} | ||
24 | |||
25 | #endif // BDL_STRINGVIEW_H | ||