#ifndef SV_INCLUDED #define SV_INCLUDED #include # // macros #define SV(s) sv_str(s) #define SV_NULL sv_strn(NULL, 0) // printf macros #define SV_FMT "%.*s" #define SV_ARG(sv) (int) (sv).len, (sv).buf struct String_View{ size_t len; // String lenght const char *buf; // String data }; typedef struct String_View SV; SV sv_str(const char *s); SV sv_strn(const char *s, size_t len); SV sv_trim(SV s); SV sv_trim_left(SV s); SV sv_trim_right(SV s); int sv_cmp(const SV s1, const SV s2); int sv_casecmp(const SV s1, const SV s2); SV before_delim(const SV s, char *delims); SV after_delim(const SV s, char *delims); SV sv_strstr(const SV haystack, const SV needle); #endif