String utils. More...
Functions | |
VTM_API char * | vtm_str_copy (const char *in) |
VTM_API char * | vtm_str_ncopy (const char *in, size_t len) |
VTM_API int | vtm_str_casecmp (const char *s1, const char *s2) |
VTM_API vtm_list * | vtm_str_split (const char *in, const char *delim, unsigned int count) |
VTM_API int | vtm_str_split_ex (const char *in, const char *delim, char ***out_tokens, size_t *token_count) |
VTM_API char * | vtm_str_trim (char *in) |
VTM_API char * | vtm_str_printf (const char *fmt,...) |
VTM_API char * | vtm_str_vprintf (const char *fmt, va_list ap) |
VTM_API ssize_t | vtm_str_index_of (const char *in, char c, size_t len) |
VTM_API ssize_t | vtm_str_index_chars (const char *in, size_t len, char *chars, size_t char_count, char *out_found) |
VTM_API ssize_t | vtm_str_index_pattern (const char *in, const char *pattern, size_t input_len, size_t pattern_len) |
VTM_API bool | vtm_str_list_contains (const char *in, const char *delim, const char *search, bool nocase) |
VTM_API size_t | vtm_str_pattern_count (const char *in, const char *pattern) |
VTM_API bool | vtm_str_starts_with (const char *in, const char *start) |
VTM_API char* vtm_str_copy | ( | const char * | in | ) |
Returns a copy of the input string.
in | the string that should be copied |
VTM_API char* vtm_str_ncopy | ( | const char * | in, |
size_t | len | ||
) |
Returns a copy of the first n characters of the input string.
in | the input string |
len | the number of bytes that should be copied |
VTM_API int vtm_str_casecmp | ( | const char * | s1, |
const char * | s2 | ||
) |
Compares s1 to s2 ignoring case.
s1 | |
s2 |
VTM_API vtm_list* vtm_str_split | ( | const char * | in, |
const char * | delim, | ||
unsigned int | count | ||
) |
Splits the given input string by given delimiter
in | the input string |
delim | the delimiter by that the input should be split |
count | the maximum number of result tokens |
VTM_API int vtm_str_split_ex | ( | const char * | in, |
const char * | delim, | ||
char *** | out_tokens, | ||
size_t * | token_count | ||
) |
Splits the given input string by given delimiter.
in | NUL-terminated input string | |
delim | NUL-terminated delimiter string | |
[out] | out_tokens | filled with array of pointers to tokens |
[out] | token_count | filled with number of tokens in array |
VTM_API char* vtm_str_trim | ( | char * | in | ) |
Removes whitespaces at begin and end of the input string.
The result is a pointer to same string and does not need to be freed.
in | the input string |
VTM_API char* vtm_str_printf | ( | const char * | fmt, |
... | |||
) |
Prints fmt with arguments in returned string.
fmt | the format string |
VTM_API char* vtm_str_vprintf | ( | const char * | fmt, |
va_list | ap | ||
) |
Prints fmt with arguments in returned string.
fmt | the format string |
ap | the variadic argument list |
VTM_API ssize_t vtm_str_index_of | ( | const char * | in, |
char | c, | ||
size_t | len | ||
) |
Searches first occurence of given character.
in | the input string |
c | the searched character |
len | the length of the input string |
VTM_API ssize_t vtm_str_index_chars | ( | const char * | in, |
size_t | len, | ||
char * | chars, | ||
size_t | char_count, | ||
char * | out_found | ||
) |
Searches first occurence of any of the given characters.
in | the input string | |
len | the length of the input string | |
chars | array of searched characters | |
char_count | char array length | |
[out] | out_found | the found character |
VTM_API ssize_t vtm_str_index_pattern | ( | const char * | in, |
const char * | pattern, | ||
size_t | input_len, | ||
size_t | pattern_len | ||
) |
Searches the first occurence of the given pattern.
in | the input string |
pattern | the search pattern |
input_len | the length of the input string |
pattern_len | the length of the pattern |
VTM_API bool vtm_str_list_contains | ( | const char * | in, |
const char * | delim, | ||
const char * | search, | ||
bool | nocase | ||
) |
Checks if the list with given delimeter contains search string.
in | the input string |
delim | the list delimeter |
search | the search patttern |
nocase | true if comparison should be case-insensitive |
VTM_API size_t vtm_str_pattern_count | ( | const char * | in, |
const char * | pattern | ||
) |
Evaluates how often the given pattern exists in the input string.
in | the input string |
pattern | the search pattern |
VTM_API bool vtm_str_starts_with | ( | const char * | in, |
const char * | start | ||
) |
Checks if first string begins with the seconds string.
the | input string |
the | prefix |