Initial commit
[platform/upstream/glib2.0.git] / gobject / gvaluetypes.h
1 /* GObject - GLib Type, Object, Parameter and Signal Library
2  * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
3  *
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.
8  *
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.
13  *
14  * You should have received a copy of the GNU Lesser General
15  * Public License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
17  * Boston, MA 02111-1307, USA.
18  *
19  * gvaluetypes.h: GLib default values
20  */
21 #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
22 #error "Only <glib-object.h> can be included directly."
23 #endif
24
25 #ifndef __G_VALUETYPES_H__
26 #define __G_VALUETYPES_H__
27
28 #include        <gobject/gvalue.h>
29
30 G_BEGIN_DECLS
31
32 /* --- type macros --- */
33 /**
34  * G_VALUE_HOLDS_CHAR:
35  * @value: a valid #GValue structure
36  * 
37  * Checks whether the given #GValue can hold values of type %G_TYPE_CHAR.
38  * 
39  * Returns: %TRUE on success.
40  */
41 #define G_VALUE_HOLDS_CHAR(value)        (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_CHAR))
42 /**
43  * G_VALUE_HOLDS_UCHAR:
44  * @value: a valid #GValue structure
45  * 
46  * Checks whether the given #GValue can hold values of type %G_TYPE_UCHAR.
47  * 
48  * Returns: %TRUE on success.
49  */
50 #define G_VALUE_HOLDS_UCHAR(value)       (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UCHAR))
51 /**
52  * G_VALUE_HOLDS_BOOLEAN:
53  * @value: a valid #GValue structure
54  * 
55  * Checks whether the given #GValue can hold values of type %G_TYPE_BOOLEAN.
56  * 
57  * Returns: %TRUE on success.
58  */
59 #define G_VALUE_HOLDS_BOOLEAN(value)     (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOOLEAN))
60 /**
61  * G_VALUE_HOLDS_INT:
62  * @value: a valid #GValue structure
63  * 
64  * Checks whether the given #GValue can hold values of type %G_TYPE_INT.
65  * 
66  * Returns: %TRUE on success.
67  */
68 #define G_VALUE_HOLDS_INT(value)         (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT))
69 /**
70  * G_VALUE_HOLDS_UINT:
71  * @value: a valid #GValue structure
72  * 
73  * Checks whether the given #GValue can hold values of type %G_TYPE_UINT.
74  * 
75  * Returns: %TRUE on success.
76  */
77 #define G_VALUE_HOLDS_UINT(value)        (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT))
78 /**
79  * G_VALUE_HOLDS_LONG:
80  * @value: a valid #GValue structure
81  * 
82  * Checks whether the given #GValue can hold values of type %G_TYPE_LONG.
83  * 
84  * Returns: %TRUE on success.
85  */
86 #define G_VALUE_HOLDS_LONG(value)        (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_LONG))
87 /**
88  * G_VALUE_HOLDS_ULONG:
89  * @value: a valid #GValue structure
90  * 
91  * Checks whether the given #GValue can hold values of type %G_TYPE_ULONG.
92  * 
93  * Returns: %TRUE on success.
94  */
95 #define G_VALUE_HOLDS_ULONG(value)       (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ULONG))
96 /**
97  * G_VALUE_HOLDS_INT64:
98  * @value: a valid #GValue structure
99  * 
100  * Checks whether the given #GValue can hold values of type %G_TYPE_INT64.
101  * 
102  * Returns: %TRUE on success.
103  */
104 #define G_VALUE_HOLDS_INT64(value)       (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT64))
105 /**
106  * G_VALUE_HOLDS_UINT64:
107  * @value: a valid #GValue structure
108  * 
109  * Checks whether the given #GValue can hold values of type %G_TYPE_UINT64.
110  * 
111  * Returns: %TRUE on success.
112  */
113 #define G_VALUE_HOLDS_UINT64(value)      (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT64))
114 /**
115  * G_VALUE_HOLDS_FLOAT:
116  * @value: a valid #GValue structure
117  * 
118  * Checks whether the given #GValue can hold values of type %G_TYPE_FLOAT.
119  * 
120  * Returns: %TRUE on success.
121  */
122 #define G_VALUE_HOLDS_FLOAT(value)       (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLOAT))
123 /**
124  * G_VALUE_HOLDS_DOUBLE:
125  * @value: a valid #GValue structure
126  * 
127  * Checks whether the given #GValue can hold values of type %G_TYPE_DOUBLE.
128  * 
129  * Returns: %TRUE on success.
130  */
131 #define G_VALUE_HOLDS_DOUBLE(value)      (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_DOUBLE))
132 /**
133  * G_VALUE_HOLDS_STRING:
134  * @value: a valid #GValue structure
135  * 
136  * Checks whether the given #GValue can hold values of type %G_TYPE_STRING.
137  * 
138  * Returns: %TRUE on success.
139  */
140 #define G_VALUE_HOLDS_STRING(value)      (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_STRING))
141 /**
142  * G_VALUE_HOLDS_POINTER:
143  * @value: a valid #GValue structure
144  * 
145  * Checks whether the given #GValue can hold values of type %G_TYPE_POINTER.
146  * 
147  * Returns: %TRUE on success.
148  */
149 #define G_VALUE_HOLDS_POINTER(value)     (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_POINTER))
150 /**
151  * G_TYPE_GTYPE:
152  * 
153  * The type for #GType.
154  */
155 #define G_TYPE_GTYPE                     (g_gtype_get_type())
156 /**
157  * G_VALUE_HOLDS_GTYPE:
158  * @value: a valid #GValue structure
159  * 
160  * Checks whether the given #GValue can hold values of type %G_TYPE_GTYPE.
161  * 
162  * Since: 2.12
163  * Returns: %TRUE on success.
164  */
165 #define G_VALUE_HOLDS_GTYPE(value)       (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_GTYPE))
166
167
168 /* --- prototypes --- */
169 void                  g_value_set_char          (GValue       *value,
170                                                  gchar         v_char);
171 gchar                 g_value_get_char          (const GValue *value);
172 void                  g_value_set_uchar         (GValue       *value,
173                                                  guchar        v_uchar);
174 guchar                g_value_get_uchar         (const GValue *value);
175 void                  g_value_set_boolean       (GValue       *value,
176                                                  gboolean      v_boolean);
177 gboolean              g_value_get_boolean       (const GValue *value);
178 void                  g_value_set_int           (GValue       *value,
179                                                  gint          v_int);
180 gint                  g_value_get_int           (const GValue *value);
181 void                  g_value_set_uint          (GValue       *value,
182                                                  guint         v_uint);
183 guint                 g_value_get_uint          (const GValue *value);
184 void                  g_value_set_long          (GValue       *value,
185                                                  glong         v_long);
186 glong                 g_value_get_long          (const GValue *value);
187 void                  g_value_set_ulong         (GValue       *value,
188                                                  gulong        v_ulong);
189 gulong                g_value_get_ulong         (const GValue *value);
190 void                  g_value_set_int64         (GValue       *value,
191                                                  gint64        v_int64);
192 gint64                g_value_get_int64         (const GValue *value);
193 void                  g_value_set_uint64        (GValue       *value,
194                                                  guint64      v_uint64);
195 guint64               g_value_get_uint64        (const GValue *value);
196 void                  g_value_set_float         (GValue       *value,
197                                                  gfloat        v_float);
198 gfloat                g_value_get_float         (const GValue *value);
199 void                  g_value_set_double        (GValue       *value,
200                                                  gdouble       v_double);
201 gdouble               g_value_get_double        (const GValue *value);
202 void                  g_value_set_string        (GValue       *value,
203                                                  const gchar  *v_string);
204 void                  g_value_set_static_string (GValue       *value,
205                                                  const gchar  *v_string);
206 G_CONST_RETURN gchar* g_value_get_string        (const GValue *value);
207 gchar*                g_value_dup_string        (const GValue *value);
208 void                  g_value_set_pointer       (GValue       *value,
209                                                  gpointer      v_pointer);
210 gpointer              g_value_get_pointer       (const GValue *value);
211 GType                 g_gtype_get_type          (void);
212 void                  g_value_set_gtype         (GValue       *value,
213                                                  GType         v_gtype);
214 GType                 g_value_get_gtype         (const GValue *value);
215
216
217 /* Convenience for registering new pointer types */
218 GType                 g_pointer_type_register_static (const gchar *name);
219
220 /* debugging aid, describe value contents as string */
221 gchar*                g_strdup_value_contents   (const GValue *value);
222
223
224 void g_value_take_string                        (GValue            *value,
225                                                  gchar             *v_string);
226 #ifndef G_DISABLE_DEPRECATED
227 void g_value_set_string_take_ownership          (GValue            *value,
228                                                  gchar             *v_string);
229 #endif
230
231
232 /* humpf, need a C representable type name for G_TYPE_STRING */
233 /**
234  * gchararray:
235  * 
236  * A C representable type name for #G_TYPE_STRING.
237  */
238 typedef gchar* gchararray;
239
240
241 G_END_DECLS
242
243 #endif /* __G_VALUETYPES_H__ */