changed prototype of g_boxed_type_register_static() to contain an optional
[platform/upstream/glib.git] / docs / reference / glib / tmpl / strings.sgml
1 <!-- ##### SECTION Title ##### -->
2 Strings
3
4 <!-- ##### SECTION Short_Description ##### -->
5 text buffers which grow automatically as text is added.
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 A #GString is similar to a standard C string, except that it grows
10 automatically as text is appended or inserted.
11 </para>
12 <para>
13 The space allocated for the string is always a power of two, so as the
14 string grows it will occupy 2, 4, 8, 16, 32, 64, 128 etc. characters.
15 </para>
16
17 <!-- ##### SECTION See_Also ##### -->
18 <para>
19
20 </para>
21
22 <!-- ##### STRUCT GString ##### -->
23 <para>
24 The #GString struct contains the public fields of a #GString.
25 The <structfield>str</structfield> field points to the character data.
26 It may move as text is added.
27 The <structfield>len</structfield> field contains the length of the string,
28 not including the terminating null character.
29 </para>
30 <para>
31 The str field is zero-terminated and so can be used as an ordinary C
32 string. But it may be moved when text is appended or inserted into the
33 string.
34 </para>
35
36 @str: 
37 @len: 
38
39 <!-- ##### FUNCTION g_string_new ##### -->
40 <para>
41 Creates a new #GString, initialized with the given string.
42 </para>
43
44 @init: the initial text to copy into the string.
45 @Returns: the new #GString.
46
47
48 <!-- ##### FUNCTION g_string_new_len ##### -->
49 <para>
50
51 </para>
52
53 @init: 
54 @len: 
55 @Returns: 
56
57
58 <!-- ##### FUNCTION g_string_sized_new ##### -->
59 <para>
60 Creates a new GString, with enough space for @dfl_size characters.
61 This is useful if you are going to add a lot of text to the string and
62 don't want it to be reallocated too often.
63 </para>
64
65 @dfl_size: the default size of the space allocated to hold the string.
66 @Returns: the new #GString.
67
68
69 <!-- ##### FUNCTION g_string_assign ##### -->
70 <para>
71 Copies the characters from one #GString into another, destroying any previous
72 contents. It is rather like the standard strcpy() function, except that
73 you do not have to worry about having enough space to copy the string.
74 </para>
75
76 @string: the destination #GString. Its current contents are destroyed.
77 @rval: the source #GString.
78 @Returns: the destination #GString.
79
80
81 <!-- ##### MACRO g_string_sprintf ##### -->
82 <para>
83 Writes a formatted string into a #GString.
84 This is similar to the standard <function>sprintf()</function> function,
85 except that the GString buffer automatically expands to contain the results.
86 The previous contents of the GString are destroyed.
87 </para>
88
89 <!-- # Unused Parameters # -->
90 @string: a #GString.
91 @format: the string format. See the <function>sprintf()</function>
92 documentation.
93 @Varargs: the parameters to insert into the format string.
94
95
96 <!-- ##### MACRO g_string_sprintfa ##### -->
97 <para>
98 Appends a formatted string onto the end of a #GString.
99 This function is is similar to g_string_sprintf() except that
100 the text is appended to the GString.
101 </para>
102
103 <!-- # Unused Parameters # -->
104 @string: a #GString.
105 @format: the string format. See the <function>sprintf()</function>
106 documentation.
107 @Varargs: the parameters to insert into the format string.
108
109
110 <!-- ##### FUNCTION g_string_append ##### -->
111 <para>
112 Adds a string onto the end of a #GString, expanding it if necessary.
113 </para>
114
115 @string: a #GString.
116 @val: the string to append onto the end of the #GString.
117 @Returns: the #GString.
118
119
120 <!-- ##### FUNCTION g_string_append_c ##### -->
121 <para>
122 Adds a character onto the end of a #GString, expanding it if necessary.
123 </para>
124
125 @string: a #GString.
126 @c: the character to append onto the end of the #GString.
127 @Returns: the #GString.
128
129
130 <!-- ##### FUNCTION g_string_append_len ##### -->
131 <para>
132
133 </para>
134
135 @string: 
136 @val: 
137 @len: 
138 @Returns: 
139
140
141 <!-- ##### FUNCTION g_string_prepend ##### -->
142 <para>
143 Adds a string on to the start of a #GString, expanding it if necessary.
144 </para>
145
146 @string: a #GString.
147 @val: the string to prepend on the start of the #GString.
148 @Returns: the #GString.
149
150
151 <!-- ##### FUNCTION g_string_prepend_c ##### -->
152 <para>
153 Adds a character onto the start of a #GString, expanding it if necessary.
154 </para>
155
156 @string: a #GString.
157 @c: the character to prepend on the start of the #GString.
158 @Returns: the #GString.
159
160
161 <!-- ##### FUNCTION g_string_prepend_len ##### -->
162 <para>
163
164 </para>
165
166 @string: 
167 @val: 
168 @len: 
169 @Returns: 
170
171
172 <!-- ##### FUNCTION g_string_insert ##### -->
173 <para>
174 Inserts a copy of a string into a #GString, expanding it if necessary.
175 </para>
176
177 @string: a #GString.
178 @pos: the position to insert the copy of the string.
179 @val: the string to insert.
180 @Returns: the #GString.
181
182
183 <!-- ##### FUNCTION g_string_insert_c ##### -->
184 <para>
185 Inserts a character into a #GString, expanding it if necessary.
186 </para>
187
188 @string: a #GString.
189 @pos: the position to insert the character.
190 @c: the character to insert.
191 @Returns: the #GString.
192
193
194 <!-- ##### FUNCTION g_string_insert_len ##### -->
195 <para>
196
197 </para>
198
199 @string: 
200 @pos: 
201 @val: 
202 @len: 
203 @Returns: 
204
205
206 <!-- ##### FUNCTION g_string_erase ##### -->
207 <para>
208 Removes @len characters from a #GString, starting at position @pos.
209 The rest of the #GString is shifted down to fill the gap.
210 </para>
211
212 @string: a #GString.
213 @pos: the position of the characters to remove.
214 @len: the number of characters to remove.
215 @Returns: the #GString.
216
217
218 <!-- ##### FUNCTION g_string_truncate ##### -->
219 <para>
220 Cuts off the end of the GString, leaving the first @len characters.
221 </para>
222
223 @string: a #GString.
224 @len: the new size of the #GString.
225 @Returns: the #GString.
226
227
228 <!-- ##### FUNCTION g_string_free ##### -->
229 <para>
230 Frees the memory allocated for the #GString.
231 If free_segment is TRUE it also frees the character data.
232 </para>
233
234 @string: a #GString.
235 @free_segment: if TRUE the actual character data is freed as well.
236 @Returns: 
237
238
239 <!-- ##### FUNCTION g_string_up ##### -->
240 <para>
241 Converts a #GString to upper case.
242 </para>
243
244 @string: a #GString.
245 @Returns: the #GString.
246
247
248 <!-- ##### FUNCTION g_string_down ##### -->
249 <para>
250 Converts a #GString to lower case.
251 </para>
252
253 @string: a #GString.
254 @Returns: the #GString.
255
256
257 <!-- ##### FUNCTION g_string_hash ##### -->
258 <para>
259
260 </para>
261
262 @str: 
263 @Returns: 
264
265
266 <!-- ##### FUNCTION g_string_equal ##### -->
267 <para>
268
269 </para>
270
271 @v: 
272 @v2: 
273 @Returns: 
274
275