Eina_String_Group

Langue: en

Version: 378191 (fedora - 01/12/10)

Section: 3 (Bibliothèques de fonctions)

NAME

String -

These functions provide useful C string management.

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)
Join two static strings and store the result in a static buffer.

Functions


static size_t eina_strlen_bounded (const char *str, size_t maxlen)
Count up to a given amount of bytes of the given string.
EAPI size_t eina_strlcpy (char *dst, const char *src, size_t siz)
Copy a c-string to another.
EAPI size_t EAPI size_t eina_strlcat (char *dst, const char *src, size_t siz)
Append a c-string.
EAPI size_t EAPI size_t EAPI Eina_Bool eina_str_has_prefix (const char *str, const char *prefix)
Check if the given string has the given prefix.
EAPI Eina_Bool eina_str_has_suffix (const char *str, const char *suffix)
Check if the given string has the given suffix.
EAPI Eina_Bool eina_str_has_extension (const char *str, const char *ext)
Check if the given string has the given suffix.
EAPI char ** eina_str_split (const char *str, const char *delim, int max_tokens)
Split a string using a delimiter.
EAPI char ** eina_str_split_full (const char *str, const char *delim, int max_tokens, unsigned int *elements)
Split a string using a delimiter and returns number of elements.
EAPI 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)
Join two strings of known length.
EAPI size_t EAPI char * eina_str_convert (const char *enc_from, const char *enc_to, const char *text)
Use iconv to convert a text string from one encoding to another.
EAPI size_t EAPI char EAPI char * eina_str_escape (const char *str)
Put a \ before and Space( ), \ or ' in a 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.

Variables


EAPI size_t EAPI size_t EAPI Eina_Bool EINA_WARN_UNUSED_RESULT

Detailed Description

These functions provide useful C string management.

Define Documentation

#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)

Join two static strings and store the result in a static buffer. Parameters:

dst The buffer to store the result.
sep The separator character to use.
a First string to use, before sep.
b Second string to use, after sep.

Returns:

The number of characters printed.

This function is similar to eina_str_join_len(), but will assume string sizes are know using sizeof(X).

See also:

eina_str_join()
eina_str_join_static()

Function Documentation

static size_t eina_strlen_bounded (const char * str, size_t maxlen) [inline, static]

Count up to a given amount of bytes of the given string. Parameters:

str The string pointer.
maxlen The maximum length to allow.

Returns:

the string size or (size_t)-1 if greater than maxlen.

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.

EAPI size_t eina_strlcpy (char * dst, const char * src, size_t siz)

Copy a c-string to another. Parameters:

dst The destination string.
src The source string.
siz The size of the destination string.

Returns:

The length of the source string.

This function copies up to siz - 1 characters from the NUL-terminated string src to dst, NUL-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 occured.

EAPI size_t eina_strlcat (char * dst, const char * src, size_t siz)

Append a c-string. Parameters:

dst The destination string.
src The source string.
siz The size of the destination string.

Returns:

The length of the source string plus MIN(siz, strlen(initial dst))

This function appends src to 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)). This function returns strlen(src) + MIN(siz, strlen(initial dst)). If the returned value is greater or equal than siz, truncation occurred.

EAPI Eina_Bool eina_str_has_prefix (const char * str, const char * prefix)

Check if the given string has the given prefix. Parameters:

str The string to work with.
prefix The prefix to check for.

Returns:

EINA_TRUE if the string has the given prefix, EINA_FALSE otherwise.

This function returns EINA_TRUE if str has the prefix prefix, EINA_FALSE otherwise. If the length of prefix is greater than str, EINA_FALSE is returned.

EAPI Eina_Bool eina_str_has_suffix (const char * str, const char * suffix)

Check if the given string has the given suffix. Parameters:

str The string to work with.
suffix The suffix to check for.

Returns:

EINA_TRUE if the string has the given suffix, EINA_FALSE otherwise.

This function returns EINA_TRUE if str has the suffix suffix, EINA_FALSE otherwise. If the length of suffix is greater than str, EINA_FALSE is returned.

Parameters:

str the string to work with
suffix the suffix to check for

Returns:

true if str has the given suffix checks if the string has the given suffix

EAPI Eina_Bool eina_str_has_extension (const char * str, const char * ext)

Check if the given string has the given suffix. Parameters:

str The string to work with.
ext The extension to check for.

Returns:

EINA_TRUE if the string has the given extension, EINA_FALSE otherwise.

This function does the same like eina_str_has_suffix(), but with a case insensitive compare.

EAPI char ** eina_str_split (const char * str, const char * delim, int max_tokens)

Split a string using a delimiter. Parameters:

str The string to split.
delim The string which specifies the places at which to split the string.
max_tokens The maximum number of strings to split string into.

Returns:

A newly-allocated NULL-terminated array of strings.

This functin splits str into a maximum of max_tokens pieces, using the given delimiter delim. delim 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 completely. If max_tokens is reached, the last string in the returned string array contains the remainder of string. The returned value is a newly allocated NUL-terminated array of string. To free it, free the first element of the array and the array itself.

EAPI char ** eina_str_split_full (const char * str, const char * delim, int max_tokens, unsigned int * elements)

Split a string using a delimiter and returns number of elements. Parameters:

str The string to split.
delim The string which specifies the places at which to split the string.
max_tokens The maximum number of strings to split string into.
elements Where to return the number of elements in returned array (not counting the terminating NULL). May be NULL.

Returns:

A newly-allocated NULL-terminated array of strings.

This functin splits str into a maximum of max_tokens pieces, using the given delimiter delim. delim 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 completely. If max_tokens is reached, the last string in the returned string array contains the remainder of string. The returned value is a newly allocated NUL-terminated array of string. To free it, free the first element of the array and the array itself.

See also:

eina_str_split()

EAPI 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)

Join two strings of known length. Parameters:

dst The buffer to store the result.
size Size (in byte) of the buffer.
sep The separator character to use.
a First string to use, before sep.
a_len length of a.
b Second string to use, after sep.
b_len length of b.

Returns:

The number of characters printed.

This function joins the strings a and b (in that order) and separate them with sep. The result is stored in the buffer dst and at most size - 1 characters will be 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 strings). Just like snprintf(), it will not write more than size bytes, thus a returned value of size or more means that the output was truncated.

See also:

eina_str_join()
eina_str_join_static()

EAPI char * eina_str_convert (const char * enc_from, const char * enc_to, const char * text)

Use iconv to convert a text string from one encoding to another. Parameters:

enc_from encoding to convert from
enc_to encoding to convert to
text text to convert

EAPI char * eina_str_escape (const char * str)

Put a \ before and Space( ), \ or ' in a string. Parameters:

str the string to escape

A newly allocated string is returned.

static size_t static size_t eina_str_join (char * dst, size_t size, char sep, const char * a, const char * b) [inline, static]

Join two strings of known length. Parameters:

dst The buffer to store the result.
size Size (in byte) of the buffer.
sep The separator character to use.
a First string to use, before sep.
b Second string to use, after sep.

Returns:

The number of characters printed.

This function is similar to eina_str_join_len(), but will compute the length of a and b using strlen().

See also:

eina_str_join_len()
eina_str_join_static()

Author

Generated automatically by Doxygen for Eina from the source code.