Synopsis

#include <adg-1/adg.h>

#define             ADG_DIR_RIGHT
#define             ADG_DIR_DOWN
#define             ADG_DIR_LEFT
#define             ADG_DIR_UP
#define             ADG_UTF8_DIAMETER
#define             ADG_UTF8_DEGREE
gint                g_strcmp0                           (const gchar *s1,
                                                         const gchar *s2);
gboolean            adg_is_string_empty                 (const gchar *str);
gboolean            adg_is_enum_value                   (int value,
                                                         GType enum_type);
gboolean            adg_is_boolean_value                (gboolean value);
gchar *             adg_string_replace                  (const gchar *str,
                                                         const gchar *from,
                                                         const gchar *to);
gchar *             adg_find_file                       (const gchar *file,
                                                         ...);
gdouble             adg_scale_factor                    (const gchar *scale);

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

Since 1.0


ADG_DIR_DOWN

#define ADG_DIR_DOWN            G_PI_2

Symbolic constant for the down direction (in radians).

Since 1.0


ADG_DIR_LEFT

#define ADG_DIR_LEFT            G_PI

Symbolic constant for the left direction (in radians).

Since 1.0


ADG_DIR_UP

#define ADG_DIR_UP              -G_PI_2

Symbolic constant for the up direction (in radians).

Since 1.0


ADG_UTF8_DIAMETER

#define ADG_UTF8_DIAMETER       "\xE2\x8C\x80"

String constant that embeds a UTF-8 encoded diameter (U+2300). It can be used to prefix diameter quotes, such as:

Since 1.0


ADG_UTF8_DEGREE

#define ADG_UTF8_DEGREE         "\xC2\xB0"

String constant that embeds a UTF-8 encoded degree symbol (U+00B0). It is used to suffix by the default implementation of AdgADim to suffix the set value, but can be also used manually:

Since 1.0


g_strcmp0 ()

gint                g_strcmp0                           (const gchar *s1,
                                                         const gchar *s2);

Compares s1 and s2 like strcmp(). Handles NULL gracefully by sorting it before non-NULL strings. This is a backward compatibility fallback for GLib prior to 2.16.0

s1 :

a C string or NULL

s2 :

another C string or NULL

Returns :

-1, 0 or 1, if s1 is <, == or > than s2.

Since 1.0


adg_is_string_empty ()

gboolean            adg_is_string_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

Since 1.0


adg_is_enum_value ()

gboolean            adg_is_enum_value                   (int value,
                                                         GType enum_type);

Checks if value is a valid enum_type value.

value :

the enum value to check

enum_type :

a GEnum based type

Returns :

TRUE if value is a valid enum_type, FALSE otherwise

Since 1.0


adg_is_boolean_value ()

gboolean            adg_is_boolean_value                (gboolean value);

Checks if value is a valid gboolean value, that is if it is TRUE or FALSE. No other values are accepted.

value :

the gboolean value to check

Returns :

TRUE if value is a valid gboolean, FALSE otherwise

Since 1.0


adg_string_replace ()

gchar *             adg_string_replace                  (const gchar *str,
                                                         const gchar *from,
                                                         const gchar *to);

Replaces from with to inside str and returns the result as a newly allocated string.

str and from must be non-null valid C strings while to can be NULL, in which case an empty string ("") will be implied.

str :

the original string

from :

the substring to replace

to :

the replacement string

Returns :

a newly allocated string to be freed with g_free() or NULL on errors

Since 1.0


adg_find_file ()

gchar *             adg_find_file                       (const gchar *file,
                                                         ...);

Searches file in the provided paths and returns the full path to the first existing match. The check is performed using g_file_test() with the G_FILE_TEST_EXISTS test.

This function has been picked up from the ntdisp project: http://dev.entidi.com/p/ntdisp/

file :

the file to search

... :

a NULL terminated list of paths where to look for file existence.

Returns :

a newly allocated string containing the path or NULL on errors. Free it with g_free() when no longer needed.

Since 1.0


adg_scale_factor ()

gdouble             adg_scale_factor                    (const gchar *scale);

Converts a scale in the form x:y (where x and y are respectively two positive integers representing the numerator and denominator of a fraction) into its approximate double representation. Any garbage following x or y will be silently ignored, meaning that x+garbage:y+garbage is equivalent to x:y. Furthermore, the postfix :y can be omitted, in which case (double) x will be returned.

x and y are converted by using atoi(), so refer to your C library documentation for details on the algorithm used.

scale :

a string identifying the scale

Returns :

the (possibly approximated) double conversion of scale or 0 on errors.