Migrating docs.
[platform/upstream/glib.git] / gobject / gboxed.h
1 /* GObject - GLib Type, Object, Parameter and Signal Library
2  * Copyright (C) 2000-2001 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 #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
20 #error "Only <glib-object.h> can be included directly."
21 #endif
22
23 #ifndef __G_BOXED_H__
24 #define __G_BOXED_H__
25
26 #include        <gobject/gtype.h>
27
28 G_BEGIN_DECLS
29
30 /* --- type macros --- */
31 #define G_TYPE_IS_BOXED(type)      (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED)
32 #define G_VALUE_HOLDS_BOXED(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOXED))
33
34
35 /* --- typedefs --- */
36 /**
37  * GBoxedCopyFunc:
38  * @boxed: The boxed structure to be copied.
39  * 
40  * This function is provided by the user and should produce a copy of the passed
41  * in boxed structure.
42  * 
43  * Returns: The newly created copy of the boxed structure.
44  */
45 typedef gpointer (*GBoxedCopyFunc) (gpointer boxed);
46
47 /**
48  * GBoxedFreeFunc:
49  * @boxed: The boxed structure to be freed.
50  * 
51  * This function is provided by the user and should free the boxed
52  * structure passed.
53  */
54 typedef void (*GBoxedFreeFunc) (gpointer boxed);
55
56
57 /* --- prototypes --- */
58 gpointer        g_boxed_copy                    (GType           boxed_type,
59                                                  gconstpointer   src_boxed);
60 void            g_boxed_free                    (GType           boxed_type,
61                                                  gpointer        boxed);
62 void            g_value_set_boxed               (GValue         *value,
63                                                  gconstpointer   v_boxed);
64 void            g_value_set_static_boxed        (GValue         *value,
65                                                  gconstpointer   v_boxed);
66 gpointer        g_value_get_boxed               (const GValue   *value);
67 gpointer        g_value_dup_boxed               (const GValue   *value);
68
69
70 /* --- convenience --- */
71 GType   g_boxed_type_register_static            (const gchar    *name,
72                                                  GBoxedCopyFunc  boxed_copy,
73                                                  GBoxedFreeFunc  boxed_free);
74
75
76 /* --- GLib boxed types --- */
77 /**
78  * G_TYPE_CLOSURE:
79  * 
80  * The #GType for #GClosure.
81  */
82 #define G_TYPE_CLOSURE          (g_closure_get_type ())
83 /**
84  * G_TYPE_VALUE:
85  * 
86  * The type ID of the "GValue" type which is a boxed type,
87  * used to pass around pointers to GValues.
88  */
89 #define G_TYPE_VALUE            (g_value_get_type ())
90 /**
91  * G_TYPE_VALUE_ARRAY:
92  * 
93  * The type ID of the "GValueArray" type which is a boxed type,
94  * used to pass around pointers to GValueArrays.
95  */
96 #define G_TYPE_VALUE_ARRAY      (g_value_array_get_type ())
97 /**
98  * G_TYPE_DATE:
99  * 
100  * The #GType for #GDate.
101  */
102 #define G_TYPE_DATE             (g_date_get_type ())
103 /**
104  * G_TYPE_STRV:
105  * 
106  * The #GType for a boxed type holding a %NULL-terminated array of strings.
107  * 
108  * The code fragments in the following example show the use of a property of
109  * type #G_TYPE_STRV with g_object_class_install_property(), g_object_set()
110  * and g_object_get().
111  * 
112  * |[
113  * g_object_class_install_property (object_class,
114  *                                  PROP_AUTHORS,
115  *                                  g_param_spec_boxed ("authors",
116  *                                                      _("Authors"),
117  *                                                      _("List of authors"),
118  *                                                      G_TYPE_STRV,
119  *                                                      G_PARAM_READWRITE));
120  * 
121  * 
122  * gchar *authors[] = { "Owen", "Tim", NULL };
123  * g_object_set (obj, "authors", authors, NULL);
124  * 
125  * 
126  * gchar *writers[];
127  * g_object_get (obj, "authors", &amp;writers, NULL);
128  * // do something with writers
129  * g_strfreev (writers);
130  * ]|
131  * 
132  * Since: 2.4
133  */
134 #define G_TYPE_STRV             (g_strv_get_type ())
135 /**
136  * G_TYPE_GSTRING:
137  * 
138  * The #GType for #GString.
139  */
140 #define G_TYPE_GSTRING          (g_gstring_get_type ())
141 /**
142  * G_TYPE_HASH_TABLE:
143  * 
144  * The #GType for a boxed type holding a #GHashTable reference.
145  * 
146  * Since: 2.10
147  */
148 #define G_TYPE_HASH_TABLE (g_hash_table_get_type ())
149 /**
150  * G_TYPE_REGEX:
151  * 
152  * The #GType for a boxed type holding a #GRegex reference.
153  * 
154  * Since: 2.14
155  */
156 #define G_TYPE_REGEX (g_regex_get_type ())
157
158
159 void    g_value_take_boxed      (GValue         *value,
160                                  gconstpointer   v_boxed);
161 #ifndef G_DISABLE_DEPRECATED
162 void    g_value_set_boxed_take_ownership        (GValue         *value,
163                                                  gconstpointer   v_boxed);
164 #endif
165 GType   g_closure_get_type      (void)  G_GNUC_CONST;
166 GType   g_value_get_type        (void)  G_GNUC_CONST;
167 GType   g_value_array_get_type  (void)  G_GNUC_CONST;
168 GType   g_date_get_type         (void)  G_GNUC_CONST;
169 GType   g_strv_get_type         (void)  G_GNUC_CONST;
170 GType   g_gstring_get_type      (void)  G_GNUC_CONST;
171 GType   g_hash_table_get_type   (void)  G_GNUC_CONST;
172 GType   g_regex_get_type        (void)  G_GNUC_CONST;
173
174 /**
175  * GStrv:
176  * 
177  * A C representable type name for #G_TYPE_STRV.
178  */
179 typedef gchar** GStrv;
180      
181 G_END_DECLS
182
183 #endif  /* __G_BOXED_H__ */