140#define CX_STR(literal) cxstring{literal, sizeof(literal) - 1}
151#define CX_STR(literal) (cxstring){literal, sizeof(literal) - 1}
338#define cx_strcat_a(alloc, count, ...) \
339cx_strcat_ma(alloc, cx_mutstrn(NULL, 0), count, __VA_ARGS__)
354#define cx_strcat(count, ...) \
355cx_strcat_ma(cxDefaultAllocator, cx_mutstrn(NULL, 0), count, __VA_ARGS__)
374#define cx_strcat_m(str, count, ...) \
375cx_strcat_ma(cxDefaultAllocator, str, count, __VA_ARGS__)
775#define cx_strdup(string) cx_strdup_a(cxDefaultAllocator, string)
790#define cx_strdup_ma(allocator, string) cx_strdup_a(allocator, cx_strcast(string))
804#define cx_strdup_m(string) cx_strdup_a(cxDefaultAllocator, cx_strcast(string))
952#define cx_strreplacen(str, pattern, replacement, replmax) \
953cx_strreplacen_a(cxDefaultAllocator, str, pattern, replacement, replmax)
972#define cx_strreplace_a(allocator, str, pattern, replacement) \
973cx_strreplacen_a(allocator, str, pattern, replacement, SIZE_MAX)
992#define cx_strreplace(str, pattern, replacement) \
993cx_strreplacen_a(cxDefaultAllocator, str, pattern, replacement, SIZE_MAX)
Interface for custom allocators.
Common definitions and feature checks.
#define __attribute__(x)
Removes GNU C attributes where they are not supported.
Definition: common.h:127
cxmutstr cx_strreplacen_a(CxAllocator const *allocator, cxstring str, cxstring pattern, cxstring replacement, size_t replmax)
Replaces a pattern in a string with another string.
cxmutstr cx_strcat_ma(CxAllocator const *alloc, cxmutstr str, size_t count,...)
Concatenates strings.
cxstring cx_str(char const *cstring)
Wraps a string that must be zero-terminated.
cxstring cx_strsubsl(cxstring string, size_t start, size_t length)
Returns a substring starting at the specified location.
void cx_strfree(cxmutstr *str)
Passes the pointer in this string to free().
cxmutstr cx_strsubsl_m(cxmutstr string, size_t start, size_t length)
Returns a substring starting at the specified location.
cxstring cx_strrchr(cxstring string, int chr)
Returns a substring starting at the location of the last occurrence of the specified character.
CxStrtokCtx cx_strtok_m(cxmutstr str, cxstring delim, size_t limit)
Creates a string tokenization context for a mutable string.
cxstring cx_strn(char const *cstring, size_t length)
Wraps a string that does not need to be zero-terminated.
bool cx_strtok_next(CxStrtokCtx *ctx, cxstring *token)
Returns the next token.
size_t cx_strsplit_a(CxAllocator const *allocator, cxstring string, cxstring delim, size_t limit, cxstring **output)
Splits a given string using a delimiter string.
CxStrtokCtx cx_strtok(cxstring str, cxstring delim, size_t limit)
Creates a string tokenization context.
cxstring cx_strcast(cxmutstr str)
Casts a mutable string to an immutable string.
size_t cx_strsplit(cxstring string, cxstring delim, size_t limit, cxstring *output)
Splits a given string using a delimiter string.
int cx_strcasecmp(cxstring s1, cxstring s2)
Compares two strings ignoring case.
cxmutstr cx_strchr_m(cxmutstr string, int chr)
Returns a substring starting at the location of the first occurrence of the specified character.
cxmutstr cx_strdup_a(CxAllocator const *allocator, cxstring string)
Creates a duplicate of the specified string.
cxmutstr cx_mutstr(char *cstring)
Wraps a mutable string that must be zero-terminated.
cxstring cx_strchr(cxstring string, int chr)
Returns a substring starting at the location of the first occurrence of the specified character.
size_t cx_strlen(size_t count,...)
Returns the accumulated length of all specified strings.
cxmutstr cx_strtrim_m(cxmutstr string)
Omits leading and trailing spaces.
int cx_strcasecmp_p(void const *s1, void const *s2)
Compares two strings ignoring case.
bool cx_strtok_next_m(CxStrtokCtx *ctx, cxmutstr *token)
Returns the next token of a mutable string.
void cx_strfree_a(CxAllocator const *alloc, cxmutstr *str)
Passes the pointer in this string to the allocators free function.
size_t cx_strsplit_ma(CxAllocator const *allocator, cxmutstr string, cxstring delim, size_t limit, cxmutstr **output)
Splits a given string using a delimiter string.
void cx_strlower(cxmutstr string)
Converts the string to lower case.
bool cx_strprefix(cxstring string, cxstring prefix)
Checks, if a string has a specific prefix.
bool cx_strcaseprefix(cxstring string, cxstring prefix)
Checks, if a string has a specific prefix, ignoring the case.
cxstring cx_strtrim(cxstring string)
Omits leading and trailing spaces.
cxstring cx_strstr(cxstring haystack, cxstring needle)
Returns a substring starting at the location of the first occurrence of the specified string.
void cx_strupper(cxmutstr string)
Converts the string to upper case.
cxstring cx_strsubs(cxstring string, size_t start)
Returns a substring starting at the specified location.
void cx_strtok_delim(CxStrtokCtx *ctx, cxstring const *delim, size_t count)
Defines an array of more delimiters for the specified tokenization context.
cxmutstr cx_strsubs_m(cxmutstr string, size_t start)
Returns a substring starting at the specified location.
cxmutstr cx_strrchr_m(cxmutstr string, int chr)
Returns a substring starting at the location of the last occurrence of the specified character.
size_t cx_strsplit_m(cxmutstr string, cxstring delim, size_t limit, cxmutstr *output)
Splits a given string using a delimiter string.
int cx_strcmp(cxstring s1, cxstring s2)
Compares two strings.
bool cx_strsuffix(cxstring string, cxstring suffix)
Checks, if a string has a specific suffix.
cxmutstr cx_strstr_m(cxmutstr haystack, cxstring needle)
Returns a substring starting at the location of the first occurrence of the specified string.
bool cx_strcasesuffix(cxstring string, cxstring suffix)
Checks, if a string has a specific suffix, ignoring the case.
cxmutstr cx_mutstrn(char *cstring, size_t length)
Wraps a string that does not need to be zero-terminated.
int cx_strcmp_p(void const *s1, void const *s2)
Compares two strings.
Structure holding the data for an allocator.
Definition: allocator.h:86
The UCX string structure.
Definition: string.h:46
char * ptr
A pointer to the string.
Definition: string.h:52
size_t length
The length of the string.
Definition: string.h:54
The UCX string structure for immutable (constant) strings.
Definition: string.h:65
size_t length
The length of the string.
Definition: string.h:73
char const * ptr
A pointer to the immutable string.
Definition: string.h:71
Context for string tokenizing.
Definition: string.h:84
cxstring const * delim_more
Optional array of more delimiters.
Definition: string.h:96
size_t delim_pos
Position of next delimiter in the source string.
Definition: string.h:112
cxstring str
The string to tokenize.
Definition: string.h:88
cxstring delim
The primary delimiter.
Definition: string.h:92
size_t delim_more_count
Length of the array containing more delimiters.
Definition: string.h:100
size_t pos
Position of the currently active token in the source string.
Definition: string.h:104
size_t next_pos
The position of the next token in the source string.
Definition: string.h:116
size_t found
The number of already found tokens.
Definition: string.h:120
size_t limit
The maximum number of tokens that shall be returned.
Definition: string.h:124