File: section-stringbuffer.xml

package info (click to toggle)
raptor 1.4.13-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 11,576 kB
  • ctags: 4,494
  • sloc: ansic: 31,845; sh: 9,278; xml: 8,589; yacc: 2,912; lex: 1,018; makefile: 817; perl: 61; cpp: 59
file content (352 lines) | stat: -rw-r--r-- 19,308 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="raptor-section-stringbuffer">
<refmeta>
<refentrytitle role="top_of_page">String buffer</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>RAPTOR Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>String buffer</refname>
<refpurpose>Append-only strings.</refpurpose>
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
</refnamediv>

<refsynopsisdiv role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>



typedef     <link linkend="raptor-stringbuffer">raptor_stringbuffer</link>;
<link linkend="raptor-stringbuffer">raptor_stringbuffer</link>* <link linkend="raptor-new-stringbuffer">raptor_new_stringbuffer</link>
                                            (void);
<link linkend="void">void</link>        <link linkend="raptor-free-stringbuffer">raptor_free_stringbuffer</link>        (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer);
<link linkend="int">int</link>         <link linkend="raptor-stringbuffer-append-counted-string">raptor_stringbuffer_append_counted_string</link>
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer,
                                             unsigned <link linkend="char">char</link> *string,
                                             <link linkend="size-t">size_t</link> length,
                                             <link linkend="int">int</link> do_copy);
<link linkend="int">int</link>         <link linkend="raptor-stringbuffer-append-string">raptor_stringbuffer_append_string</link>
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer,
                                             unsigned <link linkend="char">char</link> *string,
                                             <link linkend="int">int</link> do_copy);
<link linkend="int">int</link>         <link linkend="raptor-stringbuffer-append-decimal">raptor_stringbuffer_append_decimal</link>
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer,
                                             <link linkend="int">int</link> integer);
<link linkend="int">int</link>         <link linkend="raptor-stringbuffer-append-stringbuffer">raptor_stringbuffer_append_stringbuffer</link>
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer,
                                             <link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *append);
<link linkend="int">int</link>         <link linkend="raptor-stringbuffer-prepend-counted-string">raptor_stringbuffer_prepend_counted_string</link>
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer,
                                             unsigned <link linkend="char">char</link> *string,
                                             <link linkend="size-t">size_t</link> length,
                                             <link linkend="int">int</link> do_copy);
<link linkend="int">int</link>         <link linkend="raptor-stringbuffer-prepend-string">raptor_stringbuffer_prepend_string</link>
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer,
                                             unsigned <link linkend="char">char</link> *string,
                                             <link linkend="int">int</link> do_copy);
unsigned <link linkend="char">char</link>* <link linkend="raptor-stringbuffer-as-string">raptor_stringbuffer_as_string</link>
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer);
<link linkend="size-t">size_t</link>      <link linkend="raptor-stringbuffer-length">raptor_stringbuffer_length</link>      (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer);
<link linkend="int">int</link>         <link linkend="raptor-stringbuffer-copy-to-string">raptor_stringbuffer_copy_to_string</link>
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer,
                                             unsigned <link linkend="char">char</link> *string,
                                             <link linkend="size-t">size_t</link> length);
</synopsis>
</refsynopsisdiv>









<refsect1 role="desc">
<title role="desc.title">Description</title>
<para>
A utility class that allows easy construction of strings that
grow at the end by appending new strings.  Primarily used for
constructing/serializing syntaxes into strings by the <link linkend="raptor-iostream"><type>raptor_iostream</type></link>
and <link linkend="raptor-serializer"><type>raptor_serializer</type></link> classes.
</para>
</refsect1>

<refsect1 role="details">
<title role="details.title">Details</title>
<refsect2>
<title><anchor id="raptor-stringbuffer" role="typedef"/>raptor_stringbuffer</title>
<indexterm><primary>raptor_stringbuffer</primary></indexterm><programlisting>raptor_stringbuffer* raptor_stringbuffer;
</programlisting>
<para>
Raptor string buffer class</para>
<para>

</para></refsect2>
<refsect2>
<title><anchor id="raptor-new-stringbuffer" role="function"/>raptor_new_stringbuffer ()</title>
<indexterm><primary>raptor_new_stringbuffer</primary></indexterm><programlisting><link linkend="raptor-stringbuffer">raptor_stringbuffer</link>* raptor_new_stringbuffer
                                            (void);</programlisting>
<para>
Create a new stringbuffer.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non 0 on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="raptor-free-stringbuffer" role="function"/>raptor_free_stringbuffer ()</title>
<indexterm><primary>raptor_free_stringbuffer</primary></indexterm><programlisting><link linkend="void">void</link>        raptor_free_stringbuffer        (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer);</programlisting>
<para>
Destroy a stringbuffer.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>stringbuffer</parameter>&nbsp;:</term>
<listitem><simpara> stringbuffer object to destroy.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="raptor-stringbuffer-append-counted-string" role="function"/>raptor_stringbuffer_append_counted_string ()</title>
<indexterm><primary>raptor_stringbuffer_append_counted_string</primary></indexterm><programlisting><link linkend="int">int</link>         raptor_stringbuffer_append_counted_string
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer,
                                             unsigned <link linkend="char">char</link> *string,
                                             <link linkend="size-t">size_t</link> length,
                                             <link linkend="int">int</link> do_copy);</programlisting>
<para>
If <parameter>string</parameter> is NULL or <parameter>length</parameter> is 0, no work is performed.
</para>
<para>
If <parameter>do_copy</parameter> is non-0, the passed-in string is copied into new memory
otherwise the stringbuffer becomes the owner of the string pointer
and will free it when the stringbuffer is destroyed.
</para>
<para>
Add a string to the stringbuffer.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>stringbuffer</parameter>&nbsp;:</term>
<listitem><simpara> raptor stringbuffer
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>string</parameter>&nbsp;:</term>
<listitem><simpara> string
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>length</parameter>&nbsp;:</term>
<listitem><simpara> length of string
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>do_copy</parameter>&nbsp;:</term>
<listitem><simpara> non-0 to copy the string
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="raptor-stringbuffer-append-string" role="function"/>raptor_stringbuffer_append_string ()</title>
<indexterm><primary>raptor_stringbuffer_append_string</primary></indexterm><programlisting><link linkend="int">int</link>         raptor_stringbuffer_append_string
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer,
                                             unsigned <link linkend="char">char</link> *string,
                                             <link linkend="int">int</link> do_copy);</programlisting>
<para>
Add a string to the stringbuffer.
</para>
<para>
If <parameter>string</parameter> is NULL, no work is performed.
</para>
<para>
If <parameter>do_copy</parameter> is non-0, the passed-in string is copied into new memory
otherwise the stringbuffer becomes the owner of the string pointer
and will free it when the stringbuffer is destroyed.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>stringbuffer</parameter>&nbsp;:</term>
<listitem><simpara> raptor stringbuffer
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>string</parameter>&nbsp;:</term>
<listitem><simpara> string
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>do_copy</parameter>&nbsp;:</term>
<listitem><simpara> non-0 to copy the string
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="raptor-stringbuffer-append-decimal" role="function"/>raptor_stringbuffer_append_decimal ()</title>
<indexterm><primary>raptor_stringbuffer_append_decimal</primary></indexterm><programlisting><link linkend="int">int</link>         raptor_stringbuffer_append_decimal
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer,
                                             <link linkend="int">int</link> integer);</programlisting>
<para>
Add an integer in decimal to the stringbuffer.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>stringbuffer</parameter>&nbsp;:</term>
<listitem><simpara> raptor stringbuffer
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>integer</parameter>&nbsp;:</term>
<listitem><simpara> integer to format as decimal and add
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="raptor-stringbuffer-append-stringbuffer" role="function"/>raptor_stringbuffer_append_stringbuffer ()</title>
<indexterm><primary>raptor_stringbuffer_append_stringbuffer</primary></indexterm><programlisting><link linkend="int">int</link>         raptor_stringbuffer_append_stringbuffer
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer,
                                             <link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *append);</programlisting>
<para>
Add a stringbuffer to the stringbuffer.
</para>
<para>
This function removes the content from the appending stringbuffer,
making it empty and appends it to the supplied stringbuffer.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>stringbuffer</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="raptor-stringbuffer"><type>raptor_stringbuffer</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>append</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="raptor-stringbuffer"><type>raptor_stringbuffer</type></link> to append
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="raptor-stringbuffer-prepend-counted-string" role="function"/>raptor_stringbuffer_prepend_counted_string ()</title>
<indexterm><primary>raptor_stringbuffer_prepend_counted_string</primary></indexterm><programlisting><link linkend="int">int</link>         raptor_stringbuffer_prepend_counted_string
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer,
                                             unsigned <link linkend="char">char</link> *string,
                                             <link linkend="size-t">size_t</link> length,
                                             <link linkend="int">int</link> do_copy);</programlisting>
<para>
If do_copy is non-0, the passed-in string is copied into new memory
otherwise the stringbuffer becomes the owner of the string pointer
and will free it when the stringbuffer is destroyed.
</para>
<para>
Add a string to the start of the stringbuffer.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>stringbuffer</parameter>&nbsp;:</term>
<listitem><simpara> raptor stringbuffer
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>string</parameter>&nbsp;:</term>
<listitem><simpara> string
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>length</parameter>&nbsp;:</term>
<listitem><simpara> length of string
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>do_copy</parameter>&nbsp;:</term>
<listitem><simpara> non-0 to copy the string
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="raptor-stringbuffer-prepend-string" role="function"/>raptor_stringbuffer_prepend_string ()</title>
<indexterm><primary>raptor_stringbuffer_prepend_string</primary></indexterm><programlisting><link linkend="int">int</link>         raptor_stringbuffer_prepend_string
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer,
                                             unsigned <link linkend="char">char</link> *string,
                                             <link linkend="int">int</link> do_copy);</programlisting>
<para>
Add a string to the start of the stringbuffer.
</para>
<para>
If do_copy is non-0, the passed-in string is copied into new memory
otherwise the stringbuffer becomes the owner of the string pointer
and will free it when the stringbuffer is destroyed.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>stringbuffer</parameter>&nbsp;:</term>
<listitem><simpara> raptor stringbuffer
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>string</parameter>&nbsp;:</term>
<listitem><simpara> string
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>do_copy</parameter>&nbsp;:</term>
<listitem><simpara> non-0 to copy the string
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="raptor-stringbuffer-as-string" role="function"/>raptor_stringbuffer_as_string ()</title>
<indexterm><primary>raptor_stringbuffer_as_string</primary></indexterm><programlisting>unsigned <link linkend="char">char</link>* raptor_stringbuffer_as_string
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer);</programlisting>
<para>
Return the stringbuffer as a C string.
</para>
<para>
Note: the return value is a to a shared string that the stringbuffer
allocates and manages.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>stringbuffer</parameter>&nbsp;:</term>
<listitem><simpara> raptor stringbuffer
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> NULL on failure or stringbuffer is empty, otherwise
  a pointer to a shared copy of the string.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="raptor-stringbuffer-length" role="function"/>raptor_stringbuffer_length ()</title>
<indexterm><primary>raptor_stringbuffer_length</primary></indexterm><programlisting><link linkend="size-t">size_t</link>      raptor_stringbuffer_length      (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer);</programlisting>
<para>
Return the stringbuffer length.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>stringbuffer</parameter>&nbsp;:</term>
<listitem><simpara> raptor stringbuffer
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> size of stringbuffer
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="raptor-stringbuffer-copy-to-string" role="function"/>raptor_stringbuffer_copy_to_string ()</title>
<indexterm><primary>raptor_stringbuffer_copy_to_string</primary></indexterm><programlisting><link linkend="int">int</link>         raptor_stringbuffer_copy_to_string
                                            (<link linkend="raptor-stringbuffer">raptor_stringbuffer</link> *stringbuffer,
                                             unsigned <link linkend="char">char</link> *string,
                                             <link linkend="size-t">size_t</link> length);</programlisting>
<para>
Copy the stringbuffer into a string.
</para>
<para>
Copies the underlying string to a pre-allocated buffer.  The
output string is always '\0' terminated.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>stringbuffer</parameter>&nbsp;:</term>
<listitem><simpara> raptor stringbuffer
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>string</parameter>&nbsp;:</term>
<listitem><simpara> output string
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>length</parameter>&nbsp;:</term>
<listitem><simpara> size of output string
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 on failure such as stringbuffer is empty, buffer is too small
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>




</refentry>