|
ucx
UAP Common Extensions
|
Strings that know their length. More...
Go to the source code of this file.
Data Structures | |
| struct | cx_mutstr_s |
| The UCX string structure. More... | |
| struct | cx_string_s |
| The UCX string structure for immutable (constant) strings. More... | |
| struct | cx_strtok_ctx_s |
| Context for string tokenizing. More... | |
Macros | |
| #define | CX_NULLSTR cx_mutstr(NULL) |
| Convenience macro for creating a null string. | |
| #define | CX_SFMT(s) |
| Expands a UCX string as printf arguments. | |
| #define | CX_PRIstr ".*s" |
| Format specifier for a UCX string. | |
| #define | cx_strcast_m(str) |
| Wraps any string into an UCX string. | |
| #define | cx_strcast_(str) |
| internal conversion macro | |
| #define | cx_strcast(str) |
| Converts any string to a cxstring. | |
| #define | cx_strcpy_a(alloc, dest, src) |
| Copies a string. | |
| #define | cx_strcpy(dest, src) |
| Copies a string. | |
| #define | cx_strcat(str, count, ...) |
| Concatenates strings and returns a new string. | |
| #define | cx_strsubs(string, start) |
| Returns a substring starting at the specified location. | |
| #define | cx_strsubsl(string, start, length) |
| Returns a substring starting at the specified location. | |
| #define | cx_strat(str, index) |
| Returns the character at the specified index offset. | |
| #define | cx_strchr(string, chr) |
| Returns a substring starting at the location of the first occurrence of the specified character. | |
| #define | cx_strrchr(string, chr) |
| Returns a substring starting at the location of the last occurrence of the specified character. | |
| #define | cx_strstr(haystack, needle) |
| Returns a substring starting at the location of the first occurrence of the specified string. | |
| #define | cx_strsplit(string, delim, limit, output) |
| Splits a given string using a delimiter string. | |
| #define | cx_strsplit_a(allocator, string, delim, limit, output) |
| Splits a given string using a delimiter string. | |
| #define | cx_strcmp(s1, s2) |
| Compares two strings. | |
| #define | cx_strcasecmp(s1, s2) |
| Compares two strings ignoring case. | |
| #define | cx_strdup_a(allocator, string) |
| Creates a duplicate of the specified string. | |
| #define | cx_strdup(string) |
| Creates a duplicate of the specified string. | |
| #define | cx_strtrim(string) |
| Omits leading and trailing spaces. | |
| #define | cx_strprefix(string, prefix) |
| Checks if a string has a specific prefix. | |
| #define | cx_strsuffix(string, suffix) |
| Checks if a string has a specific suffix. | |
| #define | cx_strcaseprefix(string, prefix) |
| Checks if a string has a specific prefix, ignoring the case. | |
| #define | cx_strcasesuffix(string, suffix) |
| Checks, if a string has a specific suffix, ignoring the case. | |
| #define | cx_strreplacen_a(allocator, str, search, replacement, replmax) |
| Replaces a string with another string. | |
| #define | cx_strreplacen(str, search, replacement, replmax) |
| Replaces a string with another string. | |
| #define | cx_strreplace_a(allocator, str, search, replacement) |
| Replaces a string with another string. | |
| #define | cx_strreplace(str, search, replacement) |
| Replaces a string with another string. | |
| #define | cx_strtok(str, delim, limit) |
| Creates a string tokenization context. | |
| #define | cx_strtok_next(ctx, token) |
| Returns the next token. | |
| #define | cx_strtos_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtoi_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtol_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtoll_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtoi8_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtoi16_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtoi32_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtoi64_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtous_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtou_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtoul_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtoull_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtou8_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtou16_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtou32_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtou64_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtoz_lc(str, output, base, groupsep) |
| Converts a string to a number. | |
| #define | cx_strtos(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtoi(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtol(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtoll(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtoi8(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtoi16(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtoi32(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtoi64(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtoz(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtous(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtou(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtoul(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtoull(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtou8(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtou16(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtou32(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtou64(str, output, base) |
| Converts a string to a number. | |
| #define | cx_strtof_lc(str, output, decsep, groupsep) |
| Converts a string to a single precision floating-point number. | |
| #define | cx_strtod_lc(str, output, decsep, groupsep) |
| Converts a string to a double precision floating-point number. | |
| #define | cx_strtof(str, output) |
| Converts a string to a single precision floating-point number. | |
| #define | cx_strtod(str, output) |
| Converts a string to a double precision floating-point number. | |
Typedefs | |
| typedef struct cx_mutstr_s | cxmutstr |
| A mutable string. | |
| typedef struct cx_string_s | cxstring |
| An immutable string. | |
| typedef struct cx_strtok_ctx_s | CxStrtokCtx |
| A string tokenizing context. | |
Functions | |
| static cxmutstr | cx_mutstr (char *cstring) |
| Wraps a mutable string that must be zero-terminated. | |
| static cxmutstr | cx_mutstrn (char *cstring, size_t length) |
| Wraps a string that does not need to be zero-terminated. | |
| static cxstring | cx_str (const char *cstring) |
| Wraps a string that must be zero-terminated. | |
| static cxstring | cx_strn (const char *cstring, size_t length) |
| Wraps a string that does not need to be zero-terminated. | |
| static cxmutstr | cx_strcast_cxms (cxmutstr str) |
| Internal function, do not use. | |
| static cxstring | cx_strcast_cxs (cxstring str) |
| Internal function, do not use. | |
| static cxmutstr | cx_strcast_uc (unsigned char *str) |
| Internal function, do not use. | |
| static cxmutstr | cx_strcast_c (char *str) |
| Internal function, do not use. | |
| static cxstring | cx_strcast_ucc (const unsigned char *str) |
| Internal function, do not use. | |
| static cxstring | cx_strcast_cc (const char *str) |
| Internal function, do not use. | |
| static cxstring | cx_strcast_1 (cxmutstr str) |
| Internal function, do not use. | |
| static cxstring | cx_strcast_2 (cxstring str) |
| Internal function, do not use. | |
| static cxmutstr | cx_mutstrcast (cxstring str) |
| Casts away constness and converts a cxstring to a cxmutstr. | |
| void | cx_strfree (cxmutstr *str) |
Passes the pointer in this string to the cxDefaultAllocator's free() function. | |
| void | cx_strfree_a (const CxAllocator *alloc, cxmutstr *str) |
| Passes the pointer in this string to the allocator's free function. | |
| int | cx_strcpy_a_ (const CxAllocator *alloc, cxmutstr *dest, cxstring src) |
| Copies a string. | |
| size_t | cx_strlen (size_t count,...) |
| Returns the accumulated length of all specified strings. | |
| cxmutstr | cx_strcat_a (const CxAllocator *alloc, cxmutstr str, size_t count,...) |
| Concatenates strings. | |
| cxstring | cx_strsubsl_ (cxstring string, size_t start, size_t length) |
| Returns a substring. | |
| cxstring | cx_strsubs_ (cxstring string, size_t start) |
| Returns a substring. | |
| static cxmutstr | cx_strsubs_m_ (cxmutstr string, size_t start) |
| Internal conversion function - do not use. | |
| static cxmutstr | cx_strsubsl_m_ (cxmutstr string, size_t start, size_t length) |
| Internal conversion function - do not use. | |
| static char | cx_strat_ (cxstring str, off_t index) |
| Returns the character at the specified index offset. | |
| cxstring | cx_strchr_ (cxstring string, int chr) |
| Searches for a character in a string. | |
| cxstring | cx_strrchr_ (cxstring string, int chr) |
| Searches for a character in a string. | |
| static cxmutstr | cx_strchr_m_ (cxmutstr string, int chr) |
| Internal conversion function - do not use. | |
| static cxmutstr | cx_strrchr_m_ (cxmutstr string, int chr) |
| Internal conversion function - do not use. | |
| cxstring | cx_strstr_ (cxstring haystack, cxstring needle) |
| Searches for a specific substring. | |
| static cxmutstr | cx_strstr_m_ (cxmutstr haystack, cxstring needle) |
| Internal conversion - do not use. | |
| size_t | cx_strsplit_ (cxstring string, cxstring delim, size_t limit, cxstring *output) |
| Splits a given string using a delimiter string. | |
| size_t | cx_strsplit_a_ (const CxAllocator *allocator, cxstring string, cxstring delim, size_t limit, cxstring **output) |
| Splits a given string using a delimiter string. | |
| size_t | cx_strsplit_m_ (cxmutstr string, cxstring delim, size_t limit, cxmutstr *output) |
| Splits a given string using a delimiter string. | |
| size_t | cx_strsplit_ma_ (const CxAllocator *allocator, cxmutstr string, cxstring delim, size_t limit, cxmutstr **output) |
| Splits a given string using a delimiter string. | |
| int | cx_strcmp_ (cxstring s1, cxstring s2) |
| Compares two strings. | |
| int | cx_strcasecmp_ (cxstring s1, cxstring s2) |
| Compares two strings ignoring case. | |
| int | cx_strcmp_p (const void *s1, const void *s2) |
| Compares two strings. | |
| int | cx_strcasecmp_p (const void *s1, const void *s2) |
| Compares two strings ignoring case. | |
| cxmutstr | cx_strdup_a_ (const CxAllocator *allocator, cxstring string) |
| Creates a duplicate of the specified string. | |
| cxstring | cx_strtrim_ (cxstring string) |
| Trims a string. | |
| static cxmutstr | cx_strtrim_m_ (cxmutstr string) |
| Internal conversion function. | |
| bool | cx_strprefix_ (cxstring string, cxstring prefix) |
| Checks if a string has a specific prefix. | |
| bool | cx_strsuffix_ (cxstring string, cxstring suffix) |
| Checks if a string has a specific suffix. | |
| bool | cx_strcaseprefix_ (cxstring string, cxstring prefix) |
| Checks if a string has a specific prefix, ignoring the case. | |
| bool | cx_strcasesuffix_ (cxstring string, cxstring suffix) |
| Checks, if a string has a specific suffix, ignoring the case. | |
| cxmutstr | cx_strreplace_ (const CxAllocator *allocator, cxstring str, cxstring search, cxstring replacement, size_t replmax) |
| Replaces a string with another string. | |
| CxStrtokCtx | cx_strtok_ (cxstring str, cxstring delim, size_t limit) |
| Creates a string tokenization context. | |
| bool | cx_strtok_next_ (CxStrtokCtx *ctx, cxstring *token) |
| Returns the next token. | |
| void | cx_strtok_delim (CxStrtokCtx *ctx, const cxstring *delim, size_t count) |
| Defines an array of more delimiters for the specified tokenization context. | |
| int | cx_strtos_lc_ (cxstring str, short *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtoi_lc_ (cxstring str, int *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtol_lc_ (cxstring str, long *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtoll_lc_ (cxstring str, long long *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtoi8_lc_ (cxstring str, int8_t *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtoi16_lc_ (cxstring str, int16_t *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtoi32_lc_ (cxstring str, int32_t *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtoi64_lc_ (cxstring str, int64_t *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtous_lc_ (cxstring str, unsigned short *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtou_lc_ (cxstring str, unsigned int *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtoul_lc_ (cxstring str, unsigned long *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtoull_lc_ (cxstring str, unsigned long long *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtou8_lc_ (cxstring str, uint8_t *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtou16_lc_ (cxstring str, uint16_t *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtou32_lc_ (cxstring str, uint32_t *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtou64_lc_ (cxstring str, uint64_t *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtoz_lc_ (cxstring str, size_t *output, int base, const char *groupsep) |
| Converts a string to a number. | |
| int | cx_strtof_lc_ (cxstring str, float *output, char decsep, const char *groupsep) |
| Converts a string to a single precision floating-point number. | |
| int | cx_strtod_lc_ (cxstring str, double *output, char decsep, const char *groupsep) |
| Converts a string to a double precision floating-point number. | |
Variables | |
| const unsigned | cx_strstr_sbo_size |
| The maximum length of the "needle" in cx_strstr() that can use SBO. | |
Strings that know their length.
| #define CX_SFMT | ( | s | ) |
Expands a UCX string as printf arguments.
| #define cx_strat | ( | str, | |
| index ) |
Returns the character at the specified index offset.
When the index is negative, the character is counted from the end of the string where -1 denotes the last character in the string.
When the index is out of bounds, the function returns zero.
| str | the string |
| index | the index offset |
| #define cx_strcasecmp | ( | s1, | |
| s2 ) |
Compares two strings ignoring case.
| s1 | the first string |
| s2 | the second string |
s1 is smaller than s2, positive if s1 is larger than s2, zero if both strings equal ignoring case | #define cx_strcaseprefix | ( | string, | |
| prefix ) |
Checks if a string has a specific prefix, ignoring the case.
| string | the string to check |
| prefix | the prefix the string should have |
true, if and only if the string has the specified prefix, false otherwise | #define cx_strcasesuffix | ( | string, | |
| suffix ) |
Checks, if a string has a specific suffix, ignoring the case.
| string | the string to check |
| suffix | the suffix the string should have |
true, if and only if the string has the specified suffix, false otherwise | #define cx_strcast | ( | str | ) |
Converts any string to a cxstring.
| str | (any supported string type) the string to cast |
cxstring) | #define cx_strcast_ | ( | str | ) |
internal conversion macro
| #define cx_strcast_m | ( | str | ) |
Wraps any string into an UCX string.
| str | (any supported string type) the string to cast |
cxstring) or (cxmutstr) the string wrapped as UCX string | #define cx_strcat | ( | str, | |
| count, | |||
| ... ) |
Concatenates strings and returns a new string.
The resulting string will be allocated by the cxDefaultAllocator. So developers must pass the return value to cx_strfree() eventually.
ptr in the returned string will be NULL.| str | (cxmutstr*) the string the other strings shall be concatenated to |
| count | (size_t) the number of the other following strings to concatenate |
| ... | all other UCX strings |
| #define cx_strchr | ( | string, | |
| chr ) |
Returns a substring starting at the location of the first occurrence of the specified character.
If the string does not contain the character, an empty string is returned.
| string | the string where to locate the character |
| chr | (int) the character to locate |
cxstring or cxmutstr) a substring starting at the first location of chr | #define cx_strcmp | ( | s1, | |
| s2 ) |
Compares two strings.
| s1 | the first string |
| s2 | the second string |
s1 is smaller than s2, positive if s1 is larger than s2, zero if both strings equal | #define cx_strcpy | ( | dest, | |
| src ) |
Copies a string.
The memory in the dest structure is either allocated or re-allocated to fit the entire source string, including a zero-terminator.
The string in dest is guaranteed to be zero-terminated, regardless of whether src is.
| dest | (cxmutstr*) a pointer to the structure where to copy the contents to |
| src | the source string |
| zero | success |
| non-zero | if re-allocation failed |
| #define cx_strcpy_a | ( | alloc, | |
| dest, | |||
| src ) |
Copies a string.
The memory in the dest structure is either allocated or re-allocated to fit the entire source string, including a zero-terminator.
The string in dest is guaranteed to be zero-terminated, regardless of whether src is.
| alloc | (CxAllocator*) the allocator |
| dest | (cxmutstr*) a pointer to the structure where to copy the contents to |
| src | the source string |
| zero | success |
| non-zero | if re-allocation failed |
| #define cx_strdup | ( | string | ) |
Creates a duplicate of the specified string.
The new string will contain a copy allocated by the cxDefaultAllocator. So developers must pass the return value to cx_strfree().
| string | the string to duplicate |
cxmutstr) a duplicate of the string | #define cx_strdup_a | ( | allocator, | |
| string ) |
Creates a duplicate of the specified string.
The new string will contain a copy allocated by allocator.
| allocator | (CxAllocator*) the allocator to use |
| string | the string to duplicate |
cxmutstr) a duplicate of the string | #define cx_strprefix | ( | string, | |
| prefix ) |
Checks if a string has a specific prefix.
| string | the string to check |
| prefix | the prefix the string should have |
true, if and only if the string has the specified prefix, false otherwise | #define cx_strrchr | ( | string, | |
| chr ) |
Returns a substring starting at the location of the last occurrence of the specified character.
If the string does not contain the character, an empty string is returned.
| string | the string where to locate the character |
| chr | (int) the character to locate |
cxstring or cxmutstr) a substring starting at the last location of chr | #define cx_strreplace | ( | str, | |
| search, | |||
| replacement ) |
Replaces a string with another string.
The returned string will be allocated by the cxDefaultAllocator and is guaranteed to be zero-terminated.
If allocation fails, or the input string is empty, the returned string will be empty.
| str | the string where replacements should be applied |
| search | the string to search for |
| replacement | the replacement string |
cxmutstr) the resulting string after applying the replacements | #define cx_strreplace_a | ( | allocator, | |
| str, | |||
| search, | |||
| replacement ) |
Replaces a string with another string.
The returned string will be allocated by allocator and is guaranteed to be zero-terminated.
If allocation fails, or the input string is empty, the returned string will be empty.
| allocator | (CxAllocator*) the allocator to use |
| str | the string where replacements should be applied |
| search | the string to search for |
| replacement | the replacement string |
cxmutstr) the resulting string after applying the replacements | #define cx_strreplacen | ( | str, | |
| search, | |||
| replacement, | |||
| replmax ) |
Replaces a string with another string.
The function replaces at most replmax occurrences.
The returned string will be allocated by the cxDefaultAllocator and is guaranteed to be zero-terminated.
If allocation fails, or the input string is empty, the returned string will be empty.
| str | the string where replacements should be applied |
| search | the string to search for |
| replacement | the replacement string |
| replmax | (size_t) maximum number of replacements |
cxmutstr) the resulting string after applying the replacements | #define cx_strreplacen_a | ( | allocator, | |
| str, | |||
| search, | |||
| replacement, | |||
| replmax ) |
Replaces a string with another string.
The function replaces at most replmax occurrences.
The returned string will be allocated by allocator and is guaranteed to be zero-terminated.
If allocation fails, or the input string is empty, the returned string will be empty.
| allocator | (CxAllocator*) the allocator to use |
| str | the string where replacements should be applied |
| search | the string to search for |
| replacement | the replacement string |
| replmax | (size_t) maximum number of replacements |
cxmutstr) the resulting string after applying the replacements | #define cx_strsplit | ( | string, | |
| delim, | |||
| limit, | |||
| output ) |
Splits a given string using a delimiter string.
string. Use cx_strdup() to get copies.| string | the string to split |
| delim | the delimiter |
| limit | (size_t) the maximum number of split items |
| output | (cxstring* or cxmutstr*) a preallocated array of at least limit length |
| #define cx_strsplit_a | ( | allocator, | |
| string, | |||
| delim, | |||
| limit, | |||
| output ) |
Splits a given string using a delimiter string.
The array pointed to by output will be allocated by allocator.
string. Use cx_strdup() to get copies.NULL pointer will be written to output and the number returned will be zero.| allocator | (CxAllocator*) the allocator to use for allocating the resulting array |
| string | the string to split |
| delim | the delimiter |
| limit | (size_t) the maximum number of split items |
| output | (cxstring** or cxmutstr**) a pointer where the address of the allocated array shall be written to |
| #define cx_strstr | ( | haystack, | |
| needle ) |
Returns a substring starting at the location of the first occurrence of the specified string.
If haystack does not contain needle, an empty string is returned.
If needle is an empty string, the complete haystack is returned.
| haystack | the string to be scanned |
| needle | string containing the sequence of characters to match |
cxstring or cxmutstr) a substring starting at the first occurrence of needle, or an empty string, if the sequence is not contained | #define cx_strsubs | ( | string, | |
| start ) |
Returns a substring starting at the specified location.
| string | input string |
| start | (size_t) start location of the substring |
cxstring or cxmutstr) a substring of string starting at start | #define cx_strsubsl | ( | string, | |
| start, | |||
| length ) |
Returns a substring starting at the specified location.
The returned string will be limited to length bytes or the number of bytes available in string, whichever is smaller.
| string | input string |
| start | start location of the substring |
| length | the maximum length of the returned string |
string starting at start | #define cx_strsuffix | ( | string, | |
| suffix ) |
Checks if a string has a specific suffix.
| string | the string to check |
| suffix | the suffix the string should have |
true, if and only if the string has the specified suffix, false otherwise | #define cx_strtod | ( | str, | |
| output ) |
Converts a string to a double precision floating-point number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character.
The decimal separator is assumed to be a dot character. The comma character is treated as a group separator and ignored during parsing. If you want to choose a different format, use cx_strtof_lc().
| str | the string to convert |
| output | a pointer to the double variable where the result shall be stored |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtod_lc | ( | str, | |
| output, | |||
| decsep, | |||
| groupsep ) |
Converts a string to a double precision floating-point number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character.
| str | the string to convert |
| output | a pointer to the double variable where the result shall be stored |
| decsep | the decimal separator |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtof | ( | str, | |
| output ) |
Converts a string to a single precision floating-point number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character. It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
The decimal separator is assumed to be a dot character. The comma character is treated as a group separator and ignored during parsing. If you want to choose a different format, use cx_strtof_lc().
| str | the string to convert |
| output | a pointer to the float variable where the result shall be stored |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtof_lc | ( | str, | |
| output, | |||
| decsep, | |||
| groupsep ) |
Converts a string to a single precision floating-point number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character. It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
| str | the string to convert |
| output | a pointer to the float variable where the result shall be stored |
| decsep | the decimal separator |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoi | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoi16 | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoi16_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoi32 | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoi32_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoi64 | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoi64_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoi8 | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoi8_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoi_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtok | ( | str, | |
| delim, | |||
| limit ) |
Creates a string tokenization context.
| str | the string to tokenize |
| delim | the delimiter string (must not be empty) |
| limit | (size_t) the maximum number of tokens that shall be returned |
CxStrtokCtx) a new string tokenization context | #define cx_strtok_next | ( | ctx, | |
| token ) |
Returns the next token.
The token will point to the source string.
| ctx | (CxStrtokCtx*) the tokenization context |
| token | a pointer to either a cxstring or cxmutstr where the next token shall be stored |
| #define cx_strtol | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtol_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoll | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoll_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtos | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtos_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtou | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtou16 | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtou16_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtou32 | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtou32_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtou64 | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtou64_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtou8 | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtou8_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtou_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoul | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoul_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoull | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoull_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtous | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtous_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoz | ( | str, | |
| output, | |||
| base ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
The comma character is treated as a group separator and ignored during parsing. If you want to choose the set of group separators, use the _lc variant of this function (e.g. cx_strtoz_lc()).
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtoz_lc | ( | str, | |
| output, | |||
| base, | |||
| groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | (const char*) each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| #define cx_strtrim | ( | string | ) |
Omits leading and trailing spaces.
| string | the string that shall be trimmed |
cxstring or cxmutstr) the trimmed string
|
inlinestatic |
Wraps a mutable string that must be zero-terminated.
The length is implicitly inferred by using a call to strlen().
When NULL is passed, the length will be set to zero.
If you need to wrap a constant string, use cx_str().
| cstring | the string to wrap (must be zero-terminated) |
Casts away constness and converts a cxstring to a cxmutstr.
For internal use only!
| str |
|
inlinestatic |
Wraps a string that does not need to be zero-terminated.
The argument may be NULL if the length is zero.
If you need to wrap a constant string, use cx_strn().
| cstring | the string to wrap (or NULL, only if the length is zero) |
| length | the length of the string |
|
inlinestatic |
Wraps a string that must be zero-terminated.
The length is implicitly inferred by using a call to strlen().
When NULL is passed, the length will be set to zero.
If you need to wrap a non-constant string, use cx_mutstr().
| cstring | the string to wrap (must be zero-terminated) |
|
inlinestatic |
Returns the character at the specified index offset.
Internal function - do not use.
| str | the string |
| index | the index offset |
Compares two strings ignoring case.
| s1 | the first string |
| s2 | the second string |
s1 is smaller than s2, positive if s1 is larger than s2, zero if both strings equal ignoring case | int cx_strcasecmp_p | ( | const void * | s1, |
| const void * | s2 ) |
Compares two strings ignoring case.
This function has a compatible signature for the use as a cx_compare_func.
| s1 | the first string |
| s2 | the second string |
s1 is smaller than s2, positive if s1 is larger than s2, zero if both strings equal ignoring case Checks if a string has a specific prefix, ignoring the case.
| string | the string to check |
| prefix | the prefix the string should have |
true, if and only if the string has the specified prefix, false otherwise Checks, if a string has a specific suffix, ignoring the case.
| string | the string to check |
| suffix | the suffix the string should have |
true, if and only if the string has the specified suffix, false otherwise Internal function, do not use.
| str |
Internal function, do not use.
| str |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
| cxmutstr cx_strcat_a | ( | const CxAllocator * | alloc, |
| cxmutstr | str, | ||
| size_t | count, | ||
| ... ) |
Concatenates strings.
The resulting string will be allocated by the specified allocator. So developers must pass the return value to cx_strfree_a() eventually.
If str already contains a string, the memory will be reallocated and the other strings are appended. Otherwise, new memory is allocated.
ptr in the returned string will be NULL.| alloc | the allocator to use |
| str | the string the other strings shall be concatenated to |
| count | the number of the other following strings to concatenate |
| ... | all other UCX strings |
Searches for a character in a string.
Internal function - do not use.
| string | |
| chr |
Internal conversion function - do not use.
| string | |
| chr |
Compares two strings.
| s1 | the first string |
| s2 | the second string |
s1 is smaller than s2, positive if s1 is larger than s2, zero if both strings equal | int cx_strcmp_p | ( | const void * | s1, |
| const void * | s2 ) |
Compares two strings.
This function has a compatible signature for the use as a cx_compare_func.
| s1 | the first string |
| s2 | the second string |
s1 is smaller than s2, positive if s1 is larger than s2, zero if both strings equal | int cx_strcpy_a_ | ( | const CxAllocator * | alloc, |
| cxmutstr * | dest, | ||
| cxstring | src ) |
Copies a string.
Internal function - do not use.
| alloc | the allocator |
| dest | a pointer to the structure where to copy the contents to |
| src | the source string |
| zero | success |
| non-zero | if re-allocation failed |
| cxmutstr cx_strdup_a_ | ( | const CxAllocator * | allocator, |
| cxstring | string ) |
Creates a duplicate of the specified string.
The new string will contain a copy allocated by allocator.
| allocator | the allocator to use |
| string | the string to duplicate |
| void cx_strfree | ( | cxmutstr * | str | ) |
Passes the pointer in this string to the cxDefaultAllocator's free() function.
The pointer in the struct is set to NULL, and the length is set to zero, which means that this function protects you against double-free.
const char* you are really supposed to free. If you encounter such a situation, you should double-check your code.| str | the string to free |
| void cx_strfree_a | ( | const CxAllocator * | alloc, |
| cxmutstr * | str ) |
Passes the pointer in this string to the allocator's free function.
The pointer in the struct is set to NULL, and the length is set to zero, which means that this function protects you against double-free.
const char* you are really supposed to free. If you encounter such a situation, you should double-check your code.| alloc | the allocator |
| str | the string to free |
| size_t cx_strlen | ( | size_t | count, |
| ... ) |
Returns the accumulated length of all specified strings.
If this sum overflows, errno is set to EOVERFLOW.
| count | the total number of specified strings |
| ... | all strings |
|
inlinestatic |
Wraps a string that does not need to be zero-terminated.
The argument may be NULL if the length is zero.
If you need to wrap a non-constant string, use cx_mutstrn().
| cstring | the string to wrap (or NULL, only if the length is zero) |
| length | the length of the string |
Checks if a string has a specific prefix.
| string | the string to check |
| prefix | the prefix the string should have |
true, if and only if the string has the specified prefix, false otherwise Searches for a character in a string.
Internal function - do not use.
| string | |
| chr |
Internal conversion function - do not use.
| string | |
| chr |
| cxmutstr cx_strreplace_ | ( | const CxAllocator * | allocator, |
| cxstring | str, | ||
| cxstring | search, | ||
| cxstring | replacement, | ||
| size_t | replmax ) |
Replaces a string with another string.
Internal function - do not use.
| allocator | |
| str | |
| search | |
| replacement | |
| replmax |
Splits a given string using a delimiter string.
Internal function - do not use.
| string | the string to split |
| delim | the delimiter |
| limit | the maximum number of split items |
| output | the output array |
| size_t cx_strsplit_a_ | ( | const CxAllocator * | allocator, |
| cxstring | string, | ||
| cxstring | delim, | ||
| size_t | limit, | ||
| cxstring ** | output ) |
Splits a given string using a delimiter string.
Internal function - do not use.
| allocator | the allocator to use for allocating the resulting array |
| string | the string to split |
| delim | the delimiter |
| limit | the maximum number of split items |
| output | the output array |
Splits a given string using a delimiter string.
Internal function - do not use.
| string | the string to split |
| delim | the delimiter |
| limit | the maximum number of split items |
| output | the output array |
| size_t cx_strsplit_ma_ | ( | const CxAllocator * | allocator, |
| cxmutstr | string, | ||
| cxstring | delim, | ||
| size_t | limit, | ||
| cxmutstr ** | output ) |
Splits a given string using a delimiter string.
Internal function - do not use.
| allocator | the allocator to use for allocating the resulting array |
| string | the string to split |
| delim | the delimiter |
| limit | the maximum number of split items |
| output | the output array |
Searches for a specific substring.
Internal function - do not use.
| haystack | the string to be scanned |
| needle | string containing the sequence of characters to match |
needle, or an empty string, if the sequence is not contained Internal conversion - do not use.
| haystack | |
| needle |
Returns a substring.
Internal function - do not use.
| string | input string |
| start | start location of the substring |
string starting at start Internal conversion function - do not use.
| string | |
| start |
Returns a substring.
Internal function - do not use.
| string | input string |
| start | start location of the substring |
| length | the maximum length of the returned string |
string starting at start Internal conversion function - do not use.
| string | |
| start | |
| length |
Checks if a string has a specific suffix.
| string | the string to check |
| suffix | the suffix the string should have |
true, if and only if the string has the specified suffix, false otherwise | int cx_strtod_lc_ | ( | cxstring | str, |
| double * | output, | ||
| char | decsep, | ||
| const char * | groupsep ) |
Converts a string to a double precision floating-point number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character. It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
| str | the string to convert |
| output | a pointer to the float variable where the result shall be stored |
| decsep | the decimal separator |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtof_lc_ | ( | cxstring | str, |
| float * | output, | ||
| char | decsep, | ||
| const char * | groupsep ) |
Converts a string to a single precision floating-point number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character. It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
| str | the string to convert |
| output | a pointer to the float variable where the result shall be stored |
| decsep | the decimal separator |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtoi16_lc_ | ( | cxstring | str, |
| int16_t * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtoi32_lc_ | ( | cxstring | str, |
| int32_t * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtoi64_lc_ | ( | cxstring | str, |
| int64_t * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtoi8_lc_ | ( | cxstring | str, |
| int8_t * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtoi_lc_ | ( | cxstring | str, |
| int * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| CxStrtokCtx cx_strtok_ | ( | cxstring | str, |
| cxstring | delim, | ||
| size_t | limit ) |
Creates a string tokenization context.
| str | the string to tokenize |
| delim | the delimiter (must not be empty) |
| limit | the maximum number of tokens that shall be returned |
| void cx_strtok_delim | ( | CxStrtokCtx * | ctx, |
| const cxstring * | delim, | ||
| size_t | count ) |
Defines an array of more delimiters for the specified tokenization context.
| ctx | the tokenization context |
| delim | array of more delimiters |
| count | number of elements in the array |
| bool cx_strtok_next_ | ( | CxStrtokCtx * | ctx, |
| cxstring * | token ) |
Returns the next token.
The token will point to the source string.
| ctx | the tokenization context |
| token | a pointer to memory where the next token shall be stored |
| int cx_strtol_lc_ | ( | cxstring | str, |
| long * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtoll_lc_ | ( | cxstring | str, |
| long long * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtos_lc_ | ( | cxstring | str, |
| short * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtou16_lc_ | ( | cxstring | str, |
| uint16_t * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtou32_lc_ | ( | cxstring | str, |
| uint32_t * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtou64_lc_ | ( | cxstring | str, |
| uint64_t * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtou8_lc_ | ( | cxstring | str, |
| uint8_t * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtou_lc_ | ( | cxstring | str, |
| unsigned int * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtoul_lc_ | ( | cxstring | str, |
| unsigned long * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtoull_lc_ | ( | cxstring | str, |
| unsigned long long * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtous_lc_ | ( | cxstring | str, |
| unsigned short * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
| int cx_strtoz_lc_ | ( | cxstring | str, |
| size_t * | output, | ||
| int | base, | ||
| const char * | groupsep ) |
Converts a string to a number.
The function returns non-zero when conversion is not possible. In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. It sets errno to ERANGE when the target datatype is too small.
| str | the string to convert |
| output | a pointer to the integer variable where the result shall be stored |
| base | 2, 8, 10, or 16 |
| groupsep | each character in this string is treated as a group separator and ignored during conversion |
| zero | success |
| non-zero | conversion was not possible |
Trims a string.
Internal function - do not use.
| string |