Utilities

Utilities — Assorted macros and functions

Synopsis

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

Description

Collection of macros and functions that do not fit inside any other topic.

Details

ADG_DIR_RIGHT

#define ADG_DIR_RIGHT           0.

Symbolic constant for the right direction (in radians).


ADG_DIR_DOWN

#define ADG_DIR_DOWN            M_PI_2

Symbolic constant for the down direction (in radians).


ADG_DIR_LEFT

#define ADG_DIR_LEFT            M_PI

Symbolic constant for the left direction (in radians).


ADG_DIR_UP

#define ADG_DIR_UP              (M_PI_2 * 3.)

Symbolic constant for the up direction (in radians).


ADG_FORWARD_DECL()

#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 {
...
};

id :

The name of a struct

adg_strcmp ()

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.

s1 :

first string to compare

s2 :

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

adg_is_empty ()

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'.

str :

the subject string

Returns :

TRUE if str is an empty string, FALSE otherwise

adg_enum_report_invalid ()

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.

enum_type :

a GEnum based type

value :

the enum value to check

Returns :

TRUE if value is invalid, FALSE if it is valid
Utilities was last modified by gtk-doc on Sun 21 Feb 2010 10:22:18 PM CET
Hosted by Get Automatic Drawing Generation at SourceForge.net. Fast, secure and Free Open Source software downloads
Search on this domain