Remove references to nonexisting functions
[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 automatically
10 as text is appended or inserted. Also, it stores the length of the string, so
11 can be used for binary data with embedded nul bytes.
12 </para>
13
14 <!-- ##### SECTION See_Also ##### -->
15 <para>
16
17 </para>
18
19 <!-- ##### STRUCT GString ##### -->
20 <para>
21 The #GString struct contains the public fields of a #GString.
22 The <structfield>str</structfield> field points to the character data.
23 It may move as text is added.
24 The <structfield>len</structfield> field contains the length of the string,
25 not including the terminating nul character.
26 </para>
27 <para>
28 The <structfield>str</structfield> field is nul-terminated and so can be used as an ordinary C
29 string. But it may be moved when text is appended or inserted into the
30 string.
31 </para>
32
33 @str: 
34 @len: 
35 @allocated_len: 
36
37 <!-- ##### FUNCTION g_string_new ##### -->
38 <para>
39 Creates a new #GString, initialized with the given string.
40 </para>
41
42 @init: the initial text to copy into the string.
43 @Returns: the new #GString.
44
45
46 <!-- ##### FUNCTION g_string_new_len ##### -->
47 <para>
48 Creates a new #GString with @len bytes of the @init buffer.  Because a length is
49 provided, @init need not be nul-terminated, and can contain embedded nul bytes.
50 </para>
51
52 @init: initial contents of string.
53 @len: length of @init to use.
54 @Returns: a new #GString.
55
56
57 <!-- ##### FUNCTION g_string_sized_new ##### -->
58 <para>
59 Creates a new #GString, with enough space for @dfl_size characters.
60 This is useful if you are going to add a lot of text to the string and
61 don't want it to be reallocated too often.
62 </para>
63
64 @dfl_size: the default size of the space allocated to hold the string.
65 @Returns: the new #GString.
66
67
68 <!-- ##### FUNCTION g_string_assign ##### -->
69 <para>
70 Copies the characters from a string into a #GString, destroying any previous
71 contents. It is rather like the standard <function>strcpy()</function> function, except that
72 you do not have to worry about having enough space to copy the string.
73 </para>
74
75 @string: the destination #GString. Its current contents are destroyed.
76 @rval: 
77 @Returns: the destination #GString.
78 <!-- # Unused Parameters # -->
79 @val: the string to copy into @string.
80
81
82 <!-- ##### MACRO g_string_sprintf ##### -->
83 <para>
84 Writes a formatted string into a #GString.
85 This is similar to the standard <function>sprintf()</function> function,
86 except that the #GString buffer automatically expands to contain the results.
87 The previous contents of the #GString are destroyed. This
88 function has been renamaed to g_string_printf().
89 </para>
90
91 <!-- # Unused Parameters # -->
92 @string: a #GString.
93 @format: the string format. See the <function>sprintf()</function>
94 documentation.
95 @Varargs: the parameters to insert into the format string.
96
97
98 <!-- ##### MACRO g_string_sprintfa ##### -->
99 <para>
100 Appends a formatted string onto the end of a #GString.
101 This function is is similar to g_string_sprintf() except that
102 the text is appended to the #GString. The function has been
103 renamed to g_string_append_printf().
104 </para>
105
106 <!-- # Unused Parameters # -->
107 @string: a #GString.
108 @format: the string format. See the <function>sprintf()</function>
109 documentation.
110 @Varargs: the parameters to insert into the format string.
111
112
113 <!-- ##### FUNCTION g_string_printf ##### -->
114 <para>
115 Writes a formatted string into a #GString.
116 This is similar to the standard <function>sprintf()</function> function,
117 except that the #GString buffer automatically expands to contain the results.
118 The previous contents of the #GString are destroyed.
119 </para>
120
121 @string: a #GString.
122 @format: the string format. See the <function>printf()</function>
123 documentation.
124 @Varargs: the parameters to insert into the format string.
125
126
127 <!-- ##### FUNCTION g_string_append_printf ##### -->
128 <para>
129 Appends a formatted string onto the end of a #GString.
130 This function is is similar to g_string_printf() except that
131 the text is appended to the #GString.
132 </para>
133
134 @string: a #GString.
135 @format: the string format. See the <function>printf()</function>
136 documentation.
137 @Varargs: the parameters to insert into the format string.
138
139
140 <!-- ##### FUNCTION g_string_append ##### -->
141 <para>
142 Adds a string onto the end of a #GString, expanding it if necessary.
143 </para>
144
145 @string: a #GString.
146 @val: the string to append onto the end of the #GString.
147 @Returns: the #GString.
148
149
150 <!-- ##### FUNCTION g_string_append_c ##### -->
151 <para>
152 Adds a character onto the end of a #GString, expanding it if necessary.
153 </para>
154
155 @string: a #GString.
156 @c: the character to append onto the end of the #GString.
157 @Returns: the #GString.
158
159
160 <!-- ##### FUNCTION g_string_append_unichar ##### -->
161 <para>
162
163 </para>
164
165 @string: 
166 @wc: 
167 @Returns: 
168
169
170 <!-- ##### FUNCTION g_string_append_len ##### -->
171 <para>
172 Appends @len bytes of @val to @string. Because @len is provided, 
173 @val may contain embedded nuls and need not be nul-terminated.
174 </para>
175
176 @string: a #GString.
177 @val: bytes to append.
178 @len: number of bytes of @val to use.
179 @Returns: the #GString.
180
181
182 <!-- ##### FUNCTION g_string_prepend ##### -->
183 <para>
184 Adds a string on to the start of a #GString, expanding it if necessary.
185 </para>
186
187 @string: a #GString.
188 @val: the string to prepend on the start of the #GString.
189 @Returns: the #GString.
190
191
192 <!-- ##### FUNCTION g_string_prepend_c ##### -->
193 <para>
194 Adds a character onto the start of a #GString, expanding it if necessary.
195 </para>
196
197 @string: a #GString.
198 @c: the character to prepend on the start of the #GString.
199 @Returns: the #GString.
200
201
202 <!-- ##### FUNCTION g_string_prepend_unichar ##### -->
203 <para>
204
205 </para>
206
207 @string: 
208 @wc: 
209 @Returns: 
210
211
212 <!-- ##### FUNCTION g_string_prepend_len ##### -->
213 <para>
214 Prepends @len bytes of @val to @string. Because @len is provided, 
215 @val may contain embedded nuls and need not be nul-terminated.
216 </para>
217
218 @string: a #GString.
219 @val: bytes to prepend.
220 @len: number of bytes in @val to prepend.
221 @Returns: the #GString passed in.
222
223
224 <!-- ##### FUNCTION g_string_insert ##### -->
225 <para>
226 Inserts a copy of a string into a #GString, expanding it if necessary.
227 </para>
228
229 @string: a #GString.
230 @pos: the position to insert the copy of the string.
231 @val: the string to insert.
232 @Returns: the #GString.
233
234
235 <!-- ##### FUNCTION g_string_insert_c ##### -->
236 <para>
237 Inserts a character into a #GString, expanding it if necessary.
238 </para>
239
240 @string: a #GString.
241 @pos: the position to insert the character.
242 @c: the character to insert.
243 @Returns: the #GString.
244
245
246 <!-- ##### FUNCTION g_string_insert_unichar ##### -->
247 <para>
248
249 </para>
250
251 @string: 
252 @pos: 
253 @wc: 
254 @Returns: 
255
256
257 <!-- ##### FUNCTION g_string_insert_len ##### -->
258 <para>
259 Inserts @len bytes of @val into @string at @pos.  Because @len is provided, @val
260  may contain embedded nuls and need not be nul-terminated. If @pos is -1, bytes are inserted at the end of the string.
261 </para>
262
263 @string: a #GString.
264 @pos: position in @string where insertion should happen, or -1 for at the end.
265 @val: bytes to insert.
266 @len: number of bytes of @val to insert.
267 @Returns: the #GString.
268
269
270 <!-- ##### FUNCTION g_string_erase ##### -->
271 <para>
272 Removes @len characters from a #GString, starting at position @pos.
273 The rest of the #GString is shifted down to fill the gap.
274 </para>
275
276 @string: a #GString.
277 @pos: the position of the characters to remove.
278 @len: the number of characters to remove, or -1 to remove all
279       following characters.
280 @Returns: the #GString.
281
282
283 <!-- ##### FUNCTION g_string_truncate ##### -->
284 <para>
285 Cuts off the end of the GString, leaving the first @len characters.
286 </para>
287
288 @string: a #GString.
289 @len: the new size of the #GString.
290 @Returns: the #GString.
291
292
293 <!-- ##### FUNCTION g_string_set_size ##### -->
294 <para>
295
296 </para>
297
298 @string: 
299 @len: 
300 @Returns: 
301
302
303 <!-- ##### FUNCTION g_string_free ##### -->
304 <para>
305 Frees the memory allocated for the #GString.
306 If @free_segment is %TRUE it also frees the character data.
307 </para>
308
309 @string: a #GString.
310 @free_segment: if %TRUE the actual character data is freed as well.
311 @Returns: 
312
313
314 <!-- ##### FUNCTION g_string_up ##### -->
315 <para>
316 Converts a #GString to upper case.
317 </para>
318
319 @string: a #GString.
320 @Returns: the #GString.
321
322
323 <!-- ##### FUNCTION g_string_down ##### -->
324 <para>
325 Converts a #GString to lower case.
326 </para>
327
328 @string: a #GString.
329 @Returns: the #GString.
330
331
332 <!-- ##### FUNCTION g_string_hash ##### -->
333 <para>
334 Creates a hash code for @str; for use with #GHashTable.
335 </para>
336
337 @str: a string to hash.
338 @Returns: hash code for @str.
339
340
341 <!-- ##### FUNCTION g_string_equal ##### -->
342 <para>
343 Compares two strings for equality, returning %TRUE if they are equal. 
344 For use with #GHashTable.
345 </para>
346
347 @v: a #GString.
348 @v2: another #GString.
349 @Returns: %TRUE if they strings are the same length and contain the same bytes.
350
351