Ecore_Str.h File Reference
Contains useful C string functions. More...
Defines | |
#define | ecore_str_join_static(dst, sep, a, b) ecore_str_join_len(dst, sizeof(dst), sep, a, (sizeof(a) > 0) ? sizeof(a) - 1 : 0, b, (sizeof(b) > 0) ? sizeof(b) - 1 : 0) |
Join two static strings and store the result in static dst buffer. | |
Functions | |
EAPI size_t | ecore_strlcpy (char *dst, const char *src, size_t siz) |
copy a c-string | |
EAPI size_t | ecore_strlcat (char *dst, const char *src, size_t siz) |
append a c-string | |
EAPI int | ecore_str_has_prefix (const char *str, const char *prefix) |
checks if the string has the given prefix | |
EAPI int | ecore_str_has_suffix (const char *str, const char *suffix) |
checks if the string has the given suffix | |
EAPI int | ecore_str_has_extension (const char *str, const char *ext) |
This function does the same like ecore_str_has_suffix(), but with a case insensitive compare. | |
EAPI char ** | ecore_str_split (const char *string, const char *delimiter, int max_tokens) |
Splits a string into a maximum of max_tokens pieces, using the given delimiter. | |
EAPI size_t | ecore_str_join_len (char *dst, size_t size, char sep, const char *a, size_t a_len, const char *b, size_t b_len) |
Join two strings of known length and store the result in dst buffer. |
Detailed Description
Contains useful C string functions.
Define Documentation
#define ecore_str_join_static | ( | dst, | |||
sep, | |||||
a, | |||||
b | ) | ecore_str_join_len(dst, sizeof(dst), sep, a, (sizeof(a) > 0) ? sizeof(a) - 1 : 0, b, (sizeof(b) > 0) ? sizeof(b) - 1 : 0) |
Join two static strings and store the result in static dst buffer.
Similar to ecore_str_join_len(), but will assume string sizes are know using sizeof(X).
- Parameters:
-
dst where to store the result. sep separator character to use. a first string to use, before sep. b second string to use, after sep.
- Returns:
- the number of characters printed (not including the trailing '' used to end output to strings). Just like snprintf(), it will not write more than size bytes, thus a return value of size or more means that the output was truncated.
- See also:
- ecore_str_join() and ecore_str_join_static()
Function Documentation
EAPI int ecore_str_has_extension | ( | const char * | str, | |
const char * | ext | |||
) |
This function does the same like ecore_str_has_suffix(), but with a case insensitive compare.
- Parameters:
-
str the string to work with ext the extension to check for
- Returns:
- true if str has the given extension checks if the string has the given extension
EAPI int ecore_str_has_prefix | ( | const char * | str, | |
const char * | prefix | |||
) |
checks if the string has the given prefix
- Parameters:
-
str the string to work with prefix the prefix to check for
- Returns:
- true if str has the given prefix
EAPI int ecore_str_has_suffix | ( | const char * | str, | |
const char * | suffix | |||
) |
checks if the string has the given suffix
- Parameters:
-
str the string to work with suffix the suffix to check for
- Returns:
- true if str has the given suffix
EAPI size_t ecore_str_join_len | ( | char * | dst, | |
size_t | size, | |||
char | sep, | |||
const char * | a, | |||
size_t | a_len, | |||
const char * | b, | |||
size_t | b_len | |||
) |
Join two strings of known length and store the result in dst buffer.
- Parameters:
-
dst where to store the result. size byte size of dst, will write at most (size - 1) characters and then the '' (null terminator). sep separator character to use. a first string to use, before sep. a_len length of a, not including '' (strlen()-like) b second string to use, after sep. b_len length of b, not including '' (strlen()-like)
- Returns:
- the number of characters printed (not including the trailing '' used to end output to strings). Just like snprintf(), it will not write more than size bytes, thus a return value of size or more means that the output was truncated.
- See also:
- ecore_str_join() and ecore_str_join_static()
EAPI char** ecore_str_split | ( | const char * | str, | |
const char * | delim, | |||
int | max_tokens | |||
) |
Splits a string into a maximum of max_tokens pieces, using the given delimiter.
If max_tokens is reached, the final string in the returned string array contains the remainder of string.
- Parameters:
-
str A string to split. delim A string which specifies the places at which to split the string. The delimiter is not included in any of the resulting strings, unless max_tokens is reached. max_tokens The maximum number of strings to split string into. If this is less than 1, the string is split completely.
- Returns:
- A newly-allocated NULL-terminated array of strings. To free it: free the first element of the array and the array itself.
EAPI size_t ecore_strlcat | ( | char * | dst, | |
const char * | src, | |||
size_t | siz | |||
) |
append a c-string
- Parameters:
-
dst the destination src the source siz the size of the destination
- Returns:
- the length of the source string plus MIN(siz, strlen(initial dst)) Appends src to string dst of size siz (unlike strncat, siz is the full size of dst, not space left). At most siz-1 characters will be copied. Always NUL terminates (unless siz <= strlen(dst)). Returns strlen(src) + MIN(siz, strlen(initial dst)). If retval >= siz, truncation occurred.
EAPI size_t ecore_strlcpy | ( | char * | dst, | |
const char * | src, | |||
size_t | siz | |||
) |
copy a c-string
- Parameters:
-
dst the destination src the source siz the size of the destination
- Returns:
- the length of the source string Copy src to string dst of size siz. At most siz-1 characters will be copied. Always NUL terminates (unless siz == 0). Returns strlen(src); if retval >= siz, truncation occurred.