1 \section{\class{wxStreamBuffer
}}\label{wxstreambuffer
}
3 \wxheading{Derived from
}
9 \helpref{wxStreamBase
}{wxstreambase
}
11 % ---------------------------------------------------------------------------
13 % ---------------------------------------------------------------------------
14 \latexignore{\rtfignore{\wxheading{Members
}}}
19 \membersection{wxStreamBuffer::wxStreamBuffer
}\label{wxstreambufconst
}
21 \func{}{wxStreamBuffer
}{\param{wxStreamBase\&
}{ stream
},
\param{BufMode
}{ mode
}}
23 Constructor, creates a new stream buffer using
\it{stream
} as a parent stream
24 and
\it{mode
} as the IO mode.
\it{mode
} can be: wxStreamBuffer::read,
25 wxStreamBuffer::write, wxStreamBuffer::read
\_write.
26 One stream can have many stream buffers but only one is used internally to
27 pass IO call (e.g. wxInputStream::Read() -> wxStreamBuffer::Read()). But you
28 can call directly wxStreamBuffer::Read without any problems.
32 All errors and messages linked to the stream are stored in the stream object.
34 streambuffer.Read(...);
35 streambuffer2.Read(...); /* This one erases previous error messages set by
39 \func{}{wxStreamBuffer
}{\param{BufMode
}{ mode
}}
41 Constructor, creates a new empty stream buffer which won't flush any data
42 to a stream.
\it{mode
} specifies the type of the buffer (read, write, read
\_write). This stream buffer has the advantage to be stream independent and to
43 work only on memory buffers but it is still compatible with the rest of the
44 wxStream classes. You can write, read to this special stream and it will
45 grow (if it is allowed by the user) its internal buffer. Briefly, it has all
46 functionnalities of a ``normal'' stream.
50 The "read
\_write" mode may not work: it isn't completely finished.
54 \helpref{wxStreamBuffer:SetBufferIO
}{wxstreambufsetbufferio
}
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 is nearly exactly the same as the
60 original: it has the same attributes, the same size, the same position, shares
61 the same internal buffer. The interresting point is that they can differ
62 in the future but the root is the same.
66 The fact that the two stream buffers shared the same buffer could generate
67 segmentation violation if the parent is destroyed and the children continues
68 operating. It is advised to use this feature only in very local area of the
71 \membersection{wxStreamBuffer::
\destruct{wxStreamBuffer
}}
73 \func{}{wxStreamBuffer
}{\destruct{wxStreamBuffer
}}
75 Destructor. It finalizes all IO calls and frees all internal buffers if
76 necessary. In the case of a children stream buffer, the internal buffer isn't
77 freed, this is the job of the parent.
78 The "Write-Back" buffer is freed.
83 \membersection{wxStreamBuffer::Read
}\label{wxstreambufread
}
85 \func{size
\_t}{Read
}{\param{void *
}{buffer
},
\param{size
\_t }{size
}}
87 Reads a block of the specified
\it{size
} and stores datas in
\it{buffer
}.
88 This function uses also the "Write-Back" buffer: in the case there are datas
89 waiting in this buffer, they are used before anything else. After that, if there
90 are still datas to be read, the stream is read and the stream buffer position
93 \wxheading{Return value
}
95 It returns the real read size. If returned size is different of the specified
96 \it{size
}, an error occured and should be tested using
97 \helpref{LastError
}{wxstreambaselasterror
}.
101 \helpref{wxStreamBuffer::WriteBack
}{wxstreambufwriteback
}
103 \func{size
\_t}{Read
}{\param{wxStreamBuffer *
}{buffer
}}
105 Reads a
\it{buffer
}. The function returns when
\it{buffer
} is full or
106 when there aren't datas anymore in the current buffer.
108 \membersection{wxStreamBuffer::Write
}
110 \func{size
\_t}{Write
}{\param{const void *
}{buffer
},
\param{size
\_t }{size
}}
112 Writes a block of the specified
\it{size
} using datas of
\it{buffer
}. The datas
113 are cached in a buffer before being sent in one block to the stream.
115 \func{size
\_t}{Write
}{\param{wxStreamBuffer *
}{buffer
}}
117 See
\helpref{Read
}{wxstreambufreadbuf
}
119 \membersection{wxStreamBuffer::WriteBack
}\label{wxstreambufwriteback
}
121 \func{size
\_t}{WriteBack
}{\param{const char*
}{ buffer
},
\param{size
\_t}{ size
}}
123 This function is only useful in
\it{read
} mode. It is the manager of the "Write-Back"
124 buffer. This buffer acts like a temporary buffer where datas which has to be
125 read during the next read IO call are put. This is useful when you get a big
126 block of data which you didn't want to read: you can replace them at the top
127 of the input queue by this way.
129 \wxheading{Return value
}
131 Returns the amount of bytes saved in the Write-Back buffer.
133 \func{size
\_t}{WriteBack
}{\param{char
}{c
}}
135 This function acts like the previous one except that it takes only one
136 character: it is sometimes shorter to use than the generic function.
138 \membersection{wxStreamBuffer::GetChar
}
140 \func{char
}{GetChar
}{\void}
142 Gets a single char from the stream buffer. It acts like the Read call.
146 You aren't directly notified if an error occured during the IO call.
150 \helpref{wxStreamBuffer::Read
}{wxstreambufread
}
152 \membersection{wxStreamBuffer::PutChar
}
154 \func{void
}{PutChar
}{\param{char
}{c
}}
156 Puts a single char to the stream buffer.
160 You aren't directly notified if an error occured during the IO call.
164 \helpref{wxStreamBuffer::Read
}{wxstreambufwrite
}
166 \membersection{wxStreamBuffer::Tell
}
168 \constfunc{off
\_t}{Tell
}{\void}
170 Gets the current position in the stream. This position is calculated from
171 the
\it{real
} position in the stream and from the internal buffer position: so
172 it gives you the position in the
\it{real
} stream counted from the start of
175 \wxheading{Return value
}
177 Returns the current position in the stream if possible, wxInvalidOffset in the
180 \membersection{wxStreamBuffer::Seek
}\label{wxstreambufferseek
}
182 \func{off
\_t}{Seek
}{\param{off
\_t }{pos
},
\param{wxSeekMode
}{mode
}}
184 Changes the current position.
186 \it{mode
} may be one of the following:
189 \begin{twocollist
}\itemsep=
0pt
190 \twocolitem{{\bf wxFromStart
}}{The position is counted from the start of the stream.
}
191 \twocolitem{{\bf wxFromCurrent
}}{The position is counted from the current position of the stream.
}
192 \twocolitem{{\bf wxFromEnd
}}{The position is counted from the end of the stream.
}
195 \wxheading{Return value
}
197 Upon successful completion, it returns the new offset as measured in bytes from
198 the beginning of the stream. Otherwise, it returns wxInvalidOffset.
203 \membersection{wxStreamBuffer::ResetBuffer
}
205 \func{void
}{ResetBuffer
}{\void}
207 Resets to the initial state variables concerning the buffer.
209 \membersection{wxStreamBuffer::SetBufferIO
}\label{wxstreambufsetbufferio
}
211 \func{void
}{SetBufferIO
}{\param{char*
}{ buffer
\_start},
\param{char*
}{ buffer
\_end}}
213 Specifies which pointers to use for stream buffering. You need to pass a pointer on the
214 start of the buffer end and another on the end. The object will use this buffer
215 to cache stream data. It may be used also as a source/destination buffer when
216 you create an empty stream buffer (See
\helpref{wxStreamBuffer::wxStreamBuffer
}{wxstreambufconst
}).
220 When you use this function, you'll have to destroy the IO buffers yourself
221 after the stream buffer is destroyed or don't use it anymore.
222 In the case you use it with an empty buffer, the stream buffer will not grow
227 \helpref{wxStreamBuffer constructor
}{wxstreambufconst
}\\
228 \helpref{wxStreamBuffer::Fixed
}{wxstreambuffixed
}\\
229 \helpref{wxStreamBuffer::Flushable
}{wxstreambufflushable
}
231 \func{void
}{SetBufferIO
}{\param{size
\_t}{ bufsize
}}
233 Destroys or invalidates the previous IO buffer and allocates a new one of the
238 All previous pointers aren't valid anymore.
242 The created IO buffer is growable by the object.
246 \helpref{wxStreamBuffer::Fixed
}{wxstreambuffixed
}\\
247 \helpref{wxStreamBuffer::Flushable
}{wxstreambufflushable
}
249 \membersection{wxStreamBuffer::GetBufferStart
}
251 \constfunc{char *
}{GetBufferStart
}{\void}
253 Returns a pointer on the start of the stream buffer.
255 \membersection{wxStreamBuffer::GetBufferEnd
}
257 \constfunc{char *
}{GetBufferEnd
}{\void}
259 Returns a pointer on the end of the stream buffer.
261 \membersection{wxStreamBuffer::GetBufferPos
}
263 \constfunc{char *
}{GetBufferPos
}{\void}
265 Returns a pointer on the current position of the stream buffer.
267 \membersection{wxStreamBuffer::GetIntPosition
}
269 \constfunc{off
\_t}{GetIntPosition
}{\void}
271 Returns the current position (counted in bytes) in the stream buffer.
273 \membersection{wxStreamBuffer::SetIntPosition
}
275 \func{void
}{SetIntPosition
}{\void}
277 Sets the current position in the stream buffer.
279 \membersection{wxStreamBuffer::GetLastAccess
}
281 \constfunc{size
\_t}{GetLastAccess
}{\void}
283 Returns the amount of bytes read during the last IO call to the parent stream.
285 \membersection{wxStreamBuffer::Fixed
}
287 \func{void
}{Fixed
}{\param{bool
}{ fixed
}}
289 Toggles the fixed flag. Usually this flag is toggled at the same time as
290 \it{flushable
}. This flag allows (when it has the FALSE value) or forbids
291 (when it has the TRUE value) the stream buffer to resize dynamically the IO buffer.
295 \helpref{wxStreamBuffer::SetBufferIO
}{wxstreambufsetbufferio
}
297 \membersection{wxStreamBuffer::Flushable
}
299 \func{void
}{Flushable
}{\param{bool
}{ flushable
}}
301 Toggles the flushable flag. If
\it{flushable
} is disabled, no datas are sent
302 to the parent stream.
304 \membersection{wxStreamBuffer::FlushBuffer
}
306 \func{bool
}{FlushBuffer
}{\void}
308 Flushes the IO buffer.
310 \membersection{wxStreamBuffer::FillBuffer
}
312 \func{bool
}{FillBuffer
}{\void}
316 \membersection{wxStreamBuffer::GetDataLeft
}
318 \func{size
\_t}{GetDataLeft
}{\void}
320 Returns the amount of available datas in the buffer.
325 \membersection{wxStreamBuffer::Stream
}
327 \func{wxStreamBase*
}{Stream
}{\void}
329 Returns the parent stream of the stream buffer.