diff options
Diffstat (limited to 'cstring')
-rw-r--r-- | cstring/include/cstring.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cstring/include/cstring.h b/cstring/include/cstring.h index 644f1e1..ae650eb 100644 --- a/cstring/include/cstring.h +++ b/cstring/include/cstring.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <assert.h> | 4 | #include <assert.h> |
5 | #include <bsd/string.h> | 5 | #include <bsd/string.h> |
6 | #include <stdbool.h> | ||
6 | 7 | ||
7 | /// A fixed-size string. | 8 | /// A fixed-size string. |
8 | /// The string is null-terminated so that it can be used with the usual C APIs. | 9 | /// The string is null-terminated so that it can be used with the usual C APIs. |
@@ -56,6 +57,17 @@ | |||
56 | \ | 57 | \ |
57 | static inline STRING STRING##_concat_path(STRING a, STRING b) { \ | 58 | static inline STRING STRING##_concat_path(STRING a, STRING b) { \ |
58 | return STRING##_concat(STRING##_concat(a, STRING##_make("/")), b); \ | 59 | return STRING##_concat(STRING##_concat(a, STRING##_make("/")), b); \ |
60 | } \ | ||
61 | \ | ||
62 | static inline bool STRING##_eq(STRING a, STRING b) { \ | ||
63 | if (a.length != b.length) { \ | ||
64 | return false; \ | ||
65 | } \ | ||
66 | return strncmp(a.str, b.str, a.length) == 0; \ | ||
67 | } \ | ||
68 | \ | ||
69 | static inline bool STRING##_eq_cstr(STRING a, const char* b) { \ | ||
70 | return strncmp(a.str, b, a.length) == 0; \ | ||
59 | } | 71 | } |
60 | 72 | ||
61 | DEF_STRING(sstring, 32) // Small. | 73 | DEF_STRING(sstring, 32) // Small. |