1 \section{\class{wxStreamBuffer
}}\label{wxstreambuffer
}
3 \wxheading{Derived from
}
7 \wxheading{Include files
}
13 \helpref{wxStreamBase
}{wxstreambase
}
15 % ---------------------------------------------------------------------------
17 % ---------------------------------------------------------------------------
18 \latexignore{\rtfignore{\wxheading{Members
}}}
23 \membersection{wxStreamBuffer::wxStreamBuffer
}\label{wxstreambufconst
}
25 \func{}{wxStreamBuffer
}{\param{wxStreamBase\&
}{ stream
},
\param{BufMode
}{ mode
}}
27 Constructor, creates a new stream buffer using
{\it stream
} as a parent stream
28 and
{\it mode
} as the IO mode.
{\it mode
} can be: wxStreamBuffer::read,
29 wxStreamBuffer::write, wxStreamBuffer::read
\_write.
31 One stream can have many stream buffers but only one is used internally to
32 pass IO call (e.g. wxInputStream::Read() -> wxStreamBuffer::Read()), but you
33 can call directly wxStreamBuffer::Read without any problems. Note that
34 all errors and messages linked to the stream are stored in the stream, not
38 streambuffer.Read(...);
39 streambuffer2.Read(...); /* This call erases previous error messages set by
43 \func{}{wxStreamBuffer
}{\param{BufMode
}{ mode
}}
45 Constructor, creates a new empty stream buffer which won't flush any data
46 to a stream.
{\it mode
} specifies the type of the buffer (read, write, read
\_write).
47 This stream buffer has the advantage to be stream independent and to
48 work only on memory buffers but it is still compatible with the rest of the
49 wxStream classes. You can write, read to this special stream and it will
50 grow (if it is allowed by the user) its internal buffer. Briefly, it has all
51 functionality of a ``normal'' stream.
55 The "read
\_write" mode may not work: it isn't completely finished.
57 \func{}{wxStreamBuffer
}{\param{const wxStreamBuffer\&
}{buffer
}}
59 Constructor. It initializes the stream buffer with the data of the specified
60 stream buffer. The new stream buffer has the same attributes, size, position
61 and they share the same buffer. This will cause problems if the stream to
62 which the stream buffer belong is destroyed and the newly cloned stream
63 buffer continues to be used, trying to call functions in the (destroyed)
64 stream. It is advised to use this feature only in very local area of the
69 \helpref{wxStreamBuffer:SetBufferIO
}{wxstreambuffersetbufferio
}
71 \membersection{wxStreamBuffer::
\destruct{wxStreamBuffer
}}
73 \func{}{wxStreamBuffer
}{\destruct{wxStreamBuffer
}}
75 Destructor. It finalizes all IO calls and frees all internal buffers if
81 \membersection{wxStreamBuffer::Read
}\label{wxstreambufferread
}
83 \func{size
\_t}{Read
}{\param{void *
}{buffer
},
\param{size
\_t }{size
}}
85 Reads a block of the specified
{\it size
} and stores the data in
{\it buffer
}.
86 This function tries to read from the buffer first and if more data has been
87 requested, reads more data from the associated stream and updates the buffer
88 accordingly until all requested data is read.
90 \wxheading{Return value
}
92 It returns the size of the data read. If the returned size is different of the specified
93 {\it size
}, an error has occurred and should be tested using
94 \helpref{LastError
}{wxstreambaselasterror
}.
96 \func{size
\_t}{Read
}{\param{wxStreamBuffer *
}{buffer
}}
98 Reads a
{\it buffer
}. The function returns when
{\it buffer
} is full or when there isn't
99 data anymore in the current buffer.
103 \helpref{wxStreamBuffer::Write
}{wxstreambufferwrite
}
105 \membersection{wxStreamBuffer::Write
}\label{wxstreambufferwrite
}
107 \func{size
\_t}{Write
}{\param{const void *
}{buffer
},
\param{size
\_t }{size
}}
109 Writes a block of the specified
{\it size
} using data of
{\it buffer
}. The data
110 are cached in a buffer before being sent in one block to the stream.
112 \func{size
\_t}{Write
}{\param{wxStreamBuffer *
}{buffer
}}
114 See
\helpref{Read
}{wxstreambufferread
}.
116 \membersection{wxStreamBuffer::GetChar
}
118 \func{char
}{GetChar
}{\void}
120 Gets a single char from the stream buffer. It acts like the Read call.
124 You aren't directly notified if an error occurred during the IO call.
128 \helpref{wxStreamBuffer::Read
}{wxstreambufferread
}
130 \membersection{wxStreamBuffer::PutChar
}
132 \func{void
}{PutChar
}{\param{char
}{c
}}
134 Puts a single char to the stream buffer.
138 You aren't directly notified if an error occurred during the IO call.
142 \helpref{wxStreamBuffer::Read
}{wxstreambufferwrite
}
144 \membersection{wxStreamBuffer::Tell
}
146 \constfunc{off
\_t}{Tell
}{\void}
148 Gets the current position in the stream. This position is calculated from
149 the
{\it real
} position in the stream and from the internal buffer position: so
150 it gives you the position in the
{\it real
} stream counted from the start of
153 \wxheading{Return value
}
155 Returns the current position in the stream if possible, wxInvalidOffset in the
158 \membersection{wxStreamBuffer::Seek
}\label{wxstreambufferseek
}
160 \func{off
\_t}{Seek
}{\param{off
\_t }{pos
},
\param{wxSeekMode
}{mode
}}
162 Changes the current position.
164 {\it mode
} may be one of the following:
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.
}
173 \wxheading{Return value
}
175 Upon successful completion, it returns the new offset as measured in bytes from
176 the beginning of the stream. Otherwise, it returns wxInvalidOffset.
181 \membersection{wxStreamBuffer::ResetBuffer
}
183 \func{void
}{ResetBuffer
}{\void}
185 Resets to the initial state variables concerning the buffer.
187 \membersection{wxStreamBuffer::SetBufferIO
}\label{wxstreambuffersetbufferio
}
189 \func{void
}{SetBufferIO
}{\param{char*
}{ buffer
\_start},
\param{char*
}{ buffer
\_end}}
191 Specifies which pointers to use for stream buffering. You need to pass a pointer on the
192 start of the buffer end and another on the end. The object will use this buffer
193 to cache stream data. It may be used also as a source/destination buffer when
194 you create an empty stream buffer (See
\helpref{wxStreamBuffer::wxStreamBuffer
}{wxstreambufconst
}).
198 When you use this function, you will have to destroy the IO buffers yourself
199 after the stream buffer is destroyed or don't use it anymore.
200 In the case you use it with an empty buffer, the stream buffer will not resize
205 \helpref{wxStreamBuffer constructor
}{wxstreambufconst
}\\
206 \helpref{wxStreamBuffer::Fixed
}{wxstreambufferfixed
}\\
207 \helpref{wxStreamBuffer::Flushable
}{wxstreambufferflushable
}
209 \func{void
}{SetBufferIO
}{\param{size
\_t}{ bufsize
}}
211 Destroys or invalidates the previous IO buffer and allocates a new one of the
216 All previous pointers aren't valid anymore.
220 The created IO buffer is growable by the object.
224 \helpref{wxStreamBuffer::Fixed
}{wxstreambufferfixed
}\\
225 \helpref{wxStreamBuffer::Flushable
}{wxstreambufferflushable
}
227 \membersection{wxStreamBuffer::GetBufferStart
}
229 \constfunc{char *
}{GetBufferStart
}{\void}
231 Returns a pointer on the start of the stream buffer.
233 \membersection{wxStreamBuffer::GetBufferEnd
}
235 \constfunc{char *
}{GetBufferEnd
}{\void}
237 Returns a pointer on the end of the stream buffer.
239 \membersection{wxStreamBuffer::GetBufferPos
}
241 \constfunc{char *
}{GetBufferPos
}{\void}
243 Returns a pointer on the current position of the stream buffer.
245 \membersection{wxStreamBuffer::GetIntPosition
}
247 \constfunc{off
\_t}{GetIntPosition
}{\void}
249 Returns the current position (counted in bytes) in the stream buffer.
251 \membersection{wxStreamBuffer::SetIntPosition
}
253 \func{void
}{SetIntPosition
}{\void}
255 Sets the current position (in bytes) in the stream buffer.
259 Since it is a very low-level function, there is no check on the position:
260 specify an invalid position can induce unexpected results.
262 \membersection{wxStreamBuffer::GetLastAccess
}
264 \constfunc{size
\_t}{GetLastAccess
}{\void}
266 Returns the amount of bytes read during the last IO call to the parent stream.
268 \membersection{wxStreamBuffer::Fixed
}\label{wxstreambufferfixed
}
270 \func{void
}{Fixed
}{\param{bool
}{ fixed
}}
272 Toggles the fixed flag. Usually this flag is toggled at the same time as
273 {\it flushable
}. This flag allows (when it has the FALSE value) or forbids
274 (when it has the TRUE value) the stream buffer to resize dynamically the IO buffer.
278 \helpref{wxStreamBuffer::SetBufferIO
}{wxstreambuffersetbufferio
}
280 \membersection{wxStreamBuffer::Flushable
}\label{wxstreambufferflushable
}
282 \func{void
}{Flushable
}{\param{bool
}{ flushable
}}
284 Toggles the flushable flag. If
{\it flushable
} is disabled, no data are sent
285 to the parent stream.
287 \membersection{wxStreamBuffer::FlushBuffer
}
289 \func{bool
}{FlushBuffer
}{\void}
291 Flushes the IO buffer.
293 \membersection{wxStreamBuffer::FillBuffer
}
295 \func{bool
}{FillBuffer
}{\void}
299 \membersection{wxStreamBuffer::GetDataLeft
}
301 \func{size
\_t}{GetDataLeft
}{\void}
303 Returns the amount of available data in the buffer.
308 \membersection{wxStreamBuffer::Stream
}
310 \func{wxStreamBase*
}{Stream
}{\void}
312 Returns the parent stream of the stream buffer.