|
Cthulhu
0.2.10
Cthulhu compiler collection
|
String manipulation and processing. More...

Macros | |
| #define | STR_WHITESPACE " \t\r\v\n\f" |
| all whitespace charaters More... | |
Functions | |
| CT_STD_API size_t | str_vsprintf (STA_WRITES(len) char *str, size_t len, const char *fmt, va_list args) |
| format a string with printf-like syntax More... | |
| CT_STD_API size_t | str_sprintf (STA_WRITES(len) char *str, size_t len, STA_FORMAT_STRING const char *fmt,...) |
| format a string with printf-like syntax More... | |
| CT_NODISCARD | STA_PRINTF (2, 3) CT_STD_API text_t text_format(arena_t *arena |
| format a string More... | |
| CT_NODISCARD STA_FORMAT_STRING const char CT_NODISCARD CT_STD_API text_t | text_vformat (arena_t *arena, const char *fmt, va_list args) |
| format a string More... | |
| CT_NODISCARD STA_FORMAT_STRING const char CT_NODISCARD CT_STD_API char * | str_vformat (arena_t *arena, const char *fmt, va_list args) |
| format a string More... | |
| CT_NODISCARD CT_PUREFN CT_STD_API bool | str_startswith (const char *str, const char *prefix) |
| see if a string starts with a prefix More... | |
| CT_NODISCARD CT_PUREFN CT_STD_API bool | str_endswith (const char *str, const char *suffix) |
| check if a string ends with a substring More... | |
| CT_NODISCARD CT_PUREFN CT_STD_API bool | str_endswithn (STA_READS(len) const char *str, size_t len, const char *suffix) |
| check if a string ends with a substring More... | |
| CT_NODISCARD CT_STD_API char * | str_join (const char *sep, const vector_t *parts, arena_t *arena) |
| join strings More... | |
| CT_NODISCARD CT_STD_API char * | str_repeat (const char *str, size_t times, arena_t *arena) |
| repeat a string More... | |
| CT_NODISCARD CT_STD_API char * | str_normalize (const char *str, arena_t *arena) |
| turn a string into a C string literal More... | |
| CT_NODISCARD CT_STD_API char * | str_normalizen (text_view_t text, arena_t *arena) |
| turn a string with length into a C string literal More... | |
| CT_STD_API size_t | str_normalize_into (STA_WRITES(len) char *dst, size_t dstlen, STA_READS(srclen) const char *src, size_t srclen) |
| normalize a string into a buffer More... | |
| CT_NODISCARD CT_STD_API vector_t * | str_split (const char *str, const char *sep, arena_t *arena) |
| split a string into a vector by a separator More... | |
| CT_NODISCARD CT_STD_API const char * | str_common_prefix (const vector_t *args, arena_t *arena) |
| find the longest common prefix of a vector of paths More... | |
| CT_PUREFN CT_STD_API size_t | str_rfind (const char *str, const char *sub) |
| find the last instance of a substring in a string More... | |
| CT_PUREFN CT_STD_API size_t | str_find (const char *str, const char *sub) |
| find the first instance of a substring in a string More... | |
| CT_PUREFN CT_STD_API size_t | str_rfind_any (const char *str, const char *letters) |
| find the first instance of a set of characters in a string More... | |
| CT_NODISCARD CT_PUREFN CT_STD_API bool | char_is_any_of (char c, const char *chars) |
| check if a character is any of a set of characters More... | |
| CT_NODISCARD CT_PUREFN CT_STD_API bool | str_contains (const char *str, const char *search) |
| check if a string contains a substring More... | |
| CT_NODISCARD CT_STD_API char * | str_replace (const char *str, const char *search, const char *repl, arena_t *arena) |
| replace all instances of a substring in a string More... | |
| CT_STD_API void | str_replace_inplace (INOUT_NOTNULL text_t *text, const char *search, const char *repl) |
| replace all instances of a substring in a string in place More... | |
| CT_STD_API void | str_trim_back_inplace (INOUT_NOTNULL text_t *text, const char *chars) |
| trim chars from the back of a string in place More... | |
| CT_STD_API void | str_sort_inplace (STA_UPDATES(len) char *str, size_t len) |
| sort a strings contents in place More... | |
| CT_NODISCARD CT_STD_API char * | str_replace_many (const char *str, const map_t *repl, arena_t *arena) |
| replace all instances of a each substring in a string with provided replacement More... | |
| CT_NODISCARD CT_NOALIAS CT_STD_API char * | str_erase (STA_READS(len) char *str, size_t len, const char *letters) |
remove all instances of letters from str More... | |
| CT_NODISCARD CT_STD_API char * | str_basename (const char *path, arena_t *arena) |
| get the filename from a path More... | |
| CT_NODISCARD CT_STD_API char * | str_filename (const char *path, arena_t *arena) |
| get the filename from a path More... | |
| CT_NODISCARD CT_STD_API char * | str_noext (const char *path, arena_t *arena) |
| remove the last file extension from a path More... | |
| CT_NODISCARD CT_STD_API char * | str_ext (const char *path, arena_t *arena) |
| get the last file extension from a path More... | |
| CT_NODISCARD CT_STD_API char * | str_directory (const char *path, arena_t *arena) |
| get the directory segment of a path More... | |
| CT_NODISCARD CT_STD_API char * | str_upper (const char *str, arena_t *arena) |
| uppercase an ascii string More... | |
| CT_NODISCARD CT_STD_API char * | str_lower (const char *str, arena_t *arena) |
| lowercase an ascii string this allocates a new string in the provided arena More... | |
| CT_NODISCARD CT_CONSTFN CT_STD_API char | str_tolower (char c) |
| get the lowercase version of a character More... | |
| CT_NODISCARD CT_CONSTFN CT_STD_API char | str_toupper (char c) |
| get the uppercase version of a character More... | |
| CT_NODISCARD CT_STD_API bool | text_view_equal (text_view_t lhs, text_view_t rhs) |
| check if two strings are equal More... | |
Variables | |
| CT_NODISCARD STA_FORMAT_STRING const char * | fmt |
String manipulation and processing.
| CT_NODISCARD CT_PUREFN CT_STD_API bool char_is_any_of | ( | char | c, |
| const char * | chars | ||
| ) |
| CT_NODISCARD STA_PRINTF | ( | 2 | , |
| 3 | |||
| ) |
format a string
format a string with printf-like syntax into a text buffer. useful when you need the length of the formatted string.
| arena | the arena to allocate the formatted string in |
| fmt | the format string |
| ... | the arguments to format |
format a string with printf-like syntax
| arena | the arena to allocate the formatted string in |
| fmt | the format string |
| ... | the arguments to format |
| CT_NODISCARD CT_STD_API char* str_basename | ( | const char * | path, |
| arena_t * | arena | ||
| ) |
| CT_NODISCARD CT_STD_API const char* str_common_prefix | ( | const vector_t * | args, |
| arena_t * | arena | ||
| ) |
find the longest common prefix of a vector of paths
| args | the vector of paths to find the common prefix of |
| arena | the arena to allocate the common prefix in |
modified version of https://rosettacode.org/wiki/Longest_common_prefix#C
expects a list of file paths
| CT_NODISCARD CT_PUREFN CT_STD_API bool str_contains | ( | const char * | str, |
| const char * | search | ||
| ) |
| CT_NODISCARD CT_STD_API char* str_directory | ( | const char * | path, |
| arena_t * | arena | ||
| ) |
| CT_NODISCARD CT_PUREFN CT_STD_API bool str_endswith | ( | const char * | str, |
| const char * | suffix | ||
| ) |
| CT_NODISCARD CT_PUREFN CT_STD_API bool str_endswithn | ( | STA_READS(len) const char * | str, |
| size_t | len, | ||
| const char * | suffix | ||
| ) |
check if a string ends with a substring
equivalent to str_endswith but with a length parameter
| str | the string to search |
| len | the length of the string |
| suffix | the suffix to check for |
| CT_NODISCARD CT_NOALIAS CT_STD_API char* str_erase | ( | STA_READS(len) char * | str, |
| size_t | len, | ||
| const char * | letters | ||
| ) |
remove all instances of letters from str
| str | the string to erase letters from |
| len | the length of str |
| letters | the letters to erase |
str with all instances of letters removed | CT_NODISCARD CT_STD_API char* str_ext | ( | const char * | path, |
| arena_t * | arena | ||
| ) |
| CT_NODISCARD CT_STD_API char* str_filename | ( | const char * | path, |
| arena_t * | arena | ||
| ) |
| CT_PUREFN CT_STD_API size_t str_find | ( | const char * | str, |
| const char * | sub | ||
| ) |
| CT_NODISCARD CT_STD_API char* str_join | ( | const char * | sep, |
| const vector_t * | parts, | ||
| arena_t * | arena | ||
| ) |
| CT_NODISCARD CT_STD_API char* str_lower | ( | const char * | str, |
| arena_t * | arena | ||
| ) |
| CT_NODISCARD CT_STD_API char* str_noext | ( | const char * | path, |
| arena_t * | arena | ||
| ) |
| CT_NODISCARD CT_STD_API char* str_normalize | ( | const char * | str, |
| arena_t * | arena | ||
| ) |
| CT_STD_API size_t str_normalize_into | ( | STA_WRITES(len) char * | dst, |
| size_t | dstlen, | ||
| STA_READS(srclen) const char * | src, | ||
| size_t | srclen | ||
| ) |
normalize a string into a buffer
normalize a string into a buffer. if dst is NULL, the length of the normalized string is returned.
| dst | the buffer to write the normalized string into |
| dstlen | the length of the buffer |
| src | the string to normalize |
| srclen | the length of the string |
| CT_NODISCARD CT_STD_API char* str_normalizen | ( | text_view_t | text, |
| arena_t * | arena | ||
| ) |
| CT_NODISCARD CT_STD_API char* str_repeat | ( | const char * | str, |
| size_t | times, | ||
| arena_t * | arena | ||
| ) |
| CT_NODISCARD CT_STD_API char* str_replace | ( | const char * | str, |
| const char * | search, | ||
| const char * | repl, | ||
| arena_t * | arena | ||
| ) |
replace all instances of a substring in a string
| str | the string to replace elements in |
| search | the substring to replace |
| repl | the replacement substring |
| arena | the arena to allocate the new string in |
str with all instances of search replaced with repl | CT_STD_API void str_replace_inplace | ( | INOUT_NOTNULL text_t * | text, |
| const char * | search, | ||
| const char * | repl | ||
| ) |
replace all instances of a substring in a string in place
| text | the text to replace elements in |
| search | the substring to replace |
| repl | the replacement substring |
| CT_NODISCARD CT_STD_API char* str_replace_many | ( | const char * | str, |
| const map_t * | repl, | ||
| arena_t * | arena | ||
| ) |
replace all instances of a each substring in a string with provided replacement
| str | the string to replace elements in |
| repl | a map of substrings to replace and their replacements |
| arena | the arena to allocate the new string in |
str with all instances of substrings in repl replaced | CT_PUREFN CT_STD_API size_t str_rfind | ( | const char * | str, |
| const char * | sub | ||
| ) |
| CT_PUREFN CT_STD_API size_t str_rfind_any | ( | const char * | str, |
| const char * | letters | ||
| ) |
| CT_STD_API void str_sort_inplace | ( | STA_UPDATES(len) char * | str, |
| size_t | len | ||
| ) |
sort a strings contents in place
| str | the string to sort |
| len | the length of the string |
| CT_NODISCARD CT_STD_API vector_t* str_split | ( | const char * | str, |
| const char * | sep, | ||
| arena_t * | arena | ||
| ) |
split a string into a vector by a separator
| str | the string to split |
| sep | the separator to split by |
| arena | the arena to allocate the substrings in |
| CT_STD_API size_t str_sprintf | ( | STA_WRITES(len) char * | str, |
| size_t | len, | ||
| STA_FORMAT_STRING const char * | fmt, | ||
| ... | |||
| ) |
format a string with printf-like syntax
format a string with printf-like syntax into a text buffer.
str is a pointer to a buffer of at least len bytes fmt is a valid format string| str | the buffer to format into |
| len | the length of the buffer |
| fmt | the format string |
| ... | the arguments to format |
| CT_NODISCARD CT_PUREFN CT_STD_API bool str_startswith | ( | const char * | str, |
| const char * | prefix | ||
| ) |
| CT_NODISCARD CT_CONSTFN CT_STD_API char str_tolower | ( | char | c | ) |
| CT_NODISCARD CT_CONSTFN CT_STD_API char str_toupper | ( | char | c | ) |
| CT_STD_API void str_trim_back_inplace | ( | INOUT_NOTNULL text_t * | text, |
| const char * | chars | ||
| ) |
trim chars from the back of a string in place
| text | the text to trim |
| chars | the characters to trim |
| CT_NODISCARD CT_STD_API char* str_upper | ( | const char * | str, |
| arena_t * | arena | ||
| ) |
| CT_NODISCARD STA_FORMAT_STRING const char CT_NODISCARD CT_STD_API char* str_vformat | ( | arena_t * | arena, |
| const char * | fmt, | ||
| va_list | args | ||
| ) |
| CT_STD_API size_t str_vsprintf | ( | STA_WRITES(len) char * | str, |
| size_t | len, | ||
| const char * | fmt, | ||
| va_list | args | ||
| ) |
format a string with printf-like syntax
format a string with a va_list and printf-like syntax into a text buffer.
str is a pointer to a buffer of at least len bytes fmt is a valid format string| str | the buffer to format into |
| len | the length of the buffer |
| fmt | the format string |
| args | the arguments to format |
| CT_NODISCARD STA_FORMAT_STRING const char CT_NODISCARD CT_STD_API text_t text_vformat | ( | arena_t * | arena, |
| const char * | fmt, | ||
| va_list | args | ||
| ) |
format a string
format a string with a va_list and printf-like syntax into a text buffer. useful when you need the length of the formatted string.
| arena | the arena to allocate the formatted string in |
| fmt | the format string |
| args | the arguments to format |
| CT_NODISCARD CT_STD_API bool text_view_equal | ( | text_view_t | lhs, |
| text_view_t | rhs | ||
| ) |
| CT_NODISCARD STA_FORMAT_STRING const char * fmt |