]>
Commit | Line | Data |
---|---|---|
e2a6f233 | 1 | \section{\class{wxStreamBuffer}}\label{wxstreambuffer} |
7da42094 | 2 | |
b82827dd JS |
3 | \wxheading{Derived from} |
4 | ||
5 | None | |
6 | ||
7da42094 | 7 | \wxheading{See also} |
b82827dd | 8 | |
7da42094 GL |
9 | \helpref{wxStreamBase}{wxstreambase} |
10 | ||
11 | % --------------------------------------------------------------------------- | |
12 | % Members | |
13 | % --------------------------------------------------------------------------- | |
7da42094 GL |
14 | \latexignore{\rtfignore{\wxheading{Members}}} |
15 | ||
16 | % ----------- | |
17 | % ctor & dtor | |
18 | % ----------- | |
da3aea64 | 19 | \membersection{wxStreamBuffer::wxStreamBuffer}\label{wxstreambufconst} |
b82827dd JS |
20 | |
21 | \func{}{wxStreamBuffer}{\param{wxStreamBase\&}{ stream}, \param{BufMode}{ mode}} | |
7da42094 GL |
22 | |
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, | |
b82827dd | 25 | wxStreamBuffer::write, wxStreamBuffer::read\_write. |
07b73270 GL |
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. | |
7da42094 | 29 | |
07b73270 GL |
30 | \wxheading{Warning} |
31 | ||
32 | All errors and messages linked to the stream are stored in the stream object. | |
33 | \begin{verbatim} | |
34 | streambuffer.Read(...); | |
35 | streambuffer2.Read(...); /* This one erases previous error messages set by | |
36 | ``streambuffer'' */ | |
37 | \end{verbatim} | |
b82827dd | 38 | |
7da42094 GL |
39 | \func{}{wxStreamBuffer}{\param{BufMode}{ mode}} |
40 | ||
e2a6f233 | 41 | Constructor, creates a new empty stream buffer which won't flush any data |
07b73270 GL |
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. | |
7da42094 | 47 | |
07b73270 GL |
48 | \wxheading{Warning} |
49 | ||
50 | The "read\_write" mode may not work: it isn't completely finished. | |
51 | ||
52 | \wxheading{See also} | |
53 | ||
54 | \helpref{wxStreamBuffer:SetBufferIO}{wxstreambufsetbufferio} | |
55 | ||
56 | \func{}{wxStreamBuffer}{\param{const wxStreamBuffer &}{buffer}} | |
57 | ||
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. | |
b82827dd | 63 | |
07b73270 | 64 | \wxheading{Warning} |
7da42094 | 65 | |
07b73270 GL |
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 | |
69 | program. | |
7da42094 | 70 | |
b82827dd JS |
71 | \membersection{wxStreamBuffer::\destruct{wxStreamBuffer}} |
72 | ||
e2a6f233 | 73 | \func{}{wxStreamBuffer}{\destruct{wxStreamBuffer}} |
7da42094 | 74 | |
07b73270 GL |
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. | |
7da42094 GL |
79 | |
80 | % ----------- | |
81 | % Filtered IO | |
82 | % ----------- | |
7da42094 | 83 | \membersection{wxStreamBuffer::Read}\label{wxstreambufread} |
b82827dd JS |
84 | |
85 | \func{size\_t}{Read}{\param{void *}{buffer}, \param{size\_t }{size}} | |
7da42094 GL |
86 | |
87 | Reads a block of the specified \it{size} and stores datas in \it{buffer}. | |
07b73270 GL |
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 | |
91 | is incremented. | |
7da42094 GL |
92 | |
93 | \wxheading{Return value} | |
94 | ||
b82827dd JS |
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 | |
e2a6f233 | 97 | \helpref{LastError}{wxstreambaselasterror}. |
7da42094 | 98 | |
07b73270 GL |
99 | \wxheading{See also} |
100 | ||
101 | \helpref{wxStreamBuffer::WriteBack}{wxstreambufwriteback} | |
b82827dd JS |
102 | |
103 | \func{size\_t}{Read}{\param{wxStreamBuffer *}{buffer}} | |
7da42094 GL |
104 | |
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. | |
107 | ||
108 | \membersection{wxStreamBuffer::Write} | |
b82827dd JS |
109 | |
110 | \func{size\_t}{Write}{\param{const void *}{buffer}, \param{size\_t }{size}} | |
7da42094 | 111 | |
07b73270 GL |
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. | |
b82827dd JS |
114 | |
115 | \func{size\_t}{Write}{\param{wxStreamBuffer *}{buffer}} | |
7da42094 GL |
116 | |
117 | See \helpref{Read}{wxstreambufreadbuf} | |
118 | ||
07b73270 | 119 | \membersection{wxStreamBuffer::WriteBack}\label{wxstreambufwriteback} |
b82827dd | 120 | |
06ad8636 | 121 | \func{size\_t}{WriteBack}{\param{const char*}{ buffer}, \param{size\_t}{ size}} |
7da42094 | 122 | |
07b73270 GL |
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. | |
7da42094 | 128 | |
07b73270 GL |
129 | \wxheading{Return value} |
130 | ||
131 | Returns the amount of bytes saved in the Write-Back buffer. | |
b82827dd JS |
132 | |
133 | \func{size\_t}{WriteBack}{\param{char }{c}} | |
7da42094 | 134 | |
07b73270 GL |
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. | |
7da42094 GL |
137 | |
138 | \membersection{wxStreamBuffer::GetChar} | |
b82827dd | 139 | |
7da42094 GL |
140 | \func{char}{GetChar}{\void} |
141 | ||
07b73270 GL |
142 | Gets a single char from the stream buffer. It acts like the Read call. |
143 | ||
144 | \wxheading{Problem} | |
145 | ||
146 | You aren't directly notified if an error occured during the IO call. | |
147 | ||
148 | \wxheading{See also} | |
149 | ||
150 | \helpref{wxStreamBuffer::Read}{wxstreambufread} | |
7da42094 GL |
151 | |
152 | \membersection{wxStreamBuffer::PutChar} | |
b82827dd | 153 | |
7da42094 GL |
154 | \func{void}{PutChar}{\param{char }{c}} |
155 | ||
156 | Puts a single char to the stream buffer. | |
157 | ||
07b73270 GL |
158 | \wxheading{Problem} |
159 | ||
160 | You aren't directly notified if an error occured during the IO call. | |
161 | ||
162 | \wxheading{See also} | |
163 | ||
164 | \helpref{wxStreamBuffer::Read}{wxstreambufwrite} | |
165 | ||
7da42094 | 166 | \membersection{wxStreamBuffer::Tell} |
b82827dd JS |
167 | |
168 | \constfunc{off\_t}{Tell}{\void} | |
7da42094 | 169 | |
07b73270 GL |
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 | |
173 | the stream. | |
174 | ||
175 | \wxheading{Return value} | |
176 | ||
177 | Returns the current position in the stream if possible, wxInvalidOffset in the | |
178 | other case. | |
7da42094 | 179 | |
e2a6f233 | 180 | \membersection{wxStreamBuffer::Seek}\label{wxstreambufferseek} |
b82827dd JS |
181 | |
182 | \func{off\_t}{Seek}{\param{off\_t }{pos}, \param{wxSeekMode }{mode}} | |
7da42094 | 183 | |
07b73270 GL |
184 | Changes the current position. |
185 | ||
186 | \it{mode} may be one of the following: | |
187 | ||
188 | \twocolwidtha{5cm} | |
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.} | |
193 | \end{twocollist} | |
194 | ||
195 | \wxheading{Return value} | |
196 | ||
197 | Upon successful completion, it returns the new offset as measured in bytes from | |
198 | the beginning of the stream. Otherwise, it returns wxInvalidOffset. | |
7da42094 GL |
199 | |
200 | % -------------- | |
201 | % Buffer control | |
202 | % -------------- | |
7da42094 | 203 | \membersection{wxStreamBuffer::ResetBuffer} |
b82827dd | 204 | |
7da42094 GL |
205 | \func{void}{ResetBuffer}{\void} |
206 | ||
07b73270 | 207 | Resets to the initial state variables concerning the buffer. |
7da42094 | 208 | |
07b73270 | 209 | \membersection{wxStreamBuffer::SetBufferIO}\label{wxstreambufsetbufferio} |
b82827dd | 210 | |
06ad8636 | 211 | \func{void}{SetBufferIO}{\param{char*}{ buffer\_start}, \param{char*}{ buffer\_end}} |
7da42094 GL |
212 | |
213 | Specifies which pointers to use for stream buffering. You need to pass a pointer on the | |
da3aea64 GL |
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}). | |
217 | ||
218 | \wxheading{Remarks} | |
219 | ||
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 | |
223 | it when it is full. | |
224 | ||
225 | \wxheading{See also} | |
226 | ||
227 | \helpref{wxStreamBuffer constructor}{wxstreambufconst}\\ | |
228 | \helpref{wxStreamBuffer::Fixed}{wxstreambuffixed}\\ | |
229 | \helpref{wxStreamBuffer::Flushable}{wxstreambufflushable} | |
7da42094 | 230 | |
b82827dd | 231 | \func{void}{SetBufferIO}{\param{size\_t}{ bufsize}} |
7da42094 | 232 | |
da3aea64 GL |
233 | Destroys or invalidates the previous IO buffer and allocates a new one of the |
234 | specified size. | |
235 | ||
236 | \wxheading{Warning} | |
237 | ||
238 | All previous pointers aren't valid anymore. | |
239 | ||
240 | \wxheading{Remark} | |
241 | ||
242 | The created IO buffer is growable by the object. | |
243 | ||
244 | \wxheading{See also} | |
245 | ||
246 | \helpref{wxStreamBuffer::Fixed}{wxstreambuffixed}\\ | |
247 | \helpref{wxStreamBuffer::Flushable}{wxstreambufflushable} | |
7da42094 GL |
248 | |
249 | \membersection{wxStreamBuffer::GetBufferStart} | |
b82827dd | 250 | |
7da42094 GL |
251 | \constfunc{char *}{GetBufferStart}{\void} |
252 | ||
253 | Returns a pointer on the start of the stream buffer. | |
254 | ||
255 | \membersection{wxStreamBuffer::GetBufferEnd} | |
b82827dd | 256 | |
7da42094 GL |
257 | \constfunc{char *}{GetBufferEnd}{\void} |
258 | ||
259 | Returns a pointer on the end of the stream buffer. | |
260 | ||
261 | \membersection{wxStreamBuffer::GetBufferPos} | |
b82827dd | 262 | |
7da42094 GL |
263 | \constfunc{char *}{GetBufferPos}{\void} |
264 | ||
265 | Returns a pointer on the current position of the stream buffer. | |
266 | ||
267 | \membersection{wxStreamBuffer::GetIntPosition} | |
b82827dd JS |
268 | |
269 | \constfunc{off\_t}{GetIntPosition}{\void} | |
7da42094 | 270 | |
da3aea64 | 271 | Returns the current position (counted in bytes) in the stream buffer. |
7da42094 GL |
272 | |
273 | \membersection{wxStreamBuffer::SetIntPosition} | |
b82827dd | 274 | |
7da42094 GL |
275 | \func{void}{SetIntPosition}{\void} |
276 | ||
277 | Sets the current position in the stream buffer. | |
278 | ||
279 | \membersection{wxStreamBuffer::GetLastAccess} | |
b82827dd JS |
280 | |
281 | \constfunc{size\_t}{GetLastAccess}{\void} | |
7da42094 GL |
282 | |
283 | Returns the amount of bytes read during the last IO call to the parent stream. | |
284 | ||
285 | \membersection{wxStreamBuffer::Fixed} | |
b82827dd | 286 | |
7da42094 GL |
287 | \func{void}{Fixed}{\param{bool}{ fixed}} |
288 | ||
b82827dd | 289 | Toggles the fixed flag. Usually this flag is toggled at the same time as |
da3aea64 GL |
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. | |
292 | ||
293 | \wxheading{See also} | |
294 | ||
295 | \helpref{wxStreamBuffer::SetBufferIO}{wxstreambufsetbufferio} | |
7da42094 GL |
296 | |
297 | \membersection{wxStreamBuffer::Flushable} | |
b82827dd | 298 | |
7da42094 GL |
299 | \func{void}{Flushable}{\param{bool}{ flushable}} |
300 | ||
301 | Toggles the flushable flag. If \it{flushable} is disabled, no datas are sent | |
302 | to the parent stream. | |
303 | ||
304 | \membersection{wxStreamBuffer::FlushBuffer} | |
b82827dd | 305 | |
7da42094 GL |
306 | \func{bool}{FlushBuffer}{\void} |
307 | ||
308 | Flushes the IO buffer. | |
309 | ||
310 | \membersection{wxStreamBuffer::FillBuffer} | |
b82827dd | 311 | |
7da42094 GL |
312 | \func{bool}{FillBuffer}{\void} |
313 | ||
314 | Fill the IO buffer. | |
315 | ||
316 | \membersection{wxStreamBuffer::GetDataLeft} | |
b82827dd JS |
317 | |
318 | \func{size\_t}{GetDataLeft}{\void} | |
7da42094 GL |
319 | |
320 | Returns the amount of available datas in the buffer. | |
321 | ||
322 | % -------------- | |
323 | % Administration | |
324 | % -------------- | |
7da42094 | 325 | \membersection{wxStreamBuffer::Stream} |
b82827dd | 326 | |
06ad8636 | 327 | \func{wxStreamBase*}{Stream}{\void} |
7da42094 | 328 | |
07b73270 | 329 | Returns the parent stream of the stream buffer. |
b82827dd | 330 |