1 \section{\class{wxStreamBuffer
}}\label{wxstreambuffer
}
3 \wxheading{Derived from
}
7 \wxheading{Include files
}
13 \helpref{wxBase
}{librarieslist
}
17 \helpref{wxStreamBase
}{wxstreambase
}
19 \latexignore{\rtfignore{\wxheading{Members
}}}
22 \membersection{wxStreamBuffer::wxStreamBuffer
}\label{wxstreambufferctor
}
24 \func{}{wxStreamBuffer
}{\param{wxStreamBase\&
}{ stream
},
\param{BufMode
}{ mode
}}
26 Constructor, creates a new stream buffer using
{\it stream
} as a parent stream
27 and
{\it mode
} as the IO mode.
{\it mode
} can be: wxStreamBuffer::read,
28 wxStreamBuffer::write, wxStreamBuffer::read
\_write.
30 One stream can have many stream buffers but only one is used internally to
31 pass IO call (e.g. wxInputStream::Read() -> wxStreamBuffer::Read()), but you
32 can call directly wxStreamBuffer::Read without any problems. Note that
33 all errors and messages linked to the stream are stored in the stream, not
37 streambuffer.Read(...);
38 streambuffer2.Read(...); /* This call erases previous error messages set by
42 \func{}{wxStreamBuffer
}{\param{BufMode
}{ mode
}}
44 Constructor, creates a new empty stream buffer which won't flush any data
45 to a stream.
{\it mode
} specifies the type of the buffer (read, write, read
\_write).
46 This stream buffer has the advantage to be stream independent and to
47 work only on memory buffers but it is still compatible with the rest of the
48 wxStream classes. You can write, read to this special stream and it will
49 grow (if it is allowed by the user) its internal buffer. Briefly, it has all
50 functionality of a ``normal'' stream.
54 The "read
\_write" mode doesn't currently work for standalone stream buffers.
56 \func{}{wxStreamBuffer
}{\param{const wxStreamBuffer\&
}{buffer
}}
58 Constructor. It initializes the stream buffer with the data of the specified
59 stream buffer. The new stream buffer has the same attributes, size, position
60 and they share the same buffer. This will cause problems if the stream to
61 which the stream buffer belong is destroyed and the newly cloned stream
62 buffer continues to be used, trying to call functions in the (destroyed)
63 stream. It is advised to use this feature only in very local area of the
68 \helpref{wxStreamBuffer:SetBufferIO
}{wxstreambuffersetbufferio
}
71 \membersection{wxStreamBuffer::
\destruct{wxStreamBuffer
}}\label{wxstreambufferdtor
}
73 \func{}{wxStreamBuffer
}{\destruct{wxStreamBuffer
}}
75 Destructor. It finalizes all IO calls and frees all internal buffers if
79 \membersection{wxStreamBuffer::FillBuffer
}\label{wxstreambufferfillbuffer
}
81 \func{bool
}{FillBuffer
}{\void}
86 \membersection{wxStreamBuffer::Fixed
}\label{wxstreambufferfixed
}
88 \func{void
}{Fixed
}{\param{bool
}{ fixed
}}
90 Toggles 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.
96 \helpref{wxStreamBuffer::SetBufferIO
}{wxstreambuffersetbufferio
}
99 \membersection{wxStreamBuffer::Flushable
}\label{wxstreambufferflushable
}
101 \func{void
}{Flushable
}{\param{bool
}{ flushable
}}
103 Toggles the flushable flag. If
{\it flushable
} is disabled, no data are sent
104 to the parent stream.
107 \membersection{wxStreamBuffer::FlushBuffer
}\label{wxstreambufferflushbuffer
}
109 \func{bool
}{FlushBuffer
}{\void}
111 Flushes the IO buffer.
114 \membersection{wxStreamBuffer::GetBufferEnd
}\label{wxstreambuffergetbufferend
}
116 \constfunc{void *
}{GetBufferEnd
}{\void}
118 Returns a pointer on the end of the stream buffer.
121 \membersection{wxStreamBuffer::GetBufferPos
}\label{wxstreambuffergetbufferpos
}
123 \constfunc{void *
}{GetBufferPos
}{\void}
125 Returns a pointer on the current position of the stream buffer.
128 \membersection{wxStreamBuffer::GetBufferSize
}\label{wxstreambuffergetbuffersize
}
130 \constfunc{size
\_t}{GetBufferSize
}{\void}
132 Returns the size of the buffer.
135 \membersection{wxStreamBuffer::GetBufferStart
}\label{wxstreambuffergetbufferstart
}
137 \constfunc{void *
}{GetBufferStart
}{\void}
139 Returns a pointer on the start of the stream buffer.
142 \membersection{wxStreamBuffer::GetChar
}\label{wxstreambuffergetchar
}
144 \func{char
}{GetChar
}{\void}
146 Gets a single char from the stream buffer. It acts like the Read call.
150 You aren't directly notified if an error occurred during the IO call.
154 \helpref{wxStreamBuffer::Read
}{wxstreambufferread
}
157 \membersection{wxStreamBuffer::GetDataLeft
}\label{wxstreambuffergetdataleft
}
159 \func{size
\_t}{GetDataLeft
}{\void}
161 Returns the amount of available data in the buffer.
164 \membersection{wxStreamBuffer::GetIntPosition
}\label{wxstreambuffergetintposition
}
166 \constfunc{off
\_t}{GetIntPosition
}{\void}
168 Returns the current position (counted in bytes) in the stream buffer.
171 \membersection{wxStreamBuffer::GetLastAccess
}\label{wxstreambuffergetlastaccess
}
173 \constfunc{size
\_t}{GetLastAccess
}{\void}
175 Returns the amount of bytes read during the last IO call to the parent stream.
178 \membersection{wxStreamBuffer::PutChar
}\label{wxstreambufferputchar
}
180 \func{void
}{PutChar
}{\param{char
}{c
}}
182 Puts a single char to the stream buffer.
186 You aren't directly notified if an error occurred during the IO call.
190 \helpref{wxStreamBuffer::Read
}{wxstreambufferwrite
}
193 \membersection{wxStreamBuffer::Read
}\label{wxstreambufferread
}
195 \func{size
\_t}{Read
}{\param{void *
}{buffer
},
\param{size
\_t }{size
}}
197 Reads a block of the specified
{\it size
} and stores the data in
{\it buffer
}.
198 This function tries to read from the buffer first and if more data has been
199 requested, reads more data from the associated stream and updates the buffer
200 accordingly until all requested data is read.
202 \wxheading{Return value
}
204 It 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
}.
208 \func{size
\_t}{Read
}{\param{wxStreamBuffer *
}{buffer
}}
210 Copies data to
{\it buffer
}. The function returns when
{\it buffer
} is full or when there isn't
211 any more data in the current buffer.
215 \helpref{wxStreamBuffer::Write
}{wxstreambufferwrite
}
218 \membersection{wxStreamBuffer::ResetBuffer
}\label{wxstreambufferresetbuffer
}
220 \func{void
}{ResetBuffer
}{\void}
222 Resets to the initial state variables concerning the buffer.
225 \membersection{wxStreamBuffer::Seek
}\label{wxstreambufferseek
}
227 \func{off
\_t}{Seek
}{\param{off
\_t }{pos
},
\param{wxSeekMode
}{mode
}}
229 Changes the current position.
231 {\it mode
} may be one of the following:
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.
}
240 \wxheading{Return value
}
242 Upon successful completion, it returns the new offset as measured in bytes from
243 the beginning of the stream. Otherwise, it returns wxInvalidOffset.
246 \membersection{wxStreamBuffer::SetBufferIO
}\label{wxstreambuffersetbufferio
}
248 \func{void
}{SetBufferIO
}{\param{char*
}{ buffer
\_start},
\param{char*
}{ buffer
\_end}}
250 Specifies which pointers to use for stream buffering. You need to pass a pointer on the
251 start of the buffer end and another on the end. The object will use this buffer
252 to cache stream data. It may be used also as a source/destination buffer when
253 you create an empty stream buffer (See
\helpref{wxStreamBuffer::wxStreamBuffer
}{wxstreambufferctor
}).
257 When you use this function, you will have to destroy the IO buffers yourself
258 after the stream buffer is destroyed or don't use it anymore.
259 In the case you use it with an empty buffer, the stream buffer will not resize
264 \helpref{wxStreamBuffer constructor
}{wxstreambufferctor
}\\
265 \helpref{wxStreamBuffer::Fixed
}{wxstreambufferfixed
}\\
266 \helpref{wxStreamBuffer::Flushable
}{wxstreambufferflushable
}
268 \func{void
}{SetBufferIO
}{\param{size
\_t}{ bufsize
}}
270 Destroys or invalidates the previous IO buffer and allocates a new one of the
275 All previous pointers aren't valid anymore.
279 The created IO buffer is growable by the object.
283 \helpref{wxStreamBuffer::Fixed
}{wxstreambufferfixed
}\\
284 \helpref{wxStreamBuffer::Flushable
}{wxstreambufferflushable
}
287 \membersection{wxStreamBuffer::SetIntPosition
}\label{wxstreambuffersetintposition
}
289 \func{void
}{SetIntPosition
}{\param{size
\_t}{ pos
}}
291 Sets the current position (in bytes) in the stream buffer.
295 Since it is a very low-level function, there is no check on the position:
296 specifying an invalid position can induce unexpected results.
299 \membersection{wxStreamBuffer::Stream
}\label{wxstreambufferstream
}
301 \func{wxStreamBase*
}{Stream
}{\void}
303 Returns the parent stream of the stream buffer.
306 \membersection{wxStreamBuffer::Tell
}\label{wxstreambuffertell
}
308 \constfunc{off
\_t}{Tell
}{\void}
310 Gets the current position in the stream. This position is calculated from
311 the
{\it real
} position in the stream and from the internal buffer position: so
312 it gives you the position in the
{\it real
} stream counted from the start of
315 \wxheading{Return value
}
317 Returns the current position in the stream if possible, wxInvalidOffset in the
321 \membersection{wxStreamBuffer::Truncate
}\label{wxstreambuffertruncate
}
323 \func{void
}{Truncate
}{\void}
325 Truncates the buffer to the current position.
327 Note: Truncate() cannot be used to enlarge the buffer. This is
328 usually not needed since the buffer expands automatically.
331 \membersection{wxStreamBuffer::Write
}\label{wxstreambufferwrite
}
333 \func{size
\_t}{Write
}{\param{const void *
}{buffer
},
\param{size
\_t }{size
}}
335 Writes a block of the specified
{\it size
} using data of
{\it buffer
}. The data
336 are cached in a buffer before being sent in one block to the stream.
338 \func{size
\_t}{Write
}{\param{wxStreamBuffer *
}{buffer
}}
340 See
\helpref{Read
}{wxstreambufferread
}.