1 \section{\class{wxStreamBuffer
}}\label{wxstreambuffer
}
3 \wxheading{Derived from
}
7 \wxheading{Include files
}
13 \helpref{wxBase
}{librarieslist
}
17 \helpref{wxStreamBase
}{wxstreambase
}
19 % ---------------------------------------------------------------------------
21 % ---------------------------------------------------------------------------
22 \latexignore{\rtfignore{\wxheading{Members
}}}
27 \membersection{wxStreamBuffer::wxStreamBuffer
}\label{wxstreambufferctor
}
29 \func{}{wxStreamBuffer
}{\param{wxStreamBase\&
}{ stream
},
\param{BufMode
}{ mode
}}
31 Constructor, creates a new stream buffer using
{\it stream
} as a parent stream
32 and
{\it mode
} as the IO mode.
{\it mode
} can be: wxStreamBuffer::read,
33 wxStreamBuffer::write, wxStreamBuffer::read
\_write.
35 One stream can have many stream buffers but only one is used internally to
36 pass IO call (e.g. wxInputStream::Read() -> wxStreamBuffer::Read()), but you
37 can call directly wxStreamBuffer::Read without any problems. Note that
38 all errors and messages linked to the stream are stored in the stream, not
42 streambuffer.Read(...);
43 streambuffer2.Read(...); /* This call erases previous error messages set by
47 \func{}{wxStreamBuffer
}{\param{BufMode
}{ mode
}}
49 Constructor, creates a new empty stream buffer which won't flush any data
50 to a stream.
{\it mode
} specifies the type of the buffer (read, write, read
\_write).
51 This stream buffer has the advantage to be stream independent and to
52 work only on memory buffers but it is still compatible with the rest of the
53 wxStream classes. You can write, read to this special stream and it will
54 grow (if it is allowed by the user) its internal buffer. Briefly, it has all
55 functionality of a ``normal'' stream.
59 The "read
\_write" mode doesn't currently work for standalone stream buffers.
61 \func{}{wxStreamBuffer
}{\param{const wxStreamBuffer\&
}{buffer
}}
63 Constructor. It initializes the stream buffer with the data of the specified
64 stream buffer. The new stream buffer has the same attributes, size, position
65 and they share the same buffer. This will cause problems if the stream to
66 which the stream buffer belong is destroyed and the newly cloned stream
67 buffer continues to be used, trying to call functions in the (destroyed)
68 stream. It is advised to use this feature only in very local area of the
73 \helpref{wxStreamBuffer:SetBufferIO
}{wxstreambuffersetbufferio
}
75 \membersection{wxStreamBuffer::
\destruct{wxStreamBuffer
}}\label{wxstreambufferdtor
}
77 \func{}{wxStreamBuffer
}{\destruct{wxStreamBuffer
}}
79 Destructor. It finalizes all IO calls and frees all internal buffers if
85 \membersection{wxStreamBuffer::Read
}\label{wxstreambufferread
}
87 \func{size
\_t}{Read
}{\param{void *
}{buffer
},
\param{size
\_t }{size
}}
89 Reads a block of the specified
{\it size
} and stores the data in
{\it buffer
}.
90 This function tries to read from the buffer first and if more data has been
91 requested, reads more data from the associated stream and updates the buffer
92 accordingly until all requested data is read.
94 \wxheading{Return value
}
96 It returns the size of the data read. If the returned size is different of the specified
97 {\it size
}, an error has occurred and should be tested using
98 \helpref{GetLastError
}{wxstreambasegetlasterror
}.
100 \func{size
\_t}{Read
}{\param{wxStreamBuffer *
}{buffer
}}
102 Copies data to
{\it buffer
}. The function returns when
{\it buffer
} is full or when there isn't
103 any more data in the current buffer.
107 \helpref{wxStreamBuffer::Write
}{wxstreambufferwrite
}
109 \membersection{wxStreamBuffer::Write
}\label{wxstreambufferwrite
}
111 \func{size
\_t}{Write
}{\param{const void *
}{buffer
},
\param{size
\_t }{size
}}
113 Writes a block of the specified
{\it size
} using data of
{\it buffer
}. The data
114 are cached in a buffer before being sent in one block to the stream.
116 \func{size
\_t}{Write
}{\param{wxStreamBuffer *
}{buffer
}}
118 See
\helpref{Read
}{wxstreambufferread
}.
120 \membersection{wxStreamBuffer::GetChar
}\label{wxstreambuffergetchar
}
122 \func{char
}{GetChar
}{\void}
124 Gets a single char from the stream buffer. It acts like the Read call.
128 You aren't directly notified if an error occurred during the IO call.
132 \helpref{wxStreamBuffer::Read
}{wxstreambufferread
}
134 \membersection{wxStreamBuffer::PutChar
}\label{wxstreambufferputchar
}
136 \func{void
}{PutChar
}{\param{char
}{c
}}
138 Puts a single char to the stream buffer.
142 You aren't directly notified if an error occurred during the IO call.
146 \helpref{wxStreamBuffer::Read
}{wxstreambufferwrite
}
148 \membersection{wxStreamBuffer::Tell
}\label{wxstreambuffertell
}
150 \constfunc{off
\_t}{Tell
}{\void}
152 Gets the current position in the stream. This position is calculated from
153 the
{\it real
} position in the stream and from the internal buffer position: so
154 it gives you the position in the
{\it real
} stream counted from the start of
157 \wxheading{Return value
}
159 Returns the current position in the stream if possible, wxInvalidOffset in the
162 \membersection{wxStreamBuffer::Seek
}\label{wxstreambufferseek
}
164 \func{off
\_t}{Seek
}{\param{off
\_t }{pos
},
\param{wxSeekMode
}{mode
}}
166 Changes the current position.
168 {\it mode
} may be one of the following:
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.
}
177 \wxheading{Return value
}
179 Upon successful completion, it returns the new offset as measured in bytes from
180 the beginning of the stream. Otherwise, it returns wxInvalidOffset.
185 \membersection{wxStreamBuffer::ResetBuffer
}\label{wxstreambufferresetbuffer
}
187 \func{void
}{ResetBuffer
}{\void}
189 Resets to the initial state variables concerning the buffer.
192 \membersection{wxStreamBuffer::Truncate
}\label{wxstreambuffertruncate
}
194 \func{void
}{Truncate
}{\void}
196 Truncates the buffer to the current position.
198 Note: Truncate() cannot be used to enlarge the buffer. This is
199 usually not needed since the buffer expands automatically.
202 \membersection{wxStreamBuffer::SetBufferIO
}\label{wxstreambuffersetbufferio
}
204 \func{void
}{SetBufferIO
}{\param{char*
}{ buffer
\_start},
\param{char*
}{ buffer
\_end}}
206 Specifies which pointers to use for stream buffering. You need to pass a pointer on the
207 start of the buffer end and another on the end. The object will use this buffer
208 to cache stream data. It may be used also as a source/destination buffer when
209 you create an empty stream buffer (See
\helpref{wxStreamBuffer::wxStreamBuffer
}{wxstreambufferctor
}).
213 When you use this function, you will have to destroy the IO buffers yourself
214 after the stream buffer is destroyed or don't use it anymore.
215 In the case you use it with an empty buffer, the stream buffer will not resize
220 \helpref{wxStreamBuffer constructor
}{wxstreambufferctor
}\\
221 \helpref{wxStreamBuffer::Fixed
}{wxstreambufferfixed
}\\
222 \helpref{wxStreamBuffer::Flushable
}{wxstreambufferflushable
}
224 \func{void
}{SetBufferIO
}{\param{size
\_t}{ bufsize
}}
226 Destroys or invalidates the previous IO buffer and allocates a new one of the
231 All previous pointers aren't valid anymore.
235 The created IO buffer is growable by the object.
239 \helpref{wxStreamBuffer::Fixed
}{wxstreambufferfixed
}\\
240 \helpref{wxStreamBuffer::Flushable
}{wxstreambufferflushable
}
242 \membersection{wxStreamBuffer::GetBufferStart
}\label{wxstreambuffergetbufferstart
}
244 \constfunc{void *
}{GetBufferStart
}{\void}
246 Returns a pointer on the start of the stream buffer.
248 \membersection{wxStreamBuffer::GetBufferEnd
}\label{wxstreambuffergetbufferend
}
250 \constfunc{void *
}{GetBufferEnd
}{\void}
252 Returns a pointer on the end of the stream buffer.
254 \membersection{wxStreamBuffer::GetBufferPos
}\label{wxstreambuffergetbufferpos
}
256 \constfunc{void *
}{GetBufferPos
}{\void}
258 Returns a pointer on the current position of the stream buffer.
260 \membersection{wxStreamBuffer::GetIntPosition
}\label{wxstreambuffergetintposition
}
262 \constfunc{off
\_t}{GetIntPosition
}{\void}
264 Returns the current position (counted in bytes) in the stream buffer.
266 \membersection{wxStreamBuffer::SetIntPosition
}\label{wxstreambuffersetintposition
}
268 \func{void
}{SetIntPosition
}{\param{size
\_t}{ pos
}}
270 Sets the current position (in bytes) in the stream buffer.
274 Since it is a very low-level function, there is no check on the position:
275 specifying an invalid position can induce unexpected results.
277 \membersection{wxStreamBuffer::GetLastAccess
}\label{wxstreambuffergetlastaccess
}
279 \constfunc{size
\_t}{GetLastAccess
}{\void}
281 Returns the amount of bytes read during the last IO call to the parent stream.
283 \membersection{wxStreamBuffer::Fixed
}\label{wxstreambufferfixed
}
285 \func{void
}{Fixed
}{\param{bool
}{ fixed
}}
287 Toggles the fixed flag. Usually this flag is toggled at the same time as
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.
293 \helpref{wxStreamBuffer::SetBufferIO
}{wxstreambuffersetbufferio
}
295 \membersection{wxStreamBuffer::Flushable
}\label{wxstreambufferflushable
}
297 \func{void
}{Flushable
}{\param{bool
}{ flushable
}}
299 Toggles the flushable flag. If
{\it flushable
} is disabled, no data are sent
300 to the parent stream.
302 \membersection{wxStreamBuffer::FlushBuffer
}\label{wxstreambufferflushbuffer
}
304 \func{bool
}{FlushBuffer
}{\void}
306 Flushes the IO buffer.
308 \membersection{wxStreamBuffer::FillBuffer
}\label{wxstreambufferfillbuffer
}
310 \func{bool
}{FillBuffer
}{\void}
314 \membersection{wxStreamBuffer::GetBufferSize
}\label{wxstreambuffergetbuffersize
}
316 \constfunc{size
\_t}{GetBufferSize
}{\void}
318 Returns the size of the buffer.
320 \membersection{wxStreamBuffer::GetDataLeft
}\label{wxstreambuffergetdataleft
}
322 \func{size
\_t}{GetDataLeft
}{\void}
324 Returns the amount of available data in the buffer.
329 \membersection{wxStreamBuffer::Stream
}\label{wxstreambufferstream
}
331 \func{wxStreamBase*
}{Stream
}{\void}
333 Returns the parent stream of the stream buffer.