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
|
<html>
<head>
<title>~/src/firstworks/rudiments-0.27/include/rudiments/stringbuffer.h.html</title>
<meta name="Generator" content="Vim/6.2">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000">
<pre>
<font color="#0000ff">// Copyright (c) 2002 David Muse</font>
<font color="#0000ff">// See the COPYING file for more information.</font>
<font color="#a520f7">#ifndef RUDIMENTS_STRINGBUFFER_H</font>
<font color="#a520f7">#define RUDIMENTS_STRINGBUFFER_H</font>
<font color="#a520f7">#include </font><font color="#ff00ff"><rudiments/private/stringbufferincludes.h></font>
<font color="#0000ff">// The stringbuffer class can be used to store strings of arbitrary length.</font>
<font color="#298a52"><b>class</b></font> stringbuffer : <font color="#a52829"><b>public</b></font> variablebuffer {
<font color="#a52829"><b>public</b></font>:
stringbuffer();
stringbuffer(<font color="#298a52"><b>char</b></font> *initialcontents,
<font color="#298a52"><b>size_t</b></font> initialsize,
<font color="#298a52"><b>size_t</b></font> increment);
<font color="#0000ff">// Creates a new buffer which will grow as necessary</font>
<font color="#0000ff">// to accomodate the string written to it.</font>
~stringbuffer();
<font color="#298a52"><b>void</b></font> setPosition(<font color="#298a52"><b>size_t</b></font> pos);
<font color="#0000ff">// Sets the position at which the next write will</font>
<font color="#0000ff">// occur to "pos". If the position is set beyond the</font>
<font color="#0000ff">// end of the buffer, the buffer will grow but the data</font>
<font color="#0000ff">// between the current end of the buffer and the new</font>
<font color="#0000ff">// position will be undefined.</font>
<font color="#0000ff">// The write() and append() methods return a pointer to the</font>
<font color="#0000ff">// variablebuffer instance. This enables chaining:</font>
<font color="#0000ff">//</font>
<font color="#0000ff">// sb->write("numbers: ")->write(5)->write(5.5);</font>
<font color="#0000ff">// or</font>
<font color="#0000ff">// sb->append("numbers: ")->append(5)->append(5.5);</font>
stringbuffer *write(<font color="#298a52"><b>const</b></font> <font color="#298a52"><b>char</b></font> *string);
stringbuffer *write(<font color="#298a52"><b>const</b></font> <font color="#298a52"><b>char</b></font> *string, <font color="#298a52"><b>size_t</b></font> size);
stringbuffer *write(<font color="#298a52"><b>char</b></font> character);
stringbuffer *write(<font color="#298a52"><b>long</b></font> number);
stringbuffer *write(<font color="#298a52"><b>double</b></font> number);
stringbuffer *write(<font color="#298a52"><b>double</b></font> number,
<font color="#298a52"><b>unsigned</b></font> <font color="#298a52"><b>short</b></font> scale);
stringbuffer *write(<font color="#298a52"><b>double</b></font> number,
<font color="#298a52"><b>unsigned</b></font> <font color="#298a52"><b>short</b></font> precision,
<font color="#298a52"><b>unsigned</b></font> <font color="#298a52"><b>short</b></font> scale);
<font color="#0000ff">// Writes the data to the stringbuffer at the current</font>
<font color="#0000ff">// position. If necessary, the buffer will grow to</font>
<font color="#0000ff">// accommodate the new data.</font>
stringbuffer *append(<font color="#298a52"><b>const</b></font> <font color="#298a52"><b>char</b></font> *string);
stringbuffer *append(<font color="#298a52"><b>const</b></font> <font color="#298a52"><b>char</b></font> *string, <font color="#298a52"><b>size_t</b></font> size);
stringbuffer *append(<font color="#298a52"><b>char</b></font> character);
stringbuffer *append(<font color="#298a52"><b>long</b></font> number);
stringbuffer *append(<font color="#298a52"><b>double</b></font> number);
stringbuffer *append(<font color="#298a52"><b>double</b></font> number,
<font color="#298a52"><b>unsigned</b></font> <font color="#298a52"><b>short</b></font> scale);
stringbuffer *append(<font color="#298a52"><b>double</b></font> number,
<font color="#298a52"><b>unsigned</b></font> <font color="#298a52"><b>short</b></font> precision,
<font color="#298a52"><b>unsigned</b></font> <font color="#298a52"><b>short</b></font> scale);
<font color="#0000ff">// Appends the data to the stringbuffer. The buffer</font>
<font color="#0000ff">// will grow to accommodate the new data.</font>
<font color="#298a52"><b>void</b></font> clear();
<font color="#0000ff">// Empties the stringbuffer.</font>
<font color="#298a52"><b>char</b></font> *getString();
<font color="#0000ff">// Returns the string currently stored in the</font>
<font color="#0000ff">// stringbuffer.</font>
<font color="#298a52"><b>size_t</b></font> getStringLength();
<font color="#0000ff">// Returns the length of the string currently stored</font>
<font color="#0000ff">// in the stringbuffer.</font>
<font color="#298a52"><b>size_t</b></font> getPosition();
<font color="#0000ff">// Returns the position in the buffer at which</font>
<font color="#0000ff">// the next write will occur.</font>
<font color="#a520f7"> #include </font><font color="#ff00ff"><rudiments/private/stringbuffer.h></font>
};
<font color="#a520f7">#endif</font>
</pre>
</body>
</html>
|