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.
32 One stream can have many stream buffers but only one is used internally to
33 pass IO call (e.g. wxInputStream::Read() -> wxStreamBuffer::Read()), but you
34 can call directly wxStreamBuffer::Read without any problems. Note that
35 all errors and messages linked to the stream are stored in the stream, not
39 streambuffer.Read(...);
40 streambuffer2.Read(...); /* This call erases previous error messages set by
44 \func{}{wxStreamBuffer
}{\param{BufMode
}{ mode
}}
46 Constructor, creates a new empty stream buffer which won't flush any data
47 to a stream.
{\it mode
} specifies the type of the buffer (read, write, read
\_write).
48 This stream buffer has the advantage to be stream independent and to
49 work only on memory buffers but it is still compatible with the rest of the
50 wxStream classes. You can write, read to this special stream and it will
51 grow (if it is allowed by the user) its internal buffer. Briefly, it has all
52 functionality of a ``normal'' stream.
56 The "read
\_write" mode may not work: it isn't completely finished.
58 \func{}{wxStreamBuffer
}{\param{const wxStreamBuffer\&
}{buffer
}}
60 Constructor. It initializes the stream buffer with the data of the specified
61 stream buffer. The new stream buffer has the same attributes, size, position
62 and they share the same buffer. This will cause problems if the stream to
63 which the stream buffer belong is destroyed and the newly cloned stream
64 buffer continues to be used, trying to call functions in the (destroyed)
65 stream. It is advised to use this feature only in very local area of the
70 \helpref{wxStreamBuffer:SetBufferIO
}{wxstreambuffersetbufferio
}
72 \membersection{wxStreamBuffer::
\destruct{wxStreamBuffer
}}
74 \func{}{wxStreamBuffer
}{\destruct{wxStreamBuffer
}}
76 Destructor. It finalizes all IO calls and frees all internal buffers if
82 \membersection{wxStreamBuffer::Read
}\label{wxstreambufferread
}
84 \func{size
\_t}{Read
}{\param{void *
}{buffer
},
\param{size
\_t }{size
}}
86 Reads a block of the specified
{\it size
} and stores the data in
{\it buffer
}.
87 This function tries to read from the buffer first and if more data has been
88 requested, reads more data from the associated stream and updates the buffer
89 accordingly until all requested data is read.
91 \wxheading{Return value
}
93 It returns the size of the data read. If thereturned size is different of the specified
94 {\it size
}, an error has occured and should be tested using
95 \helpref{LastError
}{wxstreambaselasterror
}.
97 \func{size
\_t}{Read
}{\param{wxStreamBuffer *
}{buffer
}}
99 Reads a
{\it buffer
}. The function returns when
{\it buffer
} is full or when there isn't
100 data anymore in the current buffer.
104 \helpref{wxStreamBuffer::Write
}{wxstreambufferwrite
}
106 \membersection{wxStreamBuffer::Write
}\label{wxstreambufferwrite
}
108 \func{size
\_t}{Write
}{\param{const void *
}{buffer
},
\param{size
\_t }{size
}}
110 Writes a block of the specified
{\it size
} using datas of
{\it buffer
}. The datas
111 are cached in a buffer before being sent in one block to the stream.
113 \func{size
\_t}{Write
}{\param{wxStreamBuffer *
}{buffer
}}
115 See
\helpref{Read
}{wxstreambufferread
}.
117 \membersection{wxStreamBuffer::GetChar
}
119 \func{char
}{GetChar
}{\void}
121 Gets a single char from the stream buffer. It acts like the Read call.
125 You aren't directly notified if an error occured during the IO call.
129 \helpref{wxStreamBuffer::Read
}{wxstreambufferread
}
131 \membersection{wxStreamBuffer::PutChar
}
133 \func{void
}{PutChar
}{\param{char
}{c
}}
135 Puts a single char to the stream buffer.
139 You aren't directly notified if an error occured during the IO call.
143 \helpref{wxStreamBuffer::Read
}{wxstreambufferwrite
}
145 \membersection{wxStreamBuffer::Tell
}
147 \constfunc{off
\_t}{Tell
}{\void}
149 Gets the current position in the stream. This position is calculated from
150 the
{\it real
} position in the stream and from the internal buffer position: so
151 it gives you the position in the
{\it real
} stream counted from the start of
154 \wxheading{Return value
}
156 Returns the current position in the stream if possible, wxInvalidOffset in the
159 \membersection{wxStreamBuffer::Seek
}\label{wxstreambufferseek
}
161 \func{off
\_t}{Seek
}{\param{off
\_t }{pos
},
\param{wxSeekMode
}{mode
}}
163 Changes the current position.
165 {\it mode
} may be one of the following:
168 \begin{twocollist
}\itemsep=
0pt
169 \twocolitem{{\bf wxFromStart
}}{The position is counted from the start of the stream.
}
170 \twocolitem{{\bf wxFromCurrent
}}{The position is counted from the current position of the stream.
}
171 \twocolitem{{\bf wxFromEnd
}}{The position is counted from the end of the stream.
}
174 \wxheading{Return value
}
176 Upon successful completion, it returns the new offset as measured in bytes from
177 the beginning of the stream. Otherwise, it returns wxInvalidOffset.
182 \membersection{wxStreamBuffer::ResetBuffer
}
184 \func{void
}{ResetBuffer
}{\void}
186 Resets to the initial state variables concerning the buffer.
188 \membersection{wxStreamBuffer::SetBufferIO
}\label{wxstreambuffersetbufferio
}
190 \func{void
}{SetBufferIO
}{\param{char*
}{ buffer
\_start},
\param{char*
}{ buffer
\_end}}
192 Specifies which pointers to use for stream buffering. You need to pass a pointer on the
193 start of the buffer end and another on the end. The object will use this buffer
194 to cache stream data. It may be used also as a source/destination buffer when
195 you create an empty stream buffer (See
\helpref{wxStreamBuffer::wxStreamBuffer
}{wxstreambufconst
}).
199 When you use this function, you'll have to destroy the IO buffers yourself
200 after the stream buffer is destroyed or don't use it anymore.
201 In the case you use it with an empty buffer, the stream buffer will not resize
206 \helpref{wxStreamBuffer constructor
}{wxstreambufconst
}\\
207 \helpref{wxStreamBuffer::Fixed
}{wxstreambufferfixed
}\\
208 \helpref{wxStreamBuffer::Flushable
}{wxstreambufferflushable
}
210 \func{void
}{SetBufferIO
}{\param{size
\_t}{ bufsize
}}
212 Destroys or invalidates the previous IO buffer and allocates a new one of the
217 All previous pointers aren't valid anymore.
221 The created IO buffer is growable by the object.
225 \helpref{wxStreamBuffer::Fixed
}{wxstreambufferfixed
}\\
226 \helpref{wxStreamBuffer::Flushable
}{wxstreambufferflushable
}
228 \membersection{wxStreamBuffer::GetBufferStart
}
230 \constfunc{char *
}{GetBufferStart
}{\void}
232 Returns a pointer on the start of the stream buffer.
234 \membersection{wxStreamBuffer::GetBufferEnd
}
236 \constfunc{char *
}{GetBufferEnd
}{\void}
238 Returns a pointer on the end of the stream buffer.
240 \membersection{wxStreamBuffer::GetBufferPos
}
242 \constfunc{char *
}{GetBufferPos
}{\void}
244 Returns a pointer on the current position of the stream buffer.
246 \membersection{wxStreamBuffer::GetIntPosition
}
248 \constfunc{off
\_t}{GetIntPosition
}{\void}
250 Returns the current position (counted in bytes) in the stream buffer.
252 \membersection{wxStreamBuffer::SetIntPosition
}
254 \func{void
}{SetIntPosition
}{\void}
256 Sets the current position (in bytes) in the stream buffer.
260 Since it is a very low-level function, there is no check on the position:
261 specify an invalid position can induce unexpected results.
263 \membersection{wxStreamBuffer::GetLastAccess
}
265 \constfunc{size
\_t}{GetLastAccess
}{\void}
267 Returns the amount of bytes read during the last IO call to the parent stream.
269 \membersection{wxStreamBuffer::Fixed
}\label{wxstreambufferfixed
}
271 \func{void
}{Fixed
}{\param{bool
}{ fixed
}}
273 Toggles the fixed flag. Usually this flag is toggled at the same time as
274 {\it flushable
}. This flag allows (when it has the FALSE value) or forbids
275 (when it has the TRUE value) the stream buffer to resize dynamically the IO buffer.
279 \helpref{wxStreamBuffer::SetBufferIO
}{wxstreambuffersetbufferio
}
281 \membersection{wxStreamBuffer::Flushable
}\label{wxstreambufferflushable
}
283 \func{void
}{Flushable
}{\param{bool
}{ flushable
}}
285 Toggles the flushable flag. If
{\it flushable
} is disabled, no datas are sent
286 to the parent stream.
288 \membersection{wxStreamBuffer::FlushBuffer
}
290 \func{bool
}{FlushBuffer
}{\void}
292 Flushes the IO buffer.
294 \membersection{wxStreamBuffer::FillBuffer
}
296 \func{bool
}{FillBuffer
}{\void}
300 \membersection{wxStreamBuffer::GetDataLeft
}
302 \func{size
\_t}{GetDataLeft
}{\void}
304 Returns the amount of available datas in the buffer.
309 \membersection{wxStreamBuffer::Stream
}
311 \func{wxStreamBase*
}{Stream
}{\void}
313 Returns the parent stream of the stream buffer.