diff options
| author | 2026-11-08 05:13:29 +0000 | |
|---|---|---|
| committer | 2026-11-08 05:13:29 +0000 | |
| commit | 8bbefe95d25fa2981add4df35bdd9903c91a8e62 (patch) | |
| tree | f45cabee854e1ef7e4b4ce82d4ceced0a47ae2a5 /src/string-view.h | |
| download | lab-01-8bbefe95d25fa2981add4df35bdd9903c91a8e62.tar.gz | |
Diffstat (limited to 'src/string-view.h')
| -rw-r--r-- | src/string-view.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/string-view.h b/src/string-view.h new file mode 100644 index 0000000..c745d12 --- /dev/null +++ b/src/string-view.h | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | #ifndef INCLUDED_STRING_VIEW_H | ||
| 2 | #define INCLUDED_STRING_VIEW_H | ||
| 3 | |||
| 4 | #include <string.h> | ||
| 5 | |||
| 6 | struct string_view { | ||
| 7 | const char *beg; | ||
| 8 | const char *end; | ||
| 9 | }; | ||
| 10 | |||
| 11 | #define STRING_VIEW_LEN(SV) ((SV).end - (SV).beg) | ||
| 12 | #define STRING_VIEW_EQUALS(A, B) \ | ||
| 13 | (STRING_VIEW_LEN (A) == STRING_VIEW_LEN (B) && \ | ||
| 14 | !memcmp ((A).beg, (B).beg, STRING_VIEW_LEN (A))) | ||
| 15 | |||
| 16 | #endif // INCLUDED_STRING_VIEW_H | ||
