![]() |
DDraceNetwork Documentation
|
Functions | |
| 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_append (char *dst, const char *src, int dst_size) |
| template<int N> | |
| void | str_append (char(&dst)[N], const char *src) |
| void | str_truncate (char *dst, int dst_size, const char *src, int truncation_len) |
| int | str_length (const char *str) |
| int | str_isspace (char c) |
| 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) |
| int | str_comp_filenames (const char *a, const char *b) |
| 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) |
| const char * | str_startswith_nocase (const char *str, const char *prefix) |
| const char * | str_startswith (const char *str, const char *prefix) |
| const char * | str_endswith_nocase (const char *str, const char *suffix) |
| const char * | str_find_nocase (const char *haystack, const char *needle) |
| const char * | str_find (const char *haystack, const char *needle) |
| const char * | str_next_token (const char *str, const char *delim, char *buffer, int buffer_size) |
| bool | str_delimiters_around_offset (const char *haystack, 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) |
| void | str_hex (char *dst, int dst_size, const void *data, int data_size) |
| void | str_hex_cstyle (char *dst, int dst_size, const void *data, int data_size, int bytes_per_line=12) |
| int | str_hex_decode (void *dst, int dst_size, const char *src) |
| void | str_base64 (char *dst, int dst_size, const void *data, int data_size) |
| int | str_base64_decode (void *dst, int dst_size, const char *data) |
| int | str_utf8_encode (char *ptr, int chr) |
| int | str_utf8_decode (const char **ptr) |
| void | str_utf8_truncate (char *dst, int dst_size, const char *src, int truncation_len) |
| int | str_utf8_fix_truncation (char *str) |
| void | str_utf8_trim_right (char *param) |
| void | str_utf8_tolower (const char *input, char *output, size_t size) |
| int | str_utf8_isspace (int code) |
| int | str_utf8_isstart (char c) |
| int | str_utf8_rewind (const char *str, int cursor) |
| const char * | str_utf8_find_nocase (const char *haystack, const char *needle, const char **end=nullptr) |
| int | str_utf8_comp_nocase (const char *a, const char *b) |
| int | str_utf8_comp_nocase_num (const char *a, const char *b, int num) |
| const char * | str_utf8_skip_whitespaces (const char *str) |
| int | str_utf8_forward (const char *str, int cursor) |
| int | str_utf8_check (const char *str) |
| void | str_utf8_copy_num (char *dst, const char *src, int dst_size, int num) |
| void | str_utf8_stats (const char *str, size_t max_size, size_t max_count, size_t *size, size_t *count) |
| size_t | str_utf8_offset_bytes_to_chars (const char *str, size_t byte_offset) |
| size_t | str_utf8_offset_chars_to_bytes (const char *str, size_t char_offset) |
| 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,...) |
| int | str_utf8_dist_buffer (const char *a, const char *b, int *buf, int buf_len) |
| int | str_utf32_dist_buffer (const int *a, int a_len, const int *b, int b_len, int *buf, int buf_len) |
| int | str_utf8_comp_confusable (const char *str1, const char *str2) |
| int | str_utf8_tolower_codepoint (int code) |
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_base64 | ( | char * | dst, |
| int | dst_size, | ||
| const void * | data, | ||
| int | data_size ) |
Takes a datablock and generates the base64 encoding of it.
| dst | Buffer to fill with base64 data. |
| dst_size | Size of the buffer. |
| data | Data to turn into base64. |
| data_size | Size of the data. |
| int str_base64_decode | ( | void * | dst, |
| int | dst_size, | ||
| const char * | data ) |
Takes a base64 string without any whitespace and correct padding and returns a byte array.
| dst | Buffer for the byte array. |
| dst_size | Size of the buffer. |
| data | String to decode. |
| 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. |
| int 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. |
| int str_comp_nocase | ( | const char * | a, |
| const char * | b ) |
Compares to strings case insensitively.
| a | String to compare. |
| b | String to compare. |
| int 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. |
| int 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. |
| int 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 * | haystack, |
| const char * | delim, | ||
| int | offset, | ||
| int * | start, | ||
| int * | end ) |
| haystack | String to search in. |
| delim | String to search for. |
| offset | Number of characters into 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). |
| const char * str_endswith_nocase | ( | const char * | str, |
| const char * | suffix ) |
Checks case insensitive whether the string ends with a certain suffix.
| str | String to check. |
| suffix | Suffix to look. |
| const char * str_find | ( | const char * | haystack, |
| const char * | needle ) |
Finds a string inside another string case sensitive.
| haystack | String to search in. |
| needle | String to search for. |
| const char * str_find_nocase | ( | const char * | haystack, |
| const char * | needle ) |
Finds a string inside another string case insensitively.
| haystack | String to search in. |
| needle | String to search for. |
| 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. |
| void str_hex | ( | char * | dst, |
| int | dst_size, | ||
| const void * | data, | ||
| int | data_size ) |
Takes a datablock and generates a hex string of it, with spaces between bytes.
| dst | Buffer to fill with hex data. |
| dst_size | Size of the buffer (at least 3 * data_size + 1 to contain all data). |
| data | Data to turn into hex. |
| data_size | Size of the data. |
| void str_hex_cstyle | ( | char * | dst, |
| int | dst_size, | ||
| const void * | data, | ||
| int | data_size, | ||
| int | bytes_per_line = 12 ) |
Takes a datablock and generates a hex string of it, in the C style array format, i.e. with bytes formatted in 0x00-0xFF notation and commas with spaces between the bytes. The output can be split over multiple lines by specifying the maximum number of bytes that should be printed per line.
| dst | Buffer to fill with hex data. |
| dst_size | Size of the buffer (at least 6 * data_size + 1 to contain all data). |
| data | Data to turn into hex. |
| data_size | Size of the data. |
| bytes_per_line | After this many printed bytes a newline will be printed. |
| int str_hex_decode | ( | void * | dst, |
| int | dst_size, | ||
| const char * | src ) |
Takes a hex string without spaces between bytes and returns a byte array.
| dst | Buffer for the byte array. |
| dst_size | size of the buffer. |
| src | String to decode. |
| 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 null-terminated string.
| str | Pointer to the string. |
| const char * str_next_token | ( | const char * | str, |
| const char * | delim, | ||
| char * | buffer, | ||
| int | buffer_size ) |
Writes the next token after str into buf, returns the rest of the string.
| str | Pointer to string. |
| delim | Delimiter for tokenization. |
| buffer | Buffer to store token in. |
| buffer_size | Size of the buffer. |
| 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, \n and \n.
| 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. |
| 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_startswith_nocase | ( | const char * | str, |
| const char * | prefix ) |
Checks case insensitive 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 null-termination). |
| int str_utf32_dist_buffer | ( | const int * | a, |
| int | a_len, | ||
| const int * | b, | ||
| int | b_len, | ||
| 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. |
| a_len | Length of the first string. |
| b | Second string for the edit distance. |
| b_len | Length of the second string. |
| buf | Buffer for the function. |
| buf_len | Length of the buffer, must be at least as long as the length of both strings combined plus two. |
| int str_utf8_check | ( | const char * | str | ) |
Checks if a strings contains just valid UTF-8 characters.
| str | Pointer to a possible UTF-8 string. |
| int str_utf8_comp_confusable | ( | const char * | str1, |
| const char * | str2 ) |
Checks if two strings only differ by confusable characters.
| str1 | String to compare. |
| str2 | String to compare. |
| int str_utf8_comp_nocase | ( | const char * | a, |
| const char * | b ) |
Compares two UTF-8 strings case insensitively.
| a | String to compare. |
| b | String to compare. |
| int str_utf8_comp_nocase_num | ( | const char * | a, |
| const char * | b, | ||
| int | num ) |
Compares up to num bytes of two UTF-8 strings case insensitively.
| a | String to compare. |
| b | String to compare. |
| num | Maximum bytes to compare. |
| void str_utf8_copy_num | ( | char * | dst, |
| const char * | src, | ||
| int | dst_size, | ||
| int | num ) |
Copies a number of UTF-8 characters from one 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. |
| num | Maximum number of UTF-8 characters to be copied. |
| int str_utf8_decode | ( | const char ** | ptr | ) |
Decodes a UTF-8 codepoint.
| ptr | Pointer to a UTF-8 string. This pointer will be moved forward. |
| 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. |
| int str_utf8_encode | ( | char * | ptr, |
| int | chr ) |
Encode a UTF-8 character.
| ptr | Pointer to a buffer that should receive the data. Should be able to hold at least 4 bytes. |
| chr | Unicode codepoint to encode. |
| const char * str_utf8_find_nocase | ( | const char * | haystack, |
| const char * | needle, | ||
| const char ** | end = nullptr ) |
Finds a UTF-8 string inside another UTF-8 string case insensitively.
| haystack | String to search in. |
| needle | String to search for. |
| end | A pointer that will be set to a pointer into haystack directly behind the last character where the needle was found. Will be set to nullptr if needle could not be found. Optional parameter. |
| int str_utf8_fix_truncation | ( | char * | str | ) |
Fixes truncation of a Unicode character at the end of a UTF-8 string.
| str | UTF-8 string. |
| int str_utf8_forward | ( | const char * | str, |
| int | cursor ) |
Moves a cursor forwards in an UTF-8 string.
| str | UTF-8 string. |
| cursor | Position in the string. |
| int str_utf8_isspace | ( | int | code | ) |
Checks whether the given Unicode codepoint renders as space.
| code | Unicode codepoint to check. |
| int str_utf8_isstart | ( | char | c | ) |
Checks whether a given byte is the start of a UTF-8 character.
| c | Byte to check. |
| size_t str_utf8_offset_bytes_to_chars | ( | const char * | str, |
| size_t | byte_offset ) |
Converts a byte offset of a UTF-8 string to the UTF-8 character offset.
| str | Pointer to the string. |
| byte_offset | Offset in bytes. |
| size_t str_utf8_offset_chars_to_bytes | ( | const char * | str, |
| size_t | char_offset ) |
Converts a UTF-8 character offset of a UTF-8 string to the byte offset.
| str | Pointer to the string. |
| char_offset | Offset in UTF-8 characters. |
| int str_utf8_rewind | ( | const char * | str, |
| int | cursor ) |
Moves a cursor backwards in an UTF-8 string,
| str | UTF-8 string. |
| cursor | Position in the string. |
| const char * str_utf8_skip_whitespaces | ( | const char * | str | ) |
Skips leading characters that render as spaces.
| str | Input string. |
| void str_utf8_stats | ( | const char * | str, |
| size_t | max_size, | ||
| size_t | max_count, | ||
| size_t * | size, | ||
| size_t * | count ) |
Determines the byte size and UTF-8 character count of a UTF-8 string.
| str | Pointer to the string. |
| max_size | Maximum number of bytes to count. |
| max_count | Maximum number of UTF-8 characters to count. |
| size | Pointer to store size (number of non. Zero bytes) of the string. |
| count | Pointer to store count of UTF-8 characters of the string. |
| void str_utf8_tolower | ( | const char * | input, |
| char * | output, | ||
| size_t | size ) |
Converts the given UTF-8 string to lowercase (locale insensitive).
| input | String to convert to lowercase. |
| output | Buffer that will receive the lowercase string. |
| size | Size of the output buffer. |
| int str_utf8_tolower_codepoint | ( | int | code | ) |
Converts the given Unicode codepoint to lowercase (locale insensitive).
| code | Unicode codepoint to convert. |
| void str_utf8_trim_right | ( | char * | param | ) |
Removes trailing characters that render as spaces by modifying the string in-place.
| param | Input string. |
| void str_utf8_truncate | ( | char * | dst, |
| int | dst_size, | ||
| const char * | src, | ||
| int | truncation_len ) |
Truncates a UTF-8 encoded 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 codepoints in the returned string. |