This time the right fix.
[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_sized_new ##### -->
49 <para>
50 Creates a new GString, with enough space for @dfl_size characters.
51 This is useful if you are going to add a lot of text to the string and
52 don't want it to be reallocated too often.
53 </para>
54
55 @dfl_size: the default size of the space allocated to hold the string.
56 @Returns: the new #GString.
57
58
59 <!-- ##### FUNCTION g_string_assign ##### -->
60 <para>
61 Copies the characters from one #GString into another, destroying any previous
62 contents. It is rather like the standard strcpy() function, except that
63 you do not have to worry about having enough space to copy the string.
64 </para>
65
66 @string: the destination #GString. Its current contents are destroyed.
67 @rval: the source #GString.
68 @Returns: the destination #GString.
69
70
71 <!-- ##### FUNCTION g_string_sprintf ##### -->
72 <para>
73 Writes a formatted string into a #GString.
74 This is similar to the standard <function>sprintf()</function> function,
75 except that the GString buffer automatically expands to contain the results.
76 The previous contents of the GString are destroyed.
77 </para>
78
79 @string: a #GString.
80 @format: the string format. See the <function>sprintf()</function>
81 documentation.
82 @Varargs: the parameters to insert into the format string.
83
84
85 <!-- ##### FUNCTION g_string_sprintfa ##### -->
86 <para>
87 Appends a formatted string onto the end of a #GString.
88 This function is is similar to g_string_sprintf() except that
89 the text is appended to the GString.
90 </para>
91
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 <!-- ##### FUNCTION g_string_append ##### -->
99 <para>
100 Adds a string onto the end of a #GString, expanding it if necessary.
101 </para>
102
103 @string: a #GString.
104 @val: the string to append onto the end of the #GString.
105 @Returns: the #GString.
106
107
108 <!-- ##### FUNCTION g_string_append_c ##### -->
109 <para>
110 Adds a character onto the end of a #GString, expanding it if necessary.
111 </para>
112
113 @string: a #GString.
114 @c: the character to append onto the end of the #GString.
115 @Returns: the #GString.
116
117
118 <!-- ##### FUNCTION g_string_append_len ##### -->
119 <para>
120
121 </para>
122
123 @string: 
124 @val: 
125 @len: 
126 @Returns: 
127
128
129 <!-- ##### FUNCTION g_string_prepend ##### -->
130 <para>
131 Adds a string on to the start of a #GString, expanding it if necessary.
132 </para>
133
134 @string: a #GString.
135 @val: the string to prepend on the start of the #GString.
136 @Returns: the #GString.
137
138
139 <!-- ##### FUNCTION g_string_prepend_c ##### -->
140 <para>
141 Adds a character onto the start of a #GString, expanding it if necessary.
142 </para>
143
144 @string: a #GString.
145 @c: the character to prepend on the start of the #GString.
146 @Returns: the #GString.
147
148
149 <!-- ##### FUNCTION g_string_prepend_len ##### -->
150 <para>
151
152 </para>
153
154 @string: 
155 @val: 
156 @len: 
157 @Returns: 
158
159
160 <!-- ##### FUNCTION g_string_insert ##### -->
161 <para>
162 Inserts a copy of a string into a #GString, expanding it if necessary.
163 </para>
164
165 @string: a #GString.
166 @pos: the position to insert the copy of the string.
167 @val: the string to insert.
168 @Returns: the #GString.
169
170
171 <!-- ##### FUNCTION g_string_insert_c ##### -->
172 <para>
173 Inserts a character into a #GString, expanding it if necessary.
174 </para>
175
176 @string: a #GString.
177 @pos: the position to insert the character.
178 @c: the character to insert.
179 @Returns: the #GString.
180
181
182 <!-- ##### FUNCTION g_string_insert_len ##### -->
183 <para>
184
185 </para>
186
187 @string: 
188 @pos: 
189 @val: 
190 @len: 
191 @Returns: 
192
193
194 <!-- ##### FUNCTION g_string_erase ##### -->
195 <para>
196 Removes @len characters from a #GString, starting at position @pos.
197 The rest of the #GString is shifted down to fill the gap.
198 </para>
199
200 @string: a #GString.
201 @pos: the position of the characters to remove.
202 @len: the number of characters to remove.
203 @Returns: the #GString.
204
205
206 <!-- ##### FUNCTION g_string_truncate ##### -->
207 <para>
208 Cuts off the end of the GString, leaving the first @len characters.
209 </para>
210
211 @string: a #GString.
212 @len: the new size of the #GString.
213 @Returns: the #GString.
214
215
216 <!-- ##### FUNCTION g_string_free ##### -->
217 <para>
218 Frees the memory allocated for the #GString.
219 If free_segment is TRUE it also frees the character data.
220 </para>
221
222 @string: a #GString.
223 @free_segment: if TRUE the actual character data is freed as well.
224 @Returns: 
225
226
227 <!-- ##### FUNCTION g_string_up ##### -->
228 <para>
229 Converts a #GString to upper case.
230 </para>
231
232 @string: a #GString.
233 @Returns: the #GString.
234
235
236 <!-- ##### FUNCTION g_string_down ##### -->
237 <para>
238 Converts a #GString to lower case.
239 </para>
240
241 @string: a #GString.
242 @Returns: the #GString.
243
244
245 <!-- ##### FUNCTION g_string_hash ##### -->
246 <para>
247
248 </para>
249
250 @str: 
251 @Returns: 
252
253
254 <!-- ##### FUNCTION g_string_equal ##### -->
255 <para>
256
257 </para>
258
259 @v: 
260 @v2: 
261 @Returns: 
262
263