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.
51 You can create "memory" streams by this way:
53 wxStreamBuffer *sb = new wxStreamBuffer(wxStreamBuffer::read)
54 wxInputStream *input = new wxInputStream(sb);
56 sb->Fixed(FALSE); // It can change the size of the buffer.
58 // input is now a read-only memory stream.
60 But you should care about destroying the stream buffer
\it{YOURSELF
}.
64 \helpref{wxStreamBuffer:SetBufferIO
}{wxstreambufsetbufferio
}
66 \func{}{wxStreamBuffer
}{\param{const wxStreamBuffer &
}{buffer
}}
68 Constructor. It initializes the stream buffer with the data of the specified
69 stream buffer. The new stream buffer is nearly exactly the same as the
70 original: it has the same attributes, the same size, the same position, shares
71 the same internal buffer. The interresting point is that they can differ
72 in the future but the root is the same.
76 The fact that the two stream buffers shared the same buffer could generate
77 segmentation violation if the parent is destroyed and the children continues
78 operating. It is advised to use this feature only in very local area of the
81 \membersection{wxStreamBuffer::
\destruct{wxStreamBuffer
}}
83 \func{}{wxStreamBuffer
}{\destruct{wxStreamBuffer
}}
85 Destructor. It finalizes all IO calls and frees all internal buffers if
86 necessary. In the case of a children stream buffer, the internal buffer isn't
87 freed, this is the job of the parent.
88 The "Write-Back" buffer is freed.
93 \membersection{wxStreamBuffer::Read
}\label{wxstreambufread
}
95 \func{size
\_t}{Read
}{\param{void *
}{buffer
},
\param{size
\_t }{size
}}
97 Reads a block of the specified
\it{size
} and stores datas in
\it{buffer
}.
98 This function uses also the "Write-Back" buffer: in the case there are datas
99 waiting in this buffer, they are used before anything else. After that, if there
100 are still datas to be read, the stream is read and the stream buffer position
103 \wxheading{Return value
}
105 It returns the real read size. If returned size is different of the specified
106 \it{size
}, an error occured and should be tested using
107 \helpref{LastError
}{wxstreambaselasterror
}.
111 \helpref{wxStreamBuffer::WriteBack
}{wxstreambufwriteback
}
113 \func{size
\_t}{Read
}{\param{wxStreamBuffer *
}{buffer
}}
115 Reads a
\it{buffer
}. The function returns when
\it{buffer
} is full or
116 when there aren't datas anymore in the current buffer.
118 \membersection{wxStreamBuffer::Write
}
120 \func{size
\_t}{Write
}{\param{const void *
}{buffer
},
\param{size
\_t }{size
}}
122 Writes a block of the specified
\it{size
} using datas of
\it{buffer
}. The datas
123 are cached in a buffer before being sent in one block to the stream.
125 \func{size
\_t}{Write
}{\param{wxStreamBuffer *
}{buffer
}}
127 See
\helpref{Read
}{wxstreambufreadbuf
}
129 \membersection{wxStreamBuffer::WriteBack
}\label{wxstreambufwriteback
}
131 \func{size
\_t}{WriteBack
}{\param{const char*
}{ buffer
},
\param{size
\_t}{ size
}}
133 This function is only useful in
\it{read
} mode. It is the manager of the "Write-Back"
134 buffer. This buffer acts like a temporary buffer where datas which has to be
135 read during the next read IO call are put. This is useful when you get a big
136 block of data which you didn't want to read: you can replace them at the top
137 of the input queue by this way.
139 \wxheading{Return value
}
141 Returns the amount of bytes saved in the Write-Back buffer.
143 \func{size
\_t}{WriteBack
}{\param{char
}{c
}}
145 This function acts like the previous one except that it takes only one
146 character: it is sometimes shorter to use than the generic function.
148 \membersection{wxStreamBuffer::GetChar
}
150 \func{char
}{GetChar
}{\void}
152 Gets a single char from the stream buffer. It acts like the Read call.
156 You aren't directly notified if an error occured during the IO call.
160 \helpref{wxStreamBuffer::Read
}{wxstreambufread
}
162 \membersection{wxStreamBuffer::PutChar
}
164 \func{void
}{PutChar
}{\param{char
}{c
}}
166 Puts a single char to the stream buffer.
170 You aren't directly notified if an error occured during the IO call.
174 \helpref{wxStreamBuffer::Read
}{wxstreambufwrite
}
176 \membersection{wxStreamBuffer::Tell
}
178 \constfunc{off
\_t}{Tell
}{\void}
180 Gets the current position in the stream. This position is calculated from
181 the
\it{real
} position in the stream and from the internal buffer position: so
182 it gives you the position in the
\it{real
} stream counted from the start of
185 \wxheading{Return value
}
187 Returns the current position in the stream if possible, wxInvalidOffset in the
190 \membersection{wxStreamBuffer::Seek
}\label{wxstreambufferseek
}
192 \func{off
\_t}{Seek
}{\param{off
\_t }{pos
},
\param{wxSeekMode
}{mode
}}
194 Changes the current position.
196 \it{mode
} may be one of the following:
199 \begin{twocollist
}\itemsep=
0pt
200 \twocolitem{{\bf wxFromStart
}}{The position is counted from the start of the stream.
}
201 \twocolitem{{\bf wxFromCurrent
}}{The position is counted from the current position of the stream.
}
202 \twocolitem{{\bf wxFromEnd
}}{The position is counted from the end of the stream.
}
205 \wxheading{Return value
}
207 Upon successful completion, it returns the new offset as measured in bytes from
208 the beginning of the stream. Otherwise, it returns wxInvalidOffset.
213 \membersection{wxStreamBuffer::ResetBuffer
}
215 \func{void
}{ResetBuffer
}{\void}
217 Resets to the initial state variables concerning the buffer.
219 \membersection{wxStreamBuffer::SetBufferIO
}\label{wxstreambufsetbufferio
}
221 \func{void
}{SetBufferIO
}{\param{char*
}{ buffer
\_start},
\param{char*
}{ buffer
\_end}}
223 Specifies which pointers to use for stream buffering. You need to pass a pointer on the
224 start of the buffer end and another on the end. The object will use this buffer
225 to cache stream data. It may be used also as a source/destination buffer when
226 you create an empty stream buffer (See
\helpref{wxStreamBuffer::wxStreamBuffer
}{wxstreambufconst
}).
230 When you use this function, you'll have to destroy the IO buffers yourself
231 after the stream buffer is destroyed or don't use it anymore.
232 In the case you use it with an empty buffer, the stream buffer will not grow
237 \helpref{wxStreamBuffer constructor
}{wxstreambufconst
}\\
238 \helpref{wxStreamBuffer::Fixed
}{wxstreambuffixed
}\\
239 \helpref{wxStreamBuffer::Flushable
}{wxstreambufflushable
}
241 \func{void
}{SetBufferIO
}{\param{size
\_t}{ bufsize
}}
243 Destroys or invalidates the previous IO buffer and allocates a new one of the
248 All previous pointers aren't valid anymore.
252 The created IO buffer is growable by the object.
256 \helpref{wxStreamBuffer::Fixed
}{wxstreambuffixed
}\\
257 \helpref{wxStreamBuffer::Flushable
}{wxstreambufflushable
}
259 \membersection{wxStreamBuffer::GetBufferStart
}
261 \constfunc{char *
}{GetBufferStart
}{\void}
263 Returns a pointer on the start of the stream buffer.
265 \membersection{wxStreamBuffer::GetBufferEnd
}
267 \constfunc{char *
}{GetBufferEnd
}{\void}
269 Returns a pointer on the end of the stream buffer.
271 \membersection{wxStreamBuffer::GetBufferPos
}
273 \constfunc{char *
}{GetBufferPos
}{\void}
275 Returns a pointer on the current position of the stream buffer.
277 \membersection{wxStreamBuffer::GetIntPosition
}
279 \constfunc{off
\_t}{GetIntPosition
}{\void}
281 Returns the current position (counted in bytes) in the stream buffer.
283 \membersection{wxStreamBuffer::SetIntPosition
}
285 \func{void
}{SetIntPosition
}{\void}
287 Sets the current position in the stream buffer.
289 \membersection{wxStreamBuffer::GetLastAccess
}
291 \constfunc{size
\_t}{GetLastAccess
}{\void}
293 Returns the amount of bytes read during the last IO call to the parent stream.
295 \membersection{wxStreamBuffer::Fixed
}
297 \func{void
}{Fixed
}{\param{bool
}{ fixed
}}
299 Toggles the fixed flag. Usually this flag is toggled at the same time as
300 \it{flushable
}. This flag allows (when it has the FALSE value) or forbids
301 (when it has the TRUE value) the stream buffer to resize dynamically the IO buffer.
305 \helpref{wxStreamBuffer::SetBufferIO
}{wxstreambufsetbufferio
}
307 \membersection{wxStreamBuffer::Flushable
}
309 \func{void
}{Flushable
}{\param{bool
}{ flushable
}}
311 Toggles the flushable flag. If
\it{flushable
} is disabled, no datas are sent
312 to the parent stream.
314 \membersection{wxStreamBuffer::FlushBuffer
}
316 \func{bool
}{FlushBuffer
}{\void}
318 Flushes the IO buffer.
320 \membersection{wxStreamBuffer::FillBuffer
}
322 \func{bool
}{FillBuffer
}{\void}
326 \membersection{wxStreamBuffer::GetDataLeft
}
328 \func{size
\_t}{GetDataLeft
}{\void}
330 Returns the amount of available datas in the buffer.
335 \membersection{wxStreamBuffer::Stream
}
337 \func{wxStreamBase*
}{Stream
}{\void}
339 Returns the parent stream of the stream buffer.