Tizen Native API
|
Functions | |
size_t | eina_strlcpy (char *dst, const char *src, size_t siz) |
Copies one c-string to another. | |
size_t | eina_strlcat (char *dst, const char *src, size_t siz) |
Appends a c-string. | |
Eina_Bool | eina_str_has_prefix (const char *str, const char *prefix) |
Check whether the given string has the given prefix. | |
Eina_Bool | eina_str_has_suffix (const char *str, const char *suffix) |
Check whether the given string has the given suffix. | |
Eina_Bool | eina_str_has_extension (const char *str, const char *ext) |
Check whether the given string has the given extension. | |
char ** | eina_str_split (const char *string, const char *delimiter, int max_tokens) |
Splits a string using a delimiter. | |
char ** | eina_str_split_full (const char *string, const char *delimiter, int max_tokens, unsigned int *elements) |
Splits a string using a delimiter and returns the number of elements. | |
size_t | eina_str_join_len (char *dst, size_t size, char sep, const char *a, size_t a_len, const char *b, size_t b_len) |
Joins two strings of known length. | |
char * | eina_str_convert (const char *enc_from, const char *enc_to, const char *text) |
Uses Iconv to convert a text string from one encoding to another. | |
char * | eina_str_escape (const char *str) |
Escapes back slashes, spaces, and apostrophes in strings. | |
void | eina_str_tolower (char **str) |
Lowercases all the characters in the range [A-Z] in the given string. | |
void | eina_str_toupper (char **str) |
Uppercases all the characters in the range [a-z] in the given string. | |
static size_t | eina_str_join (char *dst, size_t size, char sep, const char *a, const char *b) |
Join two strings of known length. | |
static size_t | eina_strlen_bounded (const char *str, size_t maxlen) |
Count up to a given amount of bytes of the given string. | |
Defines | |
#define | eina_str_join_static(dst, sep, a, b) eina_str_join_len(dst, sizeof(dst), sep, a, (sizeof(a) > 0) ? sizeof(a) - 1 : 0, b, (sizeof(b) > 0) ? sizeof(b) - 1 : 0) |
Joins two static strings and stores the result in a static buffer. |
The group discusses useful functions for C string manipulation.
This group of functions allows you to manipulate strings more easily, they provide functionality that is not available through string.h.
Since these functions modify the strings they can't be used with shared strings(eina_stringshare).
#define eina_str_join_static | ( | dst, | |
sep, | |||
a, | |||
b | |||
) | eina_str_join_len(dst, sizeof(dst), sep, a, (sizeof(a) > 0) ? sizeof(a) - 1 : 0, b, (sizeof(b) > 0) ? sizeof(b) - 1 : 0) |
Joins two static strings and stores the result in a static buffer.
This function is similar to eina_str_join_len(), but assumes that string sizes are known using sizeof(X).
dst | The buffer to store the result |
sep | The separator character to use |
a | The first string to use, before sep |
b | The second string to use, after sep |
char* eina_str_convert | ( | const char * | enc_from, |
const char * | enc_to, | ||
const char * | text | ||
) |
Uses Iconv to convert a text string from one encoding to another.
This function converts text, encoded in enc_from. On success, the converted text is returned and is encoded in enc_to. On failure, NULL
is returned. Iconv is used to convert text. If Iconv is not available, NULL
is returned. When not used anymore, the returned value must be freed.
[in] | enc_from | The encoding to convert from |
[in] | enc_to | The encoding to convert to |
[in] | text | The text to convert |
char* eina_str_escape | ( | const char * | str | ) |
Escapes back slashes, spaces, and apostrophes in strings.
NULL
on failure. When not used anymore, the returned value must be freed.[in] | str | The string to escape |
Eina_Bool eina_str_has_extension | ( | const char * | str, |
const char * | ext | ||
) |
Check whether the given string has the given extension.
This function does the same as eina_str_has_suffix(), except it's case insensitive.
[in] | str | The string to work with |
[in] | ext | The extension to check for |
EINA_TRUE
if the string has the given extension, otherwise EINA_FALSE
Eina_Bool eina_str_has_prefix | ( | const char * | str, |
const char * | prefix | ||
) |
Check whether the given string has the given prefix.
This function returns EINA_TRUE
if str has the prefix prefix, otherwise it returns EINA_FALSE
. If the length of prefix is greater than str, EINA_FALSE
is returned.
[in] | str | The string to work with |
[in] | prefix | The prefix to check for |
EINA_TRUE
if the string has the given prefix, otherwise EINA_FALSE
Eina_Bool eina_str_has_suffix | ( | const char * | str, |
const char * | suffix | ||
) |
Check whether the given string has the given suffix.
This function returns EINA_TRUE
if str has the suffix suffix, otherwise it returns EINA_FALSE
. If the length of suffix is greater than str, EINA_FALSE
is returned.
[in] | str | The string to work with |
[in] | suffix | The suffix to check for |
EINA_TRUE
if the string has the given suffix, otherwise EINA_FALSE
static size_t eina_str_join | ( | char * | dst, |
size_t | size, | ||
char | sep, | ||
const char * | a, | ||
const char * | b | ||
) | [static] |
Join two strings of known length.
This function is similar to eina_str_join_len(), but will compute the length of a
and b
using strlen().
[in] | dst | The buffer to store the result. |
[in] | size | Size (in byte) of the buffer. |
[in] | sep | The separator character to use. |
[in] | a | First string to use, before sep . |
[in] | b | Second string to use, after sep . |
size_t eina_str_join_len | ( | char * | dst, |
size_t | size, | ||
char | sep, | ||
const char * | a, | ||
size_t | a_len, | ||
const char * | b, | ||
size_t | b_len | ||
) |
Joins two strings of known length.
This function joins the strings a and b (in that order) and separates them with sep. The result is stored in the buffer dst and at most size - 1 characters are written and the string is NULL-terminated. a_len is the length of a (not including '\0') and b_len is the length of b (not including '\0'). This function returns the number of characters printed (not including the trailing '\0' used to end output to the strings). Just like snprintf(), it does not write more than size bytes, thus a returned value of size or more means that the output is truncated.
[in] | dst | The buffer to store the result |
[in] | size | The size (in byte) of the buffer |
[in] | sep | The separator character to use |
[in] | a | The first string to use, before sep |
[in] | a_len | The length of a |
[in] | b | The second string to use, after sep |
[in] | b_len | The length of b |
char** eina_str_split | ( | const char * | string, |
const char * | delimiter, | ||
int | max_tokens | ||
) |
Splits a string using a delimiter.
This function splits string into a maximum of max_tokens pieces, using the given delimiter delimiter. delimiter is not included in any of the resulting strings, unless max_tokens is reached. If max_tokens is less than 1
, the string is splitted as many times as possible. If max_tokens is reached, the last string in the returned string array contains the remainder of the string. The returned value is a newly allocated NULL-terminated array of strings or NULL
if it fails to allocate the array. To free it, free the first element of the array and the array itself.
[in] | string | The string to split |
[in] | delimiter | The string that specifies the places at which to split the string |
[in] | max_tokens | The maximum number of strings to split the string into, or a number less than 1 to split as many times as possible This parameter IGNORES the added NULL terminator. |
NULL
if it fails to allocate the array char** eina_str_split_full | ( | const char * | string, |
const char * | delimiter, | ||
int | max_tokens, | ||
unsigned int * | elements | ||
) |
Splits a string using a delimiter and returns the number of elements.
This function splits string into a maximum of max_tokens pieces, using the given delimiter delimiter. delimiter is not included in any of the resulting strings, unless max_tokens is reached. If max_tokens is less than 1
, the string is splitted as many times as possible. If max_tokens is reached, the last string in the returned string array contains the remainder of the string. The returned value is a newly allocated NULL-terminated array of strings or NULL
if it fails to allocate the array. To free it, free the first element of the array and the array itself.
NULL
terminator element that is added to the array for safety. If it returns 6
, the number of split strings returned is 6, but the size of the array (including the NULL
element) is actually 7.string | The string to split | |
[in] | delimiter | The string that specifies the places at which to split the string |
[in] | max_tokens | The maximum number of strings to split the string into, or a number less than 1 to split as many times as possible This parameter IGNORES the added NULL terminator. |
[out] | elements | The number of elements in the returned array This array is guaranteed to be no greater than max_tokens, and it does NOT count the NULL terminator element. |
NULL
if it fails to allocate the arrayvoid eina_str_tolower | ( | char ** | str | ) |
Lowercases all the characters in the range [A-Z] in the given string.
This function modifies the original string, changing all characters in [A-Z] to lowercase. If str is NULL
or is an empty string, this function does nothing.
[out] | str | The string to lowercase |
void eina_str_toupper | ( | char ** | str | ) |
Uppercases all the characters in the range [a-z] in the given string.
This function modifies the original string, changing all characters in [a-z] to uppercase. If str is NULL
or is an empty string, this function does nothing.
[out] | str | The string to uppercase |
size_t eina_strlcat | ( | char * | dst, |
const char * | src, | ||
size_t | siz | ||
) |
Appends a c-string.
This function appends src to dst of size siz (unlike strncat, siz is the full size of dst, no space is left). At most siz - 1 characters are copied. Always NULL-terminates (unless siz <= strlen(dst)). This function returns strlen(src) + MIN(siz, strlen(initial dst)). If the returned value is greater than or equal to siz, truncation occurs.
[in] | dst | The destination string |
[in] | src | The source string |
[in] | siz | The size of the destination string |
size_t eina_strlcpy | ( | char * | dst, |
const char * | src, | ||
size_t | siz | ||
) |
Copies one c-string to another.
This function copies up to siz - 1 characters from the NULL-terminated string src to dst, NULL-terminating the result (unless siz is equal to 0). The returned value is the length of src. If the returned value is greater than siz, truncation occurs.
NULL
byte is found in the first siz bytes of src.[in] | dst | The destination string |
[in] | src | The source string |
[in] | siz | The size of the destination string |
static size_t eina_strlen_bounded | ( | const char * | str, |
size_t | maxlen | ||
) | [static] |
Count up to a given amount of bytes of the given string.
This function returns the size of str
, up to maxlen
characters. It avoid needless iterations after that size. str
must be a valid pointer and MUST not be NULL
, otherwise this function will crash. This function returns the string size, or (size_t)-1 if the size is greater than maxlen.
[in] | str | The string pointer. |
[in] | maxlen | The maximum length to allow. |