DDraceNetwork Docs
|
Functions | |
void | str_append (char *dst, const char *src, int dst_size) |
template<int N> | |
void | str_append (char(&dst)[N], const char *src) |
int | str_copy (char *dst, const char *src, int dst_size) |
template<int N> | |
void | str_copy (char(&dst)[N], const char *src) |
void | str_utf8_truncate (char *dst, int dst_size, const char *src, int truncation_len) |
void | str_truncate (char *dst, int dst_size, const char *src, int truncation_len) |
int | str_length (const char *str) |
int | str_format_v (char *buffer, int buffer_size, const char *format, va_list args) |
int | str_format (char *buffer, int buffer_size, const char *format,...) |
const char * | str_trim_words (const char *str, int words) |
bool | str_has_cc (const char *str) |
void | str_sanitize_cc (char *str) |
void | str_sanitize (char *str) |
void | str_clean_whitespaces (char *str) |
char * | str_skip_to_whitespace (char *str) |
const char * | str_skip_to_whitespace_const (const char *str) |
char * | str_skip_whitespaces (char *str) |
const char * | str_skip_whitespaces_const (const char *str) |
int | str_comp_nocase (const char *a, const char *b) |
int | str_comp_nocase_num (const char *a, const char *b, int num) |
int | str_comp (const char *a, const char *b) |
int | str_comp_num (const char *a, const char *b, int num) |
int | str_comp_filenames (const char *a, const char *b) |
const char * | str_startswith (const char *str, const char *prefix) |
int | str_utf8_dist_buffer (const char *a, const char *b, int *buf, int buf_len) |
bool | str_delimiters_around_offset (const char *haystay, const char *delim, int offset, int *start, int *end) |
const char * | str_rchr (const char *haystack, char needle) |
int | str_countchr (const char *haystack, char needle) |
int | str_isspace (char c) |
String related functions.
void str_append | ( | char * | dst, |
const char * | src, | ||
int | dst_size | ||
) |
Appends a string to another.
dst | Pointer to a buffer that contains a string. |
src | String to append. |
dst_size | Size of the buffer of the dst string. |
void str_append | ( | char(&) | dst[N], |
const char * | src | ||
) |
Appends a string to a fixed-size array of chars.
dst | Array that shall receive the string. |
src | String to append. |
void str_clean_whitespaces | ( | char * | str | ) |
Removes leading and trailing spaces and limits the use of multiple spaces.
str | String to clean up |
int str_comp | ( | const char * | a, |
const char * | b | ||
) |
Compares two strings case sensitive.
a | String to compare. |
b | String to compare. |
< 0
- String a is less than string b 0
- String a is equal to string b > 0
- String a is greater than string bint str_comp_filenames | ( | const char * | a, |
const char * | b | ||
) |
Compares two strings case insensitive, digit chars will be compared as numbers.
a | String to compare. |
b | String to compare. |
< 0
- String a is less than string b 0
- String a is equal to string b > 0
- String a is greater than string bint str_comp_nocase | ( | const char * | a, |
const char * | b | ||
) |
Compares to strings case insensitively.
a | String to compare. |
b | String to compare. |
< 0
- String a is less than string b 0
- String a is equal to string b > 0
- String a is greater than string bint str_comp_nocase_num | ( | const char * | a, |
const char * | b, | ||
int | num | ||
) |
Compares up to num characters of two strings case insensitively.
a | String to compare. |
b | String to compare. |
num | Maximum characters to compare |
< 0
- String a is less than string b 0
- String a is equal to string b > 0
- String a is greater than string bint str_comp_num | ( | const char * | a, |
const char * | b, | ||
int | num | ||
) |
Compares up to num characters of two strings case sensitive.
a | String to compare. |
b | String to compare. |
num | Maximum characters to compare |
< 0
- String a is less than string b 0
- String a is equal to string b > 0
- String a is greater than string bint str_copy | ( | char * | dst, |
const char * | src, | ||
int | dst_size | ||
) |
Copies a string to another.
dst | Pointer to a buffer that shall receive the string. |
src | String to be copied. |
dst_size | Size of the buffer dst. |
void str_copy | ( | char(&) | dst[N], |
const char * | src | ||
) |
Copies a string to a fixed-size array of chars.
dst | Array that shall receive the string. |
src | String to be copied. |
int str_countchr | ( | const char * | haystack, |
char | needle | ||
) |
Counts the number of occurrences of a character in a string.
haystack | String to count in |
needle | Character to count |
bool str_delimiters_around_offset | ( | const char * | haystay, |
const char * | delim, | ||
int | offset, | ||
int * | start, | ||
int * | end | ||
) |
haystack | String to search in |
delim | String to search for |
offset | Number of characters into the haystack |
start | Will be set to the first delimiter on the left side of the offset (or haystack start) |
end | Will be set to the first delimiter on the right side of the offset (or haystack end) |
true
if both delimiters were found int str_format | ( | char * | buffer, |
int | buffer_size, | ||
const char * | format, | ||
... | |||
) |
Performs printf formatting into a buffer.
buffer | Pointer to the buffer to receive the formatted string. |
buffer_size | Size of the buffer. |
format | printf formatting string. |
... | Parameters for the formatting. |
int str_format_v | ( | char * | buffer, |
int | buffer_size, | ||
const char * | format, | ||
va_list | args | ||
) |
Performs printf formatting into a buffer.
buffer | Pointer to the buffer to receive the formatted string. |
buffer_size | Size of the buffer. |
format | printf formatting string. |
args | The variable argument list. |
bool str_has_cc | ( | const char * | str | ) |
Check whether string has ASCII control characters.
str | String to check. |
int str_isspace | ( | char | c | ) |
Determines whether a character is whitespace.
c | the character to check |
int str_length | ( | const char * | str | ) |
Returns the length of a zero terminated string.
str | Pointer to the string. |
const char * str_rchr | ( | const char * | haystack, |
char | needle | ||
) |
Finds the last occurrence of a character
haystack | String to search in |
needle | Character to search for |
void str_sanitize | ( | char * | str | ) |
Replaces all characters below 32 with whitespace with exception to \t,
and \r.
str | String to sanitize. |
void str_sanitize_cc | ( | char * | str | ) |
Replaces all characters below 32 with whitespace.
str | String to sanitize. |
char * str_skip_to_whitespace | ( | char * | str | ) |
Skips leading non-whitespace characters.
str | Pointer to the string. |
const char * str_skip_to_whitespace_const | ( | const char * | str | ) |
char * str_skip_whitespaces | ( | char * | str | ) |
Skips leading whitespace characters.
str | Pointer to the string. |
Pointer to the first non-whitespace character found within the string.
const char * str_skip_whitespaces_const | ( | const char * | str | ) |
const char * str_startswith | ( | const char * | str, |
const char * | prefix | ||
) |
Checks case sensitive whether the string begins with a certain prefix.
str | String to check. |
prefix | Prefix to look for. |
const char * str_trim_words | ( | const char * | str, |
int | words | ||
) |
Trims specific number of words at the start of a string.
str | String to trim the words from. |
words | Count of words to trim. |
void str_truncate | ( | char * | dst, |
int | dst_size, | ||
const char * | src, | ||
int | truncation_len | ||
) |
Truncates a string to a given length.
dst | Pointer to a buffer that shall receive the string. |
dst_size | Size of the buffer dst. |
src | String to be truncated. |
truncation_len | Maximum length of the returned string (not counting the zero termination). |
int str_utf8_dist_buffer | ( | const char * | a, |
const char * | b, | ||
int * | buf, | ||
int | buf_len | ||
) |
Computes the edit distance between two strings, allows buffers to be passed in.
a | - First string for the edit distance. |
b | - Second string for the edit distance. |
buf | - Buffer for the function. |
buf_len | Length of the buffer, must be at least as long as twice the length of both strings combined plus two. |
void str_utf8_truncate | ( | char * | dst, |
int | dst_size, | ||
const char * | src, | ||
int | truncation_len | ||
) |
Truncates a utf8 encoded string to a given length.
dst | Pointer to a buffer that shall receive the string. |
dst_size | Size of the buffer dst. |
str | String to be truncated. |
truncation_len | Maximum codepoints in the returned string. |