]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/stream.tex
removed erroneous spaces from wxTo/FromString() documentation
[wxWidgets.git] / docs / latex / wx / stream.tex
CommitLineData
e2a6f233 1\section{\class{wxStreamBuffer}}\label{wxstreambuffer}
7da42094 2
b82827dd
JS
3\wxheading{Derived from}
4
5None
6
954b8ae6
JS
7\wxheading{Include files}
8
9<wx/stream.h>
10
7da42094 11\wxheading{See also}
b82827dd 12
7da42094
GL
13\helpref{wxStreamBase}{wxstreambase}
14
15% ---------------------------------------------------------------------------
16% Members
17% ---------------------------------------------------------------------------
7da42094
GL
18\latexignore{\rtfignore{\wxheading{Members}}}
19
20% -----------
21% ctor & dtor
22% -----------
15d83f72 23\membersection{wxStreamBuffer::wxStreamBuffer}\label{wxstreambufferctor}
b82827dd
JS
24
25\func{}{wxStreamBuffer}{\param{wxStreamBase\&}{ stream}, \param{BufMode}{ mode}}
7da42094 26
605d715d
VS
27Constructor, creates a new stream buffer using {\it stream} as a parent stream
28and {\it mode} as the IO mode. {\it mode} can be: wxStreamBuffer::read,
b82827dd 29wxStreamBuffer::write, wxStreamBuffer::read\_write.
7da42094 30
2bf8e4eb
RR
31One stream can have many stream buffers but only one is used internally to
32pass IO call (e.g. wxInputStream::Read() -> wxStreamBuffer::Read()), but you
33can call directly wxStreamBuffer::Read without any problems. Note that
34all errors and messages linked to the stream are stored in the stream, not
35the stream buffers:
2723cfeb 36
07b73270 37\begin{verbatim}
2723cfeb 38 streambuffer.Read(...);
2bf8e4eb 39 streambuffer2.Read(...); /* This call erases previous error messages set by
2723cfeb 40 ``streambuffer'' */
07b73270 41\end{verbatim}
b82827dd 42
7da42094
GL
43\func{}{wxStreamBuffer}{\param{BufMode}{ mode}}
44
e2a6f233 45Constructor, creates a new empty stream buffer which won't flush any data
605d715d 46to a stream. {\it mode} specifies the type of the buffer (read, write, read\_write).
2bf8e4eb 47This stream buffer has the advantage to be stream independent and to
07b73270
GL
48work only on memory buffers but it is still compatible with the rest of the
49wxStream classes. You can write, read to this special stream and it will
50grow (if it is allowed by the user) its internal buffer. Briefly, it has all
c7f49969 51functionality of a ``normal'' stream.
7da42094 52
07b73270
GL
53\wxheading{Warning}
54
bceb8d05 55The "read\_write" mode doesn't currently work for standalone stream buffers.
07b73270 56
c7f49969 57\func{}{wxStreamBuffer}{\param{const wxStreamBuffer\&}{buffer}}
07b73270
GL
58
59Constructor. It initializes the stream buffer with the data of the specified
2bf8e4eb
RR
60stream buffer. The new stream buffer has the same attributes, size, position
61and they share the same buffer. This will cause problems if the stream to
62which the stream buffer belong is destroyed and the newly cloned stream
63buffer continues to be used, trying to call functions in the (destroyed)
64stream. It is advised to use this feature only in very local area of the
07b73270 65program.
7da42094 66
c7f49969
JS
67\wxheading{See also}
68
69\helpref{wxStreamBuffer:SetBufferIO}{wxstreambuffersetbufferio}
70
15d83f72 71\membersection{wxStreamBuffer::\destruct{wxStreamBuffer}}\label{wxstreambufferdtor}
b82827dd 72
e2a6f233 73\func{}{wxStreamBuffer}{\destruct{wxStreamBuffer}}
7da42094 74
07b73270 75Destructor. It finalizes all IO calls and frees all internal buffers if
2bf8e4eb 76necessary.
7da42094
GL
77
78% -----------
79% Filtered IO
80% -----------
750b78ba 81\membersection{wxStreamBuffer::Read}\label{wxstreambufferread}
b82827dd
JS
82
83\func{size\_t}{Read}{\param{void *}{buffer}, \param{size\_t }{size}}
7da42094 84
2bf8e4eb
RR
85Reads a block of the specified {\it size} and stores the data in {\it buffer}.
86This function tries to read from the buffer first and if more data has been
87requested, reads more data from the associated stream and updates the buffer
88accordingly until all requested data is read.
7da42094
GL
89
90\wxheading{Return value}
91
cd6ce4a9 92It returns the size of the data read. If the returned size is different of the specified
f6bcfd97 93{\it size}, an error has occurred and should be tested using
b919fd47 94\helpref{GetLastError}{wxstreambasegetlasterror}.
7da42094 95
2bf8e4eb 96\func{size\_t}{Read}{\param{wxStreamBuffer *}{buffer}}
07b73270 97
c15b71ae
VZ
98Copies data to {\it buffer}. The function returns when {\it buffer} is full or when there isn't
99any more data in the current buffer.
b82827dd 100
2bf8e4eb 101\wxheading{See also}
7da42094 102
2bf8e4eb 103\helpref{wxStreamBuffer::Write}{wxstreambufferwrite}
7da42094 104
750b78ba 105\membersection{wxStreamBuffer::Write}\label{wxstreambufferwrite}
b82827dd
JS
106
107\func{size\_t}{Write}{\param{const void *}{buffer}, \param{size\_t }{size}}
7da42094 108
2edb0bde 109Writes a block of the specified {\it size} using data of {\it buffer}. The data
07b73270 110are cached in a buffer before being sent in one block to the stream.
b82827dd
JS
111
112\func{size\_t}{Write}{\param{wxStreamBuffer *}{buffer}}
7da42094 113
750b78ba 114See \helpref{Read}{wxstreambufferread}.
7da42094 115
15d83f72 116\membersection{wxStreamBuffer::GetChar}\label{wxstreambuffergetchar}
b82827dd 117
7da42094
GL
118\func{char}{GetChar}{\void}
119
07b73270
GL
120Gets a single char from the stream buffer. It acts like the Read call.
121
122\wxheading{Problem}
123
f6bcfd97 124You aren't directly notified if an error occurred during the IO call.
07b73270
GL
125
126\wxheading{See also}
127
750b78ba 128\helpref{wxStreamBuffer::Read}{wxstreambufferread}
7da42094 129
15d83f72 130\membersection{wxStreamBuffer::PutChar}\label{wxstreambufferputchar}
b82827dd 131
7da42094
GL
132\func{void}{PutChar}{\param{char }{c}}
133
134Puts a single char to the stream buffer.
135
07b73270
GL
136\wxheading{Problem}
137
f6bcfd97 138You aren't directly notified if an error occurred during the IO call.
07b73270
GL
139
140\wxheading{See also}
141
750b78ba 142\helpref{wxStreamBuffer::Read}{wxstreambufferwrite}
07b73270 143
15d83f72 144\membersection{wxStreamBuffer::Tell}\label{wxstreambuffertell}
b82827dd
JS
145
146\constfunc{off\_t}{Tell}{\void}
7da42094 147
07b73270 148Gets the current position in the stream. This position is calculated from
605d715d
VS
149the {\it real} position in the stream and from the internal buffer position: so
150it gives you the position in the {\it real} stream counted from the start of
07b73270
GL
151the stream.
152
153\wxheading{Return value}
154
155Returns the current position in the stream if possible, wxInvalidOffset in the
156other case.
7da42094 157
e2a6f233 158\membersection{wxStreamBuffer::Seek}\label{wxstreambufferseek}
b82827dd
JS
159
160\func{off\_t}{Seek}{\param{off\_t }{pos}, \param{wxSeekMode }{mode}}
7da42094 161
07b73270
GL
162Changes the current position.
163
605d715d 164{\it mode} may be one of the following:
07b73270
GL
165
166\twocolwidtha{5cm}
167\begin{twocollist}\itemsep=0pt
168\twocolitem{{\bf wxFromStart}}{The position is counted from the start of the stream.}
169\twocolitem{{\bf wxFromCurrent}}{The position is counted from the current position of the stream.}
170\twocolitem{{\bf wxFromEnd}}{The position is counted from the end of the stream.}
171\end{twocollist}
172
173\wxheading{Return value}
174
175Upon successful completion, it returns the new offset as measured in bytes from
176the beginning of the stream. Otherwise, it returns wxInvalidOffset.
7da42094
GL
177
178% --------------
179% Buffer control
180% --------------
15d83f72 181\membersection{wxStreamBuffer::ResetBuffer}\label{wxstreambufferresetbuffer}
b82827dd 182
7da42094
GL
183\func{void}{ResetBuffer}{\void}
184
07b73270 185Resets to the initial state variables concerning the buffer.
7da42094 186
df18cc7a
VZ
187
188\membersection{wxStreamBuffer::Truncate}\label{wxstreambuffertruncate}
189
190\func{void}{Truncate}{\void}
191
192Truncates the buffer to the current position.
193
194Note: Truncate() cannot be used to enlarge the buffer. This is
195usually not needed since the buffer expands automatically.
196
197
750b78ba 198\membersection{wxStreamBuffer::SetBufferIO}\label{wxstreambuffersetbufferio}
b82827dd 199
06ad8636 200\func{void}{SetBufferIO}{\param{char*}{ buffer\_start}, \param{char*}{ buffer\_end}}
7da42094
GL
201
202Specifies which pointers to use for stream buffering. You need to pass a pointer on the
da3aea64
GL
203start of the buffer end and another on the end. The object will use this buffer
204to cache stream data. It may be used also as a source/destination buffer when
15d83f72 205you create an empty stream buffer (See \helpref{wxStreamBuffer::wxStreamBuffer}{wxstreambufferctor}).
da3aea64
GL
206
207\wxheading{Remarks}
208
f6bcfd97 209When you use this function, you will have to destroy the IO buffers yourself
da3aea64 210after the stream buffer is destroyed or don't use it anymore.
85ec2f26 211In the case you use it with an empty buffer, the stream buffer will not resize
da3aea64
GL
212it when it is full.
213
214\wxheading{See also}
215
15d83f72 216\helpref{wxStreamBuffer constructor}{wxstreambufferctor}\\
750b78ba
JS
217\helpref{wxStreamBuffer::Fixed}{wxstreambufferfixed}\\
218\helpref{wxStreamBuffer::Flushable}{wxstreambufferflushable}
7da42094 219
b82827dd 220\func{void}{SetBufferIO}{\param{size\_t}{ bufsize}}
7da42094 221
da3aea64
GL
222Destroys or invalidates the previous IO buffer and allocates a new one of the
223specified size.
224
225\wxheading{Warning}
226
227All previous pointers aren't valid anymore.
228
229\wxheading{Remark}
230
231The created IO buffer is growable by the object.
232
233\wxheading{See also}
234
750b78ba
JS
235\helpref{wxStreamBuffer::Fixed}{wxstreambufferfixed}\\
236\helpref{wxStreamBuffer::Flushable}{wxstreambufferflushable}
7da42094 237
15d83f72 238\membersection{wxStreamBuffer::GetBufferStart}\label{wxstreambuffergetbufferstart}
b82827dd 239
9a75ba66 240\constfunc{void *}{GetBufferStart}{\void}
7da42094
GL
241
242Returns a pointer on the start of the stream buffer.
243
15d83f72 244\membersection{wxStreamBuffer::GetBufferEnd}\label{wxstreambuffergetbufferend}
b82827dd 245
9a75ba66 246\constfunc{void *}{GetBufferEnd}{\void}
7da42094
GL
247
248Returns a pointer on the end of the stream buffer.
249
15d83f72 250\membersection{wxStreamBuffer::GetBufferPos}\label{wxstreambuffergetbufferpos}
b82827dd 251
9a75ba66 252\constfunc{void *}{GetBufferPos}{\void}
7da42094
GL
253
254Returns a pointer on the current position of the stream buffer.
255
15d83f72 256\membersection{wxStreamBuffer::GetIntPosition}\label{wxstreambuffergetintposition}
b82827dd
JS
257
258\constfunc{off\_t}{GetIntPosition}{\void}
7da42094 259
da3aea64 260Returns the current position (counted in bytes) in the stream buffer.
7da42094 261
15d83f72 262\membersection{wxStreamBuffer::SetIntPosition}\label{wxstreambuffersetintposition}
b82827dd 263
fc4fb528 264\func{void}{SetIntPosition}{\param{size\_t}{ pos}}
7da42094 265
9fc0fe37
GL
266Sets the current position (in bytes) in the stream buffer.
267
268\wxheading{Warning}
269
270Since it is a very low-level function, there is no check on the position:
dbd94b75 271specifying an invalid position can induce unexpected results.
7da42094 272
15d83f72 273\membersection{wxStreamBuffer::GetLastAccess}\label{wxstreambuffergetlastaccess}
b82827dd
JS
274
275\constfunc{size\_t}{GetLastAccess}{\void}
7da42094
GL
276
277Returns the amount of bytes read during the last IO call to the parent stream.
278
750b78ba 279\membersection{wxStreamBuffer::Fixed}\label{wxstreambufferfixed}
b82827dd 280
7da42094
GL
281\func{void}{Fixed}{\param{bool}{ fixed}}
282
b82827dd 283Toggles the fixed flag. Usually this flag is toggled at the same time as
cc81d32f
VS
284{\it flushable}. This flag allows (when it has the false value) or forbids
285(when it has the true value) the stream buffer to resize dynamically the IO buffer.
da3aea64
GL
286
287\wxheading{See also}
288
750b78ba 289\helpref{wxStreamBuffer::SetBufferIO}{wxstreambuffersetbufferio}
7da42094 290
750b78ba 291\membersection{wxStreamBuffer::Flushable}\label{wxstreambufferflushable}
b82827dd 292
7da42094
GL
293\func{void}{Flushable}{\param{bool}{ flushable}}
294
2edb0bde 295Toggles the flushable flag. If {\it flushable} is disabled, no data are sent
7da42094
GL
296to the parent stream.
297
15d83f72 298\membersection{wxStreamBuffer::FlushBuffer}\label{wxstreambufferflushbuffer}
b82827dd 299
7da42094
GL
300\func{bool}{FlushBuffer}{\void}
301
302Flushes the IO buffer.
303
15d83f72 304\membersection{wxStreamBuffer::FillBuffer}\label{wxstreambufferfillbuffer}
b82827dd 305
7da42094
GL
306\func{bool}{FillBuffer}{\void}
307
308Fill the IO buffer.
309
8639b30d
VZ
310\membersection{wxStreamBuffer::GetBufferSize}\label{wxstreambuffergetbuffersize}
311
312\constfunc{size\_t}{GetBufferSize}{\void}
313
314Returns the size of the buffer.
315
15d83f72 316\membersection{wxStreamBuffer::GetDataLeft}\label{wxstreambuffergetdataleft}
b82827dd
JS
317
318\func{size\_t}{GetDataLeft}{\void}
7da42094 319
2edb0bde 320Returns the amount of available data in the buffer.
7da42094
GL
321
322% --------------
323% Administration
324% --------------
15d83f72 325\membersection{wxStreamBuffer::Stream}\label{wxstreambufferstream}
b82827dd 326
06ad8636 327\func{wxStreamBase*}{Stream}{\void}
7da42094 328
07b73270 329Returns the parent stream of the stream buffer.
b82827dd 330