12#ifndef LIBCLOD_STRING_H
13#define LIBCLOD_STRING_H
40#define CLOD_STRING_NULL ((struct clod_string){0})
43#define CLOD_STRING_C(cstr) ((struct clod_string){ .ptr = (char*)(cstr), .len = sizeof((char[]){cstr}) - 1, .cap = 0 })
46#define CLOD_STRING_NEW(size) ((struct clod_string){ .ptr = (char[size]){0}, .len = 0, .cap = (size) })
49#define CLOD_STRING_OBJECT(object) ((struct clod_string){ .ptr = (char*)(object), .len = sizeof(*(object)), .cap = sizeof(*(object)) })
63CLOD_API CLOD_NONNULL(1)
73CLOD_API CLOD_NONNULL(1)
92CLOD_API CLOD_NONNULL(1)
96CLOD_API CLOD_NONNULL(1)
208#define CLOD_STRING_DIGIT_ALPHABET CLOD_STRING_C("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_")
209#define CLOD_STRING_DIGIT_ALPHABET_CAPS CLOD_STRING_C("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_")
217 struct clod_string alphabet,
unsigned char base,
unsigned char min_digits,
unsigned char max_digits);
231 struct clod_string alphabet,
unsigned char base,
unsigned char min_digits,
unsigned char max_digits);
245 struct clod_string alphabet,
unsigned char base,
unsigned char min_digits,
unsigned char max_digits);
CLOD_API bool clod_string_remove_prefix(struct clod_string *str, struct clod_string prefix)
size_t clod_string_cat(struct clod_string *dst, struct clod_string src)
CLOD_API size_t clod_string_put_int(struct clod_string *dst, intmax_t val, struct clod_string alphabet, unsigned char base, unsigned char min_digits, unsigned char max_digits)
CLOD_API size_t clod_string_put_uint(struct clod_string *dst, uintmax_t val, struct clod_string alphabet, unsigned char base, unsigned char min_digits, unsigned char max_digits)
CLOD_API struct clod_string clod_string_find(struct clod_string str, char elem, int occurrence)
CLOD_API struct clod_string clod_string_contains(struct clod_string str, struct clod_string elem)
CLOD_API size_t clod_string_put_double(struct clod_string *dst, double val, struct clod_string alphabet, unsigned char base, unsigned char min_digits, unsigned char max_digits)
struct clod_string clod_string_from_cstr(const char *cstr)
Make a string from a C string.
char clod_string_get_char(struct clod_string *str)
Remove a single char from the start of the string.
CLOD_API double clod_string_get_double(struct clod_string *str, struct clod_string alphabet, unsigned char base)
CLOD_API uintmax_t clod_string_get_uint(struct clod_string *str, struct clod_string alphabet, unsigned char base)
int clod_string_cmp(struct clod_string str1, struct clod_string str2)
CLOD_API int clod_string_parse(struct clod_string src, struct clod_string fmt,...)
char clod_string_peek_char(struct clod_string str)
Get the first char in the string.
CLOD_API int clod_string_vparse(struct clod_string src, struct clod_string fmt, va_list args)
Same as clod_string_parse but takes a va-list argument instead of '...'.
void clod_string_put_char(struct clod_string *str, char c)
Append a single char to the end of the string.
CLOD_API intmax_t clod_string_get_int(struct clod_string *str, struct clod_string alphabet, unsigned char base)
size_t clod_string_insert(struct clod_string *dst, struct clod_string src)