1
1
<!-- ##### SECTION Title ##### -->
4
4
<!-- ##### SECTION Short_Description ##### -->
5
A mechanism to wrap opaque C structures registered by the type system
7
7
<!-- ##### SECTION Long_Description ##### -->
9
GBoxed is a generic wrapper mechanism for arbitrary C structures. The only
10
thing the type system needs to know about the structures is how to copy and
11
free them, beyond that they are treated as opaque chunks of memory.
14
Boxed types are useful for simple value-holder structures like rectangles or
15
points. They can also be used for wrapping structures defined in non-GObject
19
13
<!-- ##### SECTION See_Also ##### -->
21
#GParamSpecBoxed, g_param_spec_boxed()
24
19
<!-- ##### SECTION Stability_Level ##### -->
27
22
<!-- ##### USER_FUNCTION GBoxedCopyFunc ##### -->
29
This function is provided by the user and should produce a copy of the passed
33
@boxed: The boxed structure to be copied.
34
@Returns: The newly created copy of the boxed structure.
37
31
<!-- ##### USER_FUNCTION GBoxedFreeFunc ##### -->
39
This function is provided by the user and should free the boxed
43
@boxed: The boxed structure to be freed.
46
39
<!-- ##### FUNCTION g_boxed_copy ##### -->
48
Provide a copy of a boxed structure @src_boxed which is of type @boxed_type.
51
@boxed_type: The type of @src_boxed.
52
@src_boxed: The boxed structure to be copied.
53
@Returns: The newly created copy of the boxed structure.
56
49
<!-- ##### FUNCTION g_boxed_free ##### -->
58
Free the boxed structure @boxed which is of type @boxed_type.
61
@boxed_type: The type of @boxed.
62
@boxed: The boxed structure to be freed.
65
58
<!-- ##### FUNCTION g_boxed_type_register_static ##### -->
67
This function creates a new %G_TYPE_BOXED derived type id for a new
68
boxed type with name @name. Boxed type handling functions have to be
69
provided to copy and free opaque boxed structures of this type.
72
@name: Name of the new boxed type.
73
@boxed_copy: Boxed structure copy function.
74
@boxed_free: Boxed structure free function.
75
@Returns: New %G_TYPE_BOXED derived type id for @name.
78
69
<!-- ##### FUNCTION g_pointer_type_register_static ##### -->
80
Creates a new %G_TYPE_POINTER derived type id for a new
81
pointer type with name @name.
84
@name: the name of the new pointer type.
85
@Returns: a new %G_TYPE_POINTER derived type id for @name.
88
78
<!-- ##### MACRO G_TYPE_HASH_TABLE ##### -->
90
The #GType for a boxed type holding a #GHashTable reference.
96
85
<!-- ##### MACRO G_TYPE_DATE ##### -->
98
The #GType for #GDate.
103
92
<!-- ##### MACRO G_TYPE_GSTRING ##### -->
105
The #GType for #GString.
110
99
<!-- ##### MACRO G_TYPE_STRV ##### -->
112
The #GType for a boxed type holding a %NULL-terminated array of strings.
115
The code fragments in the following example show the use of a property of
116
type #G_TYPE_STRV with g_object_class_install_property(), g_object_set()
119
<informalexample><programlisting>
120
g_object_class_install_property (object_class,
122
g_param_spec_boxed ("authors",
124
_("List of authors"),
129
gchar *authors[] = { "Owen", "Tim", NULL };
130
g_object_set (obj, "authors", authors, NULL);
134
g_object_get (obj, "authors", &writers, NULL);
135
/* do something with writers */
136
g_strfreev (writers);
137
</programlisting></informalexample>
142
106
<!-- ##### MACRO G_TYPE_REGEX ##### -->
144
The #GType for a boxed type holding a #GRegex reference.
150
113
<!-- ##### TYPEDEF GStrv ##### -->
152
A C representable type name for #G_TYPE_STRV.