String utilities; common string support functions. More...
#include "common.h"
Go to the source code of this file.
Functions | |
QSC_EXPORT_API size_t | qsc_stringutils_formatting_count (const char *dest, size_t dstlen) |
Counts all white-spaces, line stops, and returns from a string. | |
QSC_EXPORT_API size_t | qsc_stringutils_formatting_filter (const char *source, size_t srclen, char *dest) |
Remove all white-spaces, lines stops, and returns from a string. | |
QSC_EXPORT_API size_t | qsc_stringutils_add_line_breaks (char *dest, size_t dstlen, size_t linelen, const char *source, size_t srclen) |
Add line breaks to a string at a line length interval. | |
QSC_EXPORT_API size_t | qsc_stringutils_remove_line_breaks (char *dest, size_t dstlen, const char *source, size_t srclen) |
Removes all line breaks from a string. | |
QSC_EXPORT_API void | qsc_stringutils_clear_string (char *source) |
Clear a string of data. | |
QSC_EXPORT_API void | qsc_stringutils_clear_substring (char *dest, size_t length) |
Clear a length of data from a string. | |
QSC_EXPORT_API bool | qsc_stringutils_compare_strings (const char *str1, const char *str2, size_t length) |
Compare two strings for equivalence. | |
QSC_EXPORT_API size_t | qsc_stringutils_concat_strings (char *dest, size_t dstlen, const char *source) |
Concatenate two strings. | |
QSC_EXPORT_API size_t | qsc_stringutils_concat_and_copy (char *dest, size_t dstlen, const char *str1, const char *str2) |
Concatenate two strings and copy them to a third string. | |
QSC_EXPORT_API size_t | qsc_stringutils_copy_substring (char *dest, size_t dstlen, const char *source, size_t srclen) |
Copy a length of one string to another. | |
QSC_EXPORT_API size_t | qsc_stringutils_copy_string (char *dest, size_t dstlen, const char *source) |
Copy a source string to a destination string. | |
QSC_EXPORT_API int64_t | qsc_stringutils_find_char (const char *source, const char token) |
Find a character position within a string. | |
QSC_EXPORT_API int64_t | qsc_stringutils_find_string (const char *source, const char *token) |
Find a substrings position within a string. | |
QSC_EXPORT_API void | qsc_stringutils_byte_to_hex (char *hex, uint8_t input) |
Convert a byte to a hexidecimal string. | |
QSC_EXPORT_API uint8_t | qsc_stringutils_hex_to_byte (const char *hex) |
Convert a hexidecimal string to a byte. | |
QSC_EXPORT_API int64_t | qsc_stringutils_insert_string (char *dest, size_t dstlen, const char *source, size_t offset) |
Inserts a substring into a string. | |
QSC_EXPORT_API bool | qsc_stringutils_is_empty (const char *source) |
Check if a string contains and characters. | |
QSC_EXPORT_API bool | qsc_stringutils_is_hex (const char *source, size_t srclen) |
Check that a string contains only hexadecimal ASCII characters. | |
QSC_EXPORT_API bool | qsc_stringutils_is_numeric (const char *source, size_t srclen) |
Check that a string contains only numeric ASCII characters. | |
QSC_EXPORT_API char * | qsc_stringutils_register_string (char **source, size_t count) |
Join an array of strings to form one string. | |
QSC_EXPORT_API size_t | qsc_stringutils_remove_null_chars (char *source, size_t srclen) |
Remove null characters from an array. | |
QSC_EXPORT_API int64_t | qsc_stringutils_reverse_find_string (const char *source, const char *token, size_t start) |
Find the position of a substring within a string, searching in reverse. | |
QSC_EXPORT_API const char * | qsc_stringutils_reverse_sub_string (const char *source, const char *token) |
Find a substring within a string, searching in reverse. | |
bool | qsc_stringutils_string_compare (const char *str1, const char *str2, size_t length) |
Compare two strings for equality. | |
QSC_EXPORT_API int32_t | qsc_stringutils_string_comparison (const char *source, const char *token) |
Test if the string contains a substring. | |
QSC_EXPORT_API bool | qsc_stringutils_string_contains (const char *source, const char *token) |
Test if the string contains a substring. | |
QSC_EXPORT_API bool | qsc_stringutils_strings_equal (const char *str1, const char *str2) |
Compare two strings for equality. | |
QSC_EXPORT_API char ** | qsc_stringutils_split_string (char *source, const char *delim, size_t *count) |
Split a string into a substring 2-dimensional array. | |
QSC_EXPORT_API void | qsc_stringutils_split_strings (char *dest1, char *dest2, size_t destlen, const char *source, const char *token) |
Split a string into two substrings. | |
QSC_EXPORT_API char * | qsc_stringutils_sub_string (const char *source, const char *token) |
Find a substring within a string. | |
QSC_EXPORT_API int32_t | qsc_stringutils_string_to_int (const char *source) |
Convert a string to a 32-bit integer. | |
QSC_EXPORT_API size_t | qsc_stringutils_string_size (const char *source) |
Get the character length of a string. | |
QSC_EXPORT_API void | qsc_stringutils_int_to_string (int32_t num, char *dest, size_t dstlen) |
Convert a 32-bit signed integer to a string. | |
QSC_EXPORT_API void | qsc_stringutils_uint32_to_string (uint32_t num, char *dest, size_t destlen) |
Convert a 32-bit unsigned integer to a string. | |
QSC_EXPORT_API void | qsc_stringutils_int64_to_string (int64_t num, char *dest, size_t dstlen) |
Convert a 64-bit signed integer to a string. | |
QSC_EXPORT_API void | qsc_stringutils_uint64_to_string (uint64_t num, char *dest, size_t dstlen) |
Convert a 64-bit unsigned integer to a string. | |
QSC_EXPORT_API void | qsc_stringutils_to_lowercase (char *source) |
Convert a string to all lower-case characters. | |
QSC_EXPORT_API void | qsc_stringutils_to_uppercase (char *source) |
Convert a string to all upper-case characters. | |
QSC_EXPORT_API void | qsc_stringutils_trim_newline (char *source) |
Trim null and newline characters from a string. | |
QSC_EXPORT_API void | qsc_stringutils_trim_spaces (char *source) |
Trim a trailing space character from a string. | |
QSC_EXPORT_API size_t | qsc_stringutils_whitespace_count (const char *source, size_t srclen) |
Count all the white-spaces in a string. | |
QSC_EXPORT_API size_t | qsc_stringutils_whitespace_filter (const char *source, size_t srclen, char *dest) |
Remove all the white-spaces from a string. | |
String utilities; common string support functions.
This header provides a comprehensive set of functions for handling strings, including operations for formatting (adding and removing line breaks or whitespace), concatenation, substring extraction, comparison, and conversion between data types and their string representations. These utilities are designed to simplify the manipulation and processing of strings within applications.
QSC_EXPORT_API size_t qsc_stringutils_add_line_breaks | ( | char * | dest, |
size_t | dstlen, | ||
size_t | linelen, | ||
const char * | source, | ||
size_t | srclen ) |
Add line breaks to a string at a line length interval.
dest | [char*] The string receiving the formatted text |
dstlen | [size_t] The size of the dest array |
linelen | [size_t] The line length where a new line character is placed |
source | [const char*] The source string to copy from |
srclen | [size_t] The length of the source array |
QSC_EXPORT_API void qsc_stringutils_byte_to_hex | ( | char * | hex, |
uint8_t | input ) |
Convert a byte to a hexidecimal string.
hex | [char*] The hex string output |
input | [uint8_t] The byte to be converted |
QSC_EXPORT_API void qsc_stringutils_clear_string | ( | char * | source | ) |
Clear a string of data.
source | [char*] The string to clear |
QSC_EXPORT_API void qsc_stringutils_clear_substring | ( | char * | dest, |
size_t | length ) |
Clear a length of data from a string.
dest | [char*] The string dest to clear |
length | [size_t] The number of characters to clear |
QSC_EXPORT_API bool qsc_stringutils_compare_strings | ( | const char * | str1, |
const char * | str2, | ||
size_t | length ) |
Compare two strings for equivalence.
str1 | [const char*] The first string |
str2 | [const char*] The second string |
length | [size_t] The number of characters to compare |
QSC_EXPORT_API size_t qsc_stringutils_concat_and_copy | ( | char * | dest, |
size_t | dstlen, | ||
const char * | str1, | ||
const char * | str2 ) |
Concatenate two strings and copy them to a third string.
dest | [char*] The destination string to copy to |
dstlen | [size_t] The size of the destination dest |
str1 | [const char*] The first string to copy from |
str2 | [const char*] The second string to copy from |
QSC_EXPORT_API size_t qsc_stringutils_concat_strings | ( | char * | dest, |
size_t | dstlen, | ||
const char * | source ) |
Concatenate two strings.
dest | [char*] The destination dest |
dstlen | [size_t] The size of the destination dest |
source | [const char*] The source string to copy |
QSC_EXPORT_API size_t qsc_stringutils_copy_string | ( | char * | dest, |
size_t | dstlen, | ||
const char * | source ) |
Copy a source string to a destination string.
dest | [char*] The destination string to copy to |
dstlen | [size_t] The size of the destination dest |
source | [const char*] The string to copy from |
QSC_EXPORT_API size_t qsc_stringutils_copy_substring | ( | char * | dest, |
size_t | dstlen, | ||
const char * | source, | ||
size_t | srclen ) |
Copy a length of one string to another.
dest | [char*] The destination string to copy to |
dstlen | [size_t] The size of the destination dest |
source | [const char*] The string to copy from |
srclen | [size_t] The substring length |
QSC_EXPORT_API int64_t qsc_stringutils_find_char | ( | const char * | source, |
const char | token ) |
Find a character position within a string.
source | [const char*] The string to check for the substring |
token | [char] The character to search for |
QSC_EXPORT_API int64_t qsc_stringutils_find_string | ( | const char * | source, |
const char * | token ) |
Find a substrings position within a string.
source | [const char*] The string to check for the substring |
token | [const char*] The substring to search for |
QSC_EXPORT_API size_t qsc_stringutils_formatting_count | ( | const char * | dest, |
size_t | dstlen ) |
Counts all white-spaces, line stops, and returns from a string.
dest | [const char*] The string dest to check |
dstlen | [size_t] The size of the dest string |
QSC_EXPORT_API size_t qsc_stringutils_formatting_filter | ( | const char * | source, |
size_t | srclen, | ||
char * | dest ) |
Remove all white-spaces, lines stops, and returns from a string.
source | [const char*] The source string to copy from |
srclen | [size_t] The size of the source string |
dest | [char*] The string receiving the filtered characters |
QSC_EXPORT_API uint8_t qsc_stringutils_hex_to_byte | ( | const char * | hex | ) |
Convert a hexidecimal string to a byte.
hex | [const char*] The hex string |
QSC_EXPORT_API int64_t qsc_stringutils_insert_string | ( | char * | dest, |
size_t | dstlen, | ||
const char * | source, | ||
size_t | offset ) |
Inserts a substring into a string.
dest | [char*] The string receiving the substring |
dstlen | [size_t] The size of the source dest |
source | [const char*] The substring to insert |
offset | [size_t] The insertion starting position within the source string; position is ordinal, 0-n |
QSC_EXPORT_API void qsc_stringutils_int64_to_string | ( | int64_t | num, |
char * | dest, | ||
size_t | dstlen ) |
Convert a 64-bit signed integer to a string.
num | [int64_t] The integer to convert |
dest | [char*] The destination string |
dstlen | [size_t] The size of the output dest |
QSC_EXPORT_API void qsc_stringutils_int_to_string | ( | int32_t | num, |
char * | dest, | ||
size_t | dstlen ) |
Convert a 32-bit signed integer to a string.
num | [int32_t] The integer to convert |
dest | [char*] The destination string |
dstlen | [size_t] The size of the output dest |
QSC_EXPORT_API bool qsc_stringutils_is_empty | ( | const char * | source | ) |
Check if a string contains and characters.
source | [const char*] The string to check for characters |
QSC_EXPORT_API bool qsc_stringutils_is_hex | ( | const char * | source, |
size_t | srclen ) |
Check that a string contains only hexadecimal ASCII characters.
source | [const char*] The string to check for hexadecimal characters |
srclen | [size_t] The number of characters to check |
QSC_EXPORT_API bool qsc_stringutils_is_numeric | ( | const char * | source, |
size_t | srclen ) |
Check that a string contains only numeric ASCII characters.
source | [const char*] The string to check for numeric characters |
srclen | [size_t] The number of characters to check |
QSC_EXPORT_API char * qsc_stringutils_register_string | ( | char ** | source, |
size_t | count ) |
Join an array of strings to form one string.
source | [char**] The array of substrings |
count | [size_t] The number of substring arrays |
QSC_EXPORT_API size_t qsc_stringutils_remove_line_breaks | ( | char * | dest, |
size_t | dstlen, | ||
const char * | source, | ||
size_t | srclen ) |
Removes all line breaks from a string.
dest | [char*] The string receiving the formatted text |
dstlen | [size_t] The size of the dest array |
source | [const char*] The source string to copy from |
srclen | [size_t] The length of the source array |
QSC_EXPORT_API size_t qsc_stringutils_remove_null_chars | ( | char * | source, |
size_t | srclen ) |
Remove null characters from an array.
source | [char*] The string to check for null characters |
srclen | [size_t] The number of characters to check |
QSC_EXPORT_API int64_t qsc_stringutils_reverse_find_string | ( | const char * | source, |
const char * | token, | ||
size_t | start ) |
Find the position of a substring within a string, searching in reverse.
source | [const char*] The string to check for the substring |
token | [const char*] The token separator |
start | [size_t] The starting position within the source string |
QSC_EXPORT_API const char * qsc_stringutils_reverse_sub_string | ( | const char * | source, |
const char * | token ) |
Find a substring within a string, searching in reverse.
source | [const char*] The string to check for the substring |
token | [const char*] The token separator |
QSC_EXPORT_API char ** qsc_stringutils_split_string | ( | char * | source, |
const char * | delim, | ||
size_t * | count ) |
Split a string into a substring 2-dimensional array.
source | [char*] The string to split |
delim | [const char*] The char delimiter used to split the string |
count | [size_t*] The number of substrings in the new array |
QSC_EXPORT_API void qsc_stringutils_split_strings | ( | char * | dest1, |
char * | dest2, | ||
size_t | destlen, | ||
const char * | source, | ||
const char * | token ) |
Split a string into two substrings.
dest1 | [char*] The first destination string |
dest2 | [char*] The second destination string |
destlen | [size_t] The destination strings length |
source | [const char*] The source string |
token | [const char*] The search token |
bool qsc_stringutils_string_compare | ( | const char * | str1, |
const char * | str2, | ||
size_t | length ) |
Compare two strings for equality.
str1 | [const char*] The string to check for the substring |
str2 | [const char*] The substring to search for |
length | [size_t] The string length |
QSC_EXPORT_API int32_t qsc_stringutils_string_comparison | ( | const char * | source, |
const char * | token ) |
Test if the string contains a substring.
source | [const char*] The string to check for the substring |
token | [const char*] The substring to search for |
QSC_EXPORT_API bool qsc_stringutils_string_contains | ( | const char * | source, |
const char * | token ) |
Test if the string contains a substring.
source | [const char*] The string to check for the substring |
token | [const char*] The substring to search for |
QSC_EXPORT_API size_t qsc_stringutils_string_size | ( | const char * | source | ) |
Get the character length of a string.
source | [const char*] The source string pointer |
QSC_EXPORT_API int32_t qsc_stringutils_string_to_int | ( | const char * | source | ) |
Convert a string to a 32-bit integer.
source | [const char*] The string to convert to an integer |
QSC_EXPORT_API bool qsc_stringutils_strings_equal | ( | const char * | str1, |
const char * | str2 ) |
Compare two strings for equality.
str1 | [const char*] The first comparison string |
str2 | [const char*] The second first comparison string |
QSC_EXPORT_API char * qsc_stringutils_sub_string | ( | const char * | source, |
const char * | token ) |
Find a substring within a string.
source | [const char*] The string to check for the substring |
token | [const char*] The token separator |
QSC_EXPORT_API void qsc_stringutils_to_lowercase | ( | char * | source | ) |
Convert a string to all lower-case characters.
source | [char*] The string to convert to lower-case |
QSC_EXPORT_API void qsc_stringutils_to_uppercase | ( | char * | source | ) |
Convert a string to all upper-case characters.
source | [char*] The string to convert to upper-case |
QSC_EXPORT_API void qsc_stringutils_trim_newline | ( | char * | source | ) |
Trim null and newline characters from a string.
source | [char*] The string to trim |
QSC_EXPORT_API void qsc_stringutils_trim_spaces | ( | char * | source | ) |
Trim a trailing space character from a string.
source | [char*] The string to trim |
QSC_EXPORT_API void qsc_stringutils_uint32_to_string | ( | uint32_t | num, |
char * | dest, | ||
size_t | destlen ) |
Convert a 32-bit unsigned integer to a string.
num | [uint32_t] The integer to convert |
dest | [char*] The destination string |
destlen | [size_t] The size of the output dest |
QSC_EXPORT_API void qsc_stringutils_uint64_to_string | ( | uint64_t | num, |
char * | dest, | ||
size_t | dstlen ) |
Convert a 64-bit unsigned integer to a string.
num | [uint64_t] The integer to convert |
dest | [char*] The destination string |
dstlen | [size_t] The size of the output dest |
QSC_EXPORT_API size_t qsc_stringutils_whitespace_count | ( | const char * | source, |
size_t | srclen ) |
Count all the white-spaces in a string.
source | [const char*] The string dest to check |
srclen | [size_t] The size of the dest string |
QSC_EXPORT_API size_t qsc_stringutils_whitespace_filter | ( | const char * | source, |
size_t | srclen, | ||
char * | dest ) |
Remove all the white-spaces from a string.
source | [const char*] The source string to copy from |
srclen | [size_t] The size of the source string |
dest | [char*] The destination string receiving the filtered characters |