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