stringview

This commit is contained in:
2026-11-14 20:11:26 -03:00
parent 04be717bc7
commit d8903b05de
4 changed files with 182 additions and 33 deletions
+17 -3
View File
@@ -1,14 +1,28 @@
#ifndef STRING_VIEW_H
#define STRING_VIEW_H
#include <stdbool.h>
#include <stddef.h>
typedef struct StringView {
char *text;
size_t lenght;
size_t length;
} StringView;
#define SV_NULL (StringView){.text = NULL, .length = 0}
StringView sv_from_cstr(const char *);
StringView sv_left(const StringView *sv, size_t l);
StringView sv_right(const StringView *sv, size_t l);
void sv_left(StringView *sv, size_t l);
void sv_right(StringView *sv, size_t l);
void sv_ltrim(StringView *sv);
void sv_rtrim(StringView *sv);
void sv_trim(StringView *sv);
int sv_index_of(StringView sv, char c);
StringView sv_chop_by_delim(StringView *sv, char delim);
bool sv_equals(StringView *sv1, StringView *sv2);
bool sv_starts_with(StringView *sv, StringView *prefix);
bool sv_ends_with(StringView *sv, StringView *suffix);
#endif