aboutsummaryrefslogtreecommitdiff
path: root/src/string-view.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/string-view.h')
-rw-r--r--src/string-view.h16
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
6struct 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