1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009,2010 Nicola Fontana <ntd at entidi.it>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
23 * @Section_Id:utilities
25 * @short_description: Assorted macros and functions
27 * Collection of macros and functions that do not fit inside any other topic.
33 * Symbolic constant for the right direction (in radians).
39 * Symbolic constant for the down direction (in radians).
45 * Symbolic constant for the left direction (in radians).
51 * Symbolic constant for the up direction (in radians).
56 * @id: The name of a struct
58 * Forward declaration of struct @id. It is equivalent to a typical
59 * struct forward declaration, for example:
62 * ADG_FORWARD_DECL(test)
68 * typedef struct _test test
71 * This macro is needed to fake <command>gtk-doc</command>, because
72 * up to now (v.1.12) it generates two conflicting links when using
73 * forward declarations: the first in the source with the declaration
74 * and the second where the type is defined. Using ADG_FORWARD_DECL()
75 * instead of the usual typedef avoids the parsing of the declaration
76 * in the first file (<command>gtk-doc</command> is not able to do C
79 * The same principle can be applied in the definition file. Following
80 * the previous example, you can use something like this where struct
85 * // This is declared in another file
86 * typedef struct _type type;
95 #include "adg-internal.h"
101 #if GLIB_CHECK_VERSION(2, 16, 0)
105 * @s1: first string to compare
106 * @s2: second string to compare
108 * A strcmp() function guarded against %NULL values. If glib-2.16.0 or
109 * greather is used, adg_strcmp() will be an alias for g_strcmp0.
110 * Otherwise the function will behave in the same way as strcmp() with
111 * the following exceptions:
114 * <listitem><code>s1 == NULL && s2 == NULL</code>: returns %0;</listitem>
115 * <listitem><code>s1 == NULL</code>: returns %INT_MIN;</listitem>
116 * <listitem><code>s2 == NULL</code>: returns %INT_MAX.</listitem>
119 * Returns: %0 if @s1 matches @s2, a value less than %0 if @s1 is less
120 * than @s2 or greather than %0 if @s1 is greather than @s2
123 adg_strcmp(const gchar
*s1
, const gchar
*s2
)
125 /* This will also catch the NULL == NULL case */
135 return strcmp(s1
, s2
);
141 * @str: the subject string
143 * Checks if @str is an empty string, that is if is %NULL or if
144 * its first character is %'\0'.
146 * Returns: %TRUE if @str is an empty string, %FALSE otherwise
149 adg_is_empty(const gchar
*str
)
151 return str
== NULL
|| str
[0] == '\0';