| exo Reference Manual |
|---|
String Utility FunctionsString Utility Functions — Various string-related functions. |
#include <exo/exo.h> gchar* exo_str_elide_underscores (const gchar *text); gboolean exo_str_is_equal (const gchar *a, const gchar *b); gchar* exo_str_replace (const gchar *str, const gchar *pattern, const gchar *replacement); gchar** exo_strndupv (gchar **strv, gint num); const gchar* exo_intern_string (const gchar *string); const gchar* exo_intern_static_string (const gchar *string); #define I_ (string)
gchar* exo_str_elide_underscores (const gchar *text);
Returns a copy of text with all mnemonic underscores
stripped off.
text : |
A zero terminated string. |
| Returns : | A copy of text without underscores. The
returned string must be freed when no
longer required.
|
gboolean exo_str_is_equal (const gchar *a,
const gchar *b);
NULL-safe string comparison. Returns TRUE if both a and b are
NULL or if a and b refer to valid strings which are equal.
You should always prefer this function over strcmp().
a : |
A pointer to first string or NULL.
|
b : |
A pointer to second string or NULL.
|
| Returns : | TRUE if a equals b, else FALSE.
|
gchar* exo_str_replace (const gchar *str,
const gchar *pattern,
const gchar *replacement);
Searches str for occurances of pattern and replaces each
such occurance with replacement. Returns a newly allocated
copy of str on which the given replacement were performed.
The caller is responsible to free the returned string using
g_free() when no longer needed.
Note that pattern and replacement don't need to be of the
same size.
str : |
the input string. |
pattern : |
a search pattern in str.
|
replacement : |
replacement string for pattern.
|
| Returns : | a newly allocated copy of str where all
occurances of pattern are replaced with
replacement.
|
Since 0.3.1.1
gchar** exo_strndupv (gchar **strv,
gint num);
Creates a new string vector containing the
first n elements of strv.
strv : |
String vector to duplicate. |
num : |
Number of strings in strv to
duplicate.
|
| Returns : | The new string vector. Should be
freed using g_strfreev() when no
longer needed.
|
const gchar* exo_intern_string (const gchar *string);
Returns a canonical representation for string. Interned strings can
be compared for equality by comparing the pointers, instead of using strcmp()
or exo_str_is_equal(). exo_intern_string() takes a copy of the string for its
internal usage, so string does not need to be static.
string : |
a string |
| Returns : | a canonical representation for the string |
Since 0.3.1.1
const gchar* exo_intern_static_string (const gchar *string);
Returns a canonical representation for string. Interned strings can
be compared for equality by comparing the pointers, instead of using strcmp()
or exo_str_is_equal(). exo_intern_static_string() does not copy the string,
therefore string must not be freed or modified.
string : |
a static string |
| Returns : | a canonical representation for the string |
Since 0.3.1.1
#define I_(string)
Shortcut for exo_intern_static_string().
string : |
a static string. |
Since 0.3.1.1
| << MD5 Functions | Miscellaneous Utility Functions >> |