egg-string
3
PACKAGEKIT Library

# egg-string

## Synopsis

    guint               egg_strlen                          (const gchar *text,
                                                             guint len);
    gboolean            egg_strzero                         (const gchar *text);
    gboolean            egg_strvequal                       (gchar **id1,
                                                             gchar **id2);
    gboolean            egg_strtoint                        (const gchar *text,
                                                             gint *value);
    gboolean            egg_strtouint                       (const gchar *text,
                                                             guint *value);
    gchar *             egg_strreplace                      (const gchar *text,
                                                             const gchar *find,
                                                             const gchar *replace);

## Description

## Details

### egg_strlen ()

    guint               egg_strlen                          (const gchar *text,
                                                             guint len);

This function is a much safer way of doing strlen as it checks for NULL and a stupidly long string.

`text` :

  The text to check

`len` :

  The maximum length of the string

Returns :

  the length of the string, or len if the string is too long.

### egg_strzero ()

    gboolean            egg_strzero                         (const gchar *text);

This function is a much safer way of doing "if (strlen (text) == 0))" as it does not rely on text being NULL terminated. It's also much quicker as it only checks the first byte rather than scanning the whole string just to verify it's not zero length.

`text` :

  The text to check

Returns :

  `TRUE` if the string was converted correctly

### egg_strvequal ()

    gboolean            egg_strvequal                       (gchar **id1,
                                                             gchar **id2);

This function will check to see if the GStrv arrays are string equal

`id1` :

  the first item of text to test

`id2` :

  the second item of text to test

Returns :

  `TRUE` if the arrays are the same, or are both `NULL`

### egg_strtoint ()

    gboolean            egg_strtoint                        (const gchar *text,
                                                             gint *value);

Converts a string into a signed integer value in a safe way.

`text` :

  The text the convert

`value` :

  The return numeric return value

Returns :

  `TRUE` if the string was converted correctly

### egg_strtouint ()

    gboolean            egg_strtouint                       (const gchar *text,
                                                             guint *value);

Converts a string into a unsigned integer value in a safe way.

`text` :

  The text the convert

`value` :

  The return numeric return value

Returns :

  `TRUE` if the string was converted correctly

### egg_strreplace ()

    gchar *             egg_strreplace                      (const gchar *text,
                                                             const gchar *find,
                                                             const gchar *replace);

Replaces chars in the text with a replacement. The `find` and `replace` variables to not have to be of the same length

`text` :

  The input text to make safe

`find` :

  What to search for

`replace` :

  What to replace with

Returns :

  the new string (copied)