289edd70afbf01b5ceb18dad904dbd442aac9414
[platform/upstream/glib.git] / docs / reference / gobject / tmpl / gboxed.sgml
1 <!-- ##### SECTION Title ##### -->
2 GBoxed
3
4 <!-- ##### SECTION Short_Description ##### -->
5 A mechanism to wrap opaque C structures registered by the type system
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9
10 </para>
11
12 <!-- ##### SECTION See_Also ##### -->
13 <para>
14 #GParamSpecBoxed, g_param_spec_boxed()
15 </para>
16
17 <!-- ##### USER_FUNCTION GBoxedCopyFunc ##### -->
18 <para>
19 This function is provided by the user and should produce a copy of the passed
20 in boxed structure.
21 </para>
22
23 @boxed:   The boxed structure to be copied.
24 @Returns: The newly created copy of the boxed structure.
25
26
27 <!-- ##### USER_FUNCTION GBoxedFreeFunc ##### -->
28 <para>
29 This function is provided by the user and should free the boxed
30 structure passed.
31 </para>
32
33 @boxed: The boxed structure to be freed.
34
35
36 <!-- ##### FUNCTION g_boxed_copy ##### -->
37 <para>
38 Provide a copy of a boxed structure @src_boxed which is of type @boxed_type.
39 </para>
40
41 @boxed_type: The type of @src_boxed.
42 @src_boxed:  The boxed structure to be copied.
43 @Returns:    The newly created copy of the boxed structure.
44
45
46 <!-- ##### FUNCTION g_boxed_free ##### -->
47 <para>
48 Free the boxed structure @boxed which is of type @boxed_type.
49 </para>
50
51 @boxed_type: The type of @boxed.
52 @boxed:      The boxed structure to be freed.
53
54
55 <!-- ##### FUNCTION g_boxed_type_register_static ##### -->
56 <para>
57 This function creates a new %G_TYPE_BOXED derived type id for a new
58 boxed type with name @name. Boxed type handling functions have to be
59 provided to copy and free opaque boxed structures of this type.
60 </para>
61
62 @name: Name of the new boxed type.
63 @boxed_copy: Boxed structure copy function.
64 @boxed_free: Boxed structure free function.
65 @Returns: New %G_TYPE_BOXED derived type id for @name.
66
67
68 <!-- ##### FUNCTION g_pointer_type_register_static ##### -->
69 <para>
70 Creates a new %G_TYPE_POINTER derived type id for a new
71 pointer type with name @name. 
72 </para>
73
74 @name: the name of the new pointer type.
75 @Returns: a new %G_TYPE_POINTER derived type id for @name.
76
77
78 <!-- ##### MACRO G_TYPE_GSTRING ##### -->
79 <para>
80 The #GType for #GString.
81 </para>
82
83
84
85 <!-- ##### MACRO G_TYPE_STRV ##### -->
86 <para>
87 The #GType for a boxed type holding a %NULL-terminated array of strings.
88 </para>
89 <para>
90 The code fragments in the following example show the use of a property of
91 type #G_TYPE_STRV with g_object_class_install_property(), g_object_set()
92 and g_object_get().
93 </para>
94 <informalexample><programlisting>
95 g_object_class_install_property (object_class,
96                                  PROP_AUTHORS,
97                                  g_param_spec_boxed ("authors",
98                                                      _("Authors"),
99                                                      _("List of authors"),
100                                                      G_TYPE_STRV,
101                                                      G_PARAM_READWRITE));
102
103
104 gchar *authors[] = { "Owen", "Tim", NULL };
105 g_object_set (obj, "authors", authors, NULL);
106
107
108 gchar *writers[];
109 g_object_get (obj, "authors", &amp;writers, NULL);
110 /* do something with writers */
111 g_strfreev (writers);
112 </programlisting></informalexample>
113
114 @Since: 2.4
115
116 <!-- ##### TYPEDEF GStrv ##### -->
117 <para>
118 A C representable type name for #G_TYPE_STRV.
119 </para>
120