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