RmString

RmString — String helper functions

Stability Level

Stable, unless otherwise indicated

Functions

#define RM_EMPTY_STRING()
gchar * rm_strcasestr ()
gchar * rm_convert_utf8 ()
gboolean rm_strv_contains ()
gchar ** rm_strv_add ()
gchar ** rm_strv_remove ()

Description

Adds string helper functions to simplify the code.

Functions

RM_EMPTY_STRING()

#define RM_EMPTY_STRING(x) (!(x) || !strlen(x))

Convenient function to check for an empty string (either NULL or with a len of 0)

Parameters

x

string to check

 

rm_strcasestr ()

gchar *
rm_strcasestr (const gchar *haystack,
               const gchar *needle);

Search for case-sensitive needle in haystack

Parameters

haystack

haystack

 

needle

needle

 

Returns

pointer to position or NULL


rm_convert_utf8 ()

gchar *
rm_convert_utf8 (const gchar *text,
                 gssize len);

Convert string (if needed) to UTF-8.

Parameters

text

input text string

 

len

length of string or -1 for strlen

 

Returns

input string in UTF-8 (must be freed)


rm_strv_contains ()

gboolean
rm_strv_contains (const gchar * const *strv,
                  const gchar *str);

Checks if strv contains str

Parameters

strv

a NULL-terminated array of strings

 

str

a string

 

Returns

TRUE if str is found in strv , otherwise FALSE


rm_strv_add ()

gchar **
rm_strv_add (gchar **strv,
             const gchar *str);

Add str to strv

Parameters

strv

string vector

 

str

new string

 

Returns

newly created strv


rm_strv_remove ()

gchar **
rm_strv_remove (gchar **strv,
                const gchar *str);

Remove str from strv

Parameters

strv

string vector

 

str

string to remove

 

Returns

newly created strv