]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/stream.tex
no real changes, just refactor/simplify the code to remove duplication and unnecessar...
[wxWidgets.git] / docs / latex / wx / stream.tex
... / ...
CommitLineData
1\section{\class{wxStreamBuffer}}\label{wxstreambuffer}
2
3\wxheading{Derived from}
4
5None
6
7\wxheading{Include files}
8
9<wx/stream.h>
10
11\wxheading{Library}
12
13\helpref{wxBase}{librarieslist}
14
15\wxheading{See also}
16
17\helpref{wxStreamBase}{wxstreambase}
18
19\latexignore{\rtfignore{\wxheading{Members}}}
20
21
22\membersection{wxStreamBuffer::wxStreamBuffer}\label{wxstreambufferctor}
23
24\func{}{wxStreamBuffer}{\param{wxStreamBase\&}{ stream}, \param{BufMode}{ mode}}
25
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,
28wxStreamBuffer::write, wxStreamBuffer::read\_write.
29
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:
35
36\begin{verbatim}
37 streambuffer.Read(...);
38 streambuffer2.Read(...); /* This call erases previous error messages set by
39 ``streambuffer'' */
40\end{verbatim}
41
42\func{}{wxStreamBuffer}{\param{BufMode}{ mode}}
43
44Constructor, creates a new empty stream buffer which won't flush any data
45to a stream. {\it mode} specifies the type of the buffer (read, write, read\_write).
46This stream buffer has the advantage to be stream independent and to
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
50functionality of a ``normal'' stream.
51
52\wxheading{Warning}
53
54The "read\_write" mode doesn't currently work for standalone stream buffers.
55
56\func{}{wxStreamBuffer}{\param{const wxStreamBuffer\&}{buffer}}
57
58Constructor. It initializes the stream buffer with the data of the specified
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
64program.
65
66\wxheading{See also}
67
68\helpref{wxStreamBuffer:SetBufferIO}{wxstreambuffersetbufferio}
69
70
71\membersection{wxStreamBuffer::\destruct{wxStreamBuffer}}\label{wxstreambufferdtor}
72
73\func{}{wxStreamBuffer}{\destruct{wxStreamBuffer}}
74
75Destructor. It finalizes all IO calls and frees all internal buffers if
76necessary.
77
78
79\membersection{wxStreamBuffer::FillBuffer}\label{wxstreambufferfillbuffer}
80
81\func{bool}{FillBuffer}{\void}
82
83Fill the IO buffer.
84
85
86\membersection{wxStreamBuffer::Fixed}\label{wxstreambufferfixed}
87
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.
93
94\wxheading{See also}
95
96\helpref{wxStreamBuffer::SetBufferIO}{wxstreambuffersetbufferio}
97
98
99\membersection{wxStreamBuffer::Flushable}\label{wxstreambufferflushable}
100
101\func{void}{Flushable}{\param{bool}{ flushable}}
102
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.
140
141
142\membersection{wxStreamBuffer::GetChar}\label{wxstreambuffergetchar}
143
144\func{char}{GetChar}{\void}
145
146Gets a single char from the stream buffer. It acts like the Read call.
147
148\wxheading{Problem}
149
150You aren't directly notified if an error occurred during the IO call.
151
152\wxheading{See also}
153
154\helpref{wxStreamBuffer::Read}{wxstreambufferread}
155
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
178\membersection{wxStreamBuffer::PutChar}\label{wxstreambufferputchar}
179
180\func{void}{PutChar}{\param{char }{c}}
181
182Puts a single char to the stream buffer.
183
184\wxheading{Problem}
185
186You aren't directly notified if an error occurred during the IO call.
187
188\wxheading{See also}
189
190\helpref{wxStreamBuffer::Read}{wxstreambufferwrite}
191
192
193\membersection{wxStreamBuffer::Read}\label{wxstreambufferread}
194
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.
201
202\wxheading{Return value}
203
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
224
225\membersection{wxStreamBuffer::Seek}\label{wxstreambufferseek}
226
227\func{off\_t}{Seek}{\param{off\_t }{pos}, \param{wxSeekMode }{mode}}
228
229Changes the current position.
230
231{\it mode} may be one of the following:
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.
244
245
246\membersection{wxStreamBuffer::SetBufferIO}\label{wxstreambuffersetbufferio}
247
248\func{void}{SetBufferIO}{\param{char*}{ buffer\_start}, \param{char*}{ buffer\_end}}
249
250Specifies which pointers to use for stream buffering. You need to pass a pointer on the
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
253you create an empty stream buffer (See \helpref{wxStreamBuffer::wxStreamBuffer}{wxstreambufferctor}).
254
255\wxheading{Remarks}
256
257When you use this function, you will have to destroy the IO buffers yourself
258after the stream buffer is destroyed or don't use it anymore.
259In the case you use it with an empty buffer, the stream buffer will not resize
260it when it is full.
261
262\wxheading{See also}
263
264\helpref{wxStreamBuffer constructor}{wxstreambufferctor}\\
265\helpref{wxStreamBuffer::Fixed}{wxstreambufferfixed}\\
266\helpref{wxStreamBuffer::Flushable}{wxstreambufferflushable}
267
268\func{void}{SetBufferIO}{\param{size\_t}{ bufsize}}
269
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
283\helpref{wxStreamBuffer::Fixed}{wxstreambufferfixed}\\
284\helpref{wxStreamBuffer::Flushable}{wxstreambufferflushable}
285
286
287\membersection{wxStreamBuffer::SetIntPosition}\label{wxstreambuffersetintposition}
288
289\func{void}{SetIntPosition}{\param{size\_t}{ pos}}
290
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:
296specifying an invalid position can induce unexpected results.
297
298
299\membersection{wxStreamBuffer::Stream}\label{wxstreambufferstream}
300
301\func{wxStreamBase*}{Stream}{\void}
302
303Returns the parent stream of the stream buffer.
304
305
306\membersection{wxStreamBuffer::Tell}\label{wxstreambuffertell}
307
308\constfunc{off\_t}{Tell}{\void}
309
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.
314
315\wxheading{Return value}
316
317Returns the current position in the stream if possible, wxInvalidOffset in the
318other case.
319
320
321\membersection{wxStreamBuffer::Truncate}\label{wxstreambuffertruncate}
322
323\func{void}{Truncate}{\void}
324
325Truncates the buffer to the current position.
326
327Note: Truncate() cannot be used to enlarge the buffer. This is
328usually not needed since the buffer expands automatically.
329
330
331\membersection{wxStreamBuffer::Write}\label{wxstreambufferwrite}
332
333\func{size\_t}{Write}{\param{const void *}{buffer}, \param{size\_t }{size}}
334
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.
337
338\func{size\_t}{Write}{\param{wxStreamBuffer *}{buffer}}
339
340See \helpref{Read}{wxstreambufferread}.
341