Utilities — Assorted macros and functions
#define ADG_DIR_RIGHT #define ADG_DIR_DOWN #define ADG_DIR_LEFT #define ADG_DIR_UP #define ADG_FORWARD_DECL (id) gint adg_strcmp (const gchar *s1, const gchar *s2); gboolean adg_is_empty (const gchar *str); gboolean adg_enum_report_invalid (GType enum_type, int value);
#define ADG_FORWARD_DECL(id) typedef struct _##id id
Forward declaration of struct id. It is equivalent to a typical
struct forward declaration, for example:
ADG_FORWARD_DECL(test)
will expand to:
typedef struct _test test
This macro is needed to fake gtk-doc, because
up to now (v.1.12) it generates two conflicting links when using
forward declarations: the first in the source with the declaration
and the second where the type is defined. Using ADG_FORWARD_DECL()
instead of the usual typedef avoids the parsing of the declaration
in the first file (gtk-doc is not able to do C
preprocessing).
The same principle can be applied in the definition file. Following the previous example, you can use something like this where struct _type is defined:
#if 0
// This is declared in another file
typedef struct _type type;
#endif
struct _type {
...
};
|
|
The name of a struct |
gint adg_strcmp (const gchar *s1,
const gchar *s2);
A strcmp() function guarded against NULL values. If glib-2.16.0 or
greather is used, adg_strcmp() will be an alias for g_strcmp0.
Otherwise the function will behave in the same way as strcmp() with
the following exceptions:
s1 == NULL && s2 == NULL: returns 0;s1 == NULL: returns INT_MIN;s2 == NULL: returns INT_MAX.|
|
first string to compare |
|
|
second string to compare |
|
Returns : |
0 if s1 matches s2, a value less than 0 if s1 is less
than s2 or greather than 0 if s1 is greather than s2
|
gboolean adg_is_empty (const gchar *str);
Checks if str is an empty string, that is if is NULL or if
its first character is %'\0'.
|
|
the subject string |
|
Returns : |
TRUE if str is an empty string, FALSE otherwise
|
gboolean adg_enum_report_invalid (GType enum_type,
int value);
Checks if value is a valid enum_type value and generates
a warning if it is not a valid value.
|
|
a GEnum based type |
|
|
the enum value to check |
|
Returns : |
TRUE if value is invalid, FALSE if it is valid
|