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