1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
|
<HTML>
<head><title>wxStreamBuffer</title></head>
<BODY BGCOLOR=#FFFFFF>
<A NAME="wxstreambuffer"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx22.htm#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx222.htm#wxstreambase"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx224.htm#wxstring"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>
<H2>wxStreamBuffer</H2>
<P>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
None<P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
<wx/stream.h><P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx222.htm#wxstreambase">wxStreamBase</A><P>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#wxstreambufconst">wxStreamBuffer::wxStreamBuffer</A><BR>
<A HREF="#topic853">wxStreamBuffer::~wxStreamBuffer</A><BR>
<A HREF="#wxstreambufferread">wxStreamBuffer::Read</A><BR>
<A HREF="#wxstreambufferwrite">wxStreamBuffer::Write</A><BR>
<A HREF="#wxstreambufferwriteback">wxStreamBuffer::WriteBack</A><BR>
<A HREF="#topic854">wxStreamBuffer::GetChar</A><BR>
<A HREF="#topic855">wxStreamBuffer::PutChar</A><BR>
<A HREF="#topic856">wxStreamBuffer::Tell</A><BR>
<A HREF="#wxstreambufferseek">wxStreamBuffer::Seek</A><BR>
<A HREF="#topic857">wxStreamBuffer::ResetBuffer</A><BR>
<A HREF="#wxstreambuffersetbufferio">wxStreamBuffer::SetBufferIO</A><BR>
<A HREF="#topic858">wxStreamBuffer::GetBufferStart</A><BR>
<A HREF="#topic859">wxStreamBuffer::GetBufferEnd</A><BR>
<A HREF="#topic860">wxStreamBuffer::GetBufferPos</A><BR>
<A HREF="#topic861">wxStreamBuffer::GetIntPosition</A><BR>
<A HREF="#topic862">wxStreamBuffer::SetIntPosition</A><BR>
<A HREF="#topic863">wxStreamBuffer::GetLastAccess</A><BR>
<A HREF="#wxstreambufferfixed">wxStreamBuffer::Fixed</A><BR>
<A HREF="#wxstreambufferflushable">wxStreamBuffer::Flushable</A><BR>
<A HREF="#topic864">wxStreamBuffer::FlushBuffer</A><BR>
<A HREF="#topic865">wxStreamBuffer::FillBuffer</A><BR>
<A HREF="#topic866">wxStreamBuffer::GetDataLeft</A><BR>
<A HREF="#topic867">wxStreamBuffer::Stream</A><BR>
<P>
<HR>
<A NAME="wxstreambufconst"></A>
<H3>wxStreamBuffer::wxStreamBuffer</H3>
<P>
<B></B> <B>wxStreamBuffer</B>(<B>wxStreamBase&</B><I> stream</I>, <B>BufMode</B><I> mode</I>)<P>
Constructor, creates a new stream buffer using <I>stream</I> as a parent stream
and <I>mode</I> as the IO mode. <I>mode</I> can be: wxStreamBuffer::read,
wxStreamBuffer::write, wxStreamBuffer::read_write.
One stream can have many stream buffers but only one is used internally to
pass IO call (e.g. wxInputStream::Read() -> wxStreamBuffer::Read()). But you
can call directly wxStreamBuffer::Read without any problems.<P>
<B><FONT COLOR="#FF0000">Warning</FONT></B><P>
All errors and messages linked to the stream are stored in the stream object.
<PRE>
streambuffer.Read(...);
streambuffer2.Read(...); /* This one erases previous error messages set by
``streambuffer'' */
</PRE>
<B></B> <B>wxStreamBuffer</B>(<B>BufMode</B><I> mode</I>)<P>
Constructor, creates a new empty stream buffer which won't flush any data
to a stream. <I>mode</I> specifies the type of the buffer (read, write, read_write). This stream buffer has the advantage to be stream independent and to
work only on memory buffers but it is still compatible with the rest of the
wxStream classes. You can write, read to this special stream and it will
grow (if it is allowed by the user) its internal buffer. Briefly, it has all
functionality of a "normal'' stream.<P>
<B><FONT COLOR="#FF0000">Warning</FONT></B><P>
The "read_write" mode may not work: it isn't completely finished.
You can create "memory" streams by this way:<P>
<PRE>
wxStreamBuffer *sb = new wxStreamBuffer(wxStreamBuffer::read)
wxInputStream *input = new wxInputStream(sb);
sb->Fixed(FALSE); // It can change the size of the buffer.
// input is now a read-only memory stream.
</PRE>
But you should take care when destroying the stream buffer yourself.<P>
<B></B> <B>wxStreamBuffer</B>(<B>const wxStreamBuffer&</B><I>buffer</I>)<P>
Constructor. It initializes the stream buffer with the data of the specified
stream buffer. The new stream buffer is nearly exactly the same as the
original: it has the same attributes, the same size, the same position, shares
the same internal buffer. The interresting point is that they can differ
in the future but the root is the same.<P>
<B><FONT COLOR="#FF0000">Warning</FONT></B><P>
The fact that the two stream buffers shared the same buffer could generate
segmentation violation if the parent is destroyed and the children continues
operating. It is advised to use this feature only in very local area of the
program.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx223.htm#wxstreambuffersetbufferio">wxStreamBuffer:SetBufferIO</A><P>
<HR>
<A NAME="topic853"></A>
<H3>wxStreamBuffer::~wxStreamBuffer</H3>
<P>
<B></B> <B>wxStreamBuffer</B>(~wxStreamBuffer)<P>
Destructor. It finalizes all IO calls and frees all internal buffers if
necessary. In the case of a children stream buffer, the internal buffer isn't
freed, this is the job of the parent.
The "Write-Back" buffer is freed.<P>
<HR>
<A NAME="wxstreambufferread"></A>
<H3>wxStreamBuffer::Read</H3>
<P>
<B>size_t</B> <B>Read</B>(<B>void *</B><I>buffer</I>, <B>size_t </B><I>size</I>)<P>
Reads a block of the specified <I>size</I> and stores datas in <I>buffer</I>.
This function uses also the "Write-Back" buffer: in the case there are datas
waiting in this buffer, they are used before anything else. After that, if there
are still datas to be read, the stream is read and the stream buffer position
is incremented.<P>
<B><FONT COLOR="#FF0000">Return value</FONT></B><P>
It returns the real read size. If returned size is different of the specified
<I>size</I>, an error occured and should be tested using
<A HREF="wx222.htm#wxstreambaselasterror">LastError</A>.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx223.htm#wxstreambufferwriteback">wxStreamBuffer::WriteBack</A><P>
<B>size_t</B> <B>Read</B>(<B>wxStreamBuffer *</B><I>buffer</I>)<P>
Reads a <I>buffer</I>. The function returns when <I>buffer</I> is full or
when there aren't datas anymore in the current buffer.<P>
<HR>
<A NAME="wxstreambufferwrite"></A>
<H3>wxStreamBuffer::Write</H3>
<P>
<B>size_t</B> <B>Write</B>(<B>const void *</B><I>buffer</I>, <B>size_t </B><I>size</I>)<P>
Writes a block of the specified <I>size</I> using datas of <I>buffer</I>. The datas
are cached in a buffer before being sent in one block to the stream.<P>
<B>size_t</B> <B>Write</B>(<B>wxStreamBuffer *</B><I>buffer</I>)<P>
See <A HREF="wx223.htm#wxstreambufferread">Read</A>.<P>
<HR>
<A NAME="wxstreambufferwriteback"></A>
<H3>wxStreamBuffer::WriteBack</H3>
<P>
<B>size_t</B> <B>WriteBack</B>(<B>const char*</B><I> buffer</I>, <B>size_t</B><I> size</I>)<P>
This function is only useful in <I>read</I> mode. It is the manager of the "Write-Back"
buffer. This buffer acts like a temporary buffer where datas which has to be
read during the next read IO call are put. This is useful when you get a big
block of data which you didn't want to read: you can replace them at the top
of the input queue by this way.<P>
<B><FONT COLOR="#FF0000">Return value</FONT></B><P>
Returns the amount of bytes saved in the Write-Back buffer.<P>
<B>size_t</B> <B>WriteBack</B>(<B>char </B><I>c</I>)<P>
This function acts like the previous one except that it takes only one
character: it is sometimes shorter to use than the generic function.<P>
<HR>
<A NAME="topic854"></A>
<H3>wxStreamBuffer::GetChar</H3>
<P>
<B>char</B> <B>GetChar</B>()<P>
Gets a single char from the stream buffer. It acts like the Read call.<P>
<B><FONT COLOR="#FF0000">Problem</FONT></B><P>
You aren't directly notified if an error occured during the IO call.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx223.htm#wxstreambufferread">wxStreamBuffer::Read</A><P>
<HR>
<A NAME="topic855"></A>
<H3>wxStreamBuffer::PutChar</H3>
<P>
<B>void</B> <B>PutChar</B>(<B>char </B><I>c</I>)<P>
Puts a single char to the stream buffer.<P>
<B><FONT COLOR="#FF0000">Problem</FONT></B><P>
You aren't directly notified if an error occured during the IO call.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx223.htm#wxstreambufferwrite">wxStreamBuffer::Read</A><P>
<HR>
<A NAME="topic856"></A>
<H3>wxStreamBuffer::Tell</H3>
<P>
<B>off_t</B> <B>Tell</B>() <B>const</B><P>
Gets the current position in the stream. This position is calculated from
the <I>real</I> position in the stream and from the internal buffer position: so
it gives you the position in the <I>real</I> stream counted from the start of
the stream.<P>
<B><FONT COLOR="#FF0000">Return value</FONT></B><P>
Returns the current position in the stream if possible, wxInvalidOffset in the
other case.<P>
<HR>
<A NAME="wxstreambufferseek"></A>
<H3>wxStreamBuffer::Seek</H3>
<P>
<B>off_t</B> <B>Seek</B>(<B>off_t </B><I>pos</I>, <B>wxSeekMode </B><I>mode</I>)<P>
Changes the current position.<P>
<I>mode</I> may be one of the following:<P>
<TABLE>
<TR><TD VALIGN=TOP>
<B>wxFromStart</B>
</TD>
<TD VALIGN=TOP>
The position is counted from the start of the stream.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxFromCurrent</B>
</TD>
<TD VALIGN=TOP>
The position is counted from the current position of the stream.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxFromEnd</B>
</TD>
<TD VALIGN=TOP>
The position is counted from the end of the stream.
</TD></TR>
</TABLE>
<P>
<B><FONT COLOR="#FF0000">Return value</FONT></B><P>
Upon successful completion, it returns the new offset as measured in bytes from
the beginning of the stream. Otherwise, it returns wxInvalidOffset.<P>
<HR>
<A NAME="topic857"></A>
<H3>wxStreamBuffer::ResetBuffer</H3>
<P>
<B>void</B> <B>ResetBuffer</B>()<P>
Resets to the initial state variables concerning the buffer.<P>
<HR>
<A NAME="wxstreambuffersetbufferio"></A>
<H3>wxStreamBuffer::SetBufferIO</H3>
<P>
<B>void</B> <B>SetBufferIO</B>(<B>char*</B><I> buffer_start</I>, <B>char*</B><I> buffer_end</I>)<P>
Specifies which pointers to use for stream buffering. You need to pass a pointer on the
start of the buffer end and another on the end. The object will use this buffer
to cache stream data. It may be used also as a source/destination buffer when
you create an empty stream buffer (See <A HREF="wx223.htm#wxstreambufconst">wxStreamBuffer::wxStreamBuffer</A>).<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
When you use this function, you'll have to destroy the IO buffers yourself
after the stream buffer is destroyed or don't use it anymore.
In the case you use it with an empty buffer, the stream buffer will not grow
it when it is full.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx223.htm#wxstreambufconst">wxStreamBuffer constructor</A><BR>
<A HREF="wx223.htm#wxstreambufferfixed">wxStreamBuffer::Fixed</A><BR>
<A HREF="wx223.htm#wxstreambufferflushable">wxStreamBuffer::Flushable</A><P>
<B>void</B> <B>SetBufferIO</B>(<B>size_t</B><I> bufsize</I>)<P>
Destroys or invalidates the previous IO buffer and allocates a new one of the
specified size.<P>
<B><FONT COLOR="#FF0000">Warning</FONT></B><P>
All previous pointers aren't valid anymore.<P>
<B><FONT COLOR="#FF0000">Remark</FONT></B><P>
The created IO buffer is growable by the object.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx223.htm#wxstreambufferfixed">wxStreamBuffer::Fixed</A><BR>
<A HREF="wx223.htm#wxstreambufferflushable">wxStreamBuffer::Flushable</A><P>
<HR>
<A NAME="topic858"></A>
<H3>wxStreamBuffer::GetBufferStart</H3>
<P>
<B>char *</B> <B>GetBufferStart</B>() <B>const</B><P>
Returns a pointer on the start of the stream buffer.<P>
<HR>
<A NAME="topic859"></A>
<H3>wxStreamBuffer::GetBufferEnd</H3>
<P>
<B>char *</B> <B>GetBufferEnd</B>() <B>const</B><P>
Returns a pointer on the end of the stream buffer.<P>
<HR>
<A NAME="topic860"></A>
<H3>wxStreamBuffer::GetBufferPos</H3>
<P>
<B>char *</B> <B>GetBufferPos</B>() <B>const</B><P>
Returns a pointer on the current position of the stream buffer.<P>
<HR>
<A NAME="topic861"></A>
<H3>wxStreamBuffer::GetIntPosition</H3>
<P>
<B>off_t</B> <B>GetIntPosition</B>() <B>const</B><P>
Returns the current position (counted in bytes) in the stream buffer.<P>
<HR>
<A NAME="topic862"></A>
<H3>wxStreamBuffer::SetIntPosition</H3>
<P>
<B>void</B> <B>SetIntPosition</B>()<P>
Sets the current position (in bytes) in the stream buffer.<P>
<B><FONT COLOR="#FF0000">Warning</FONT></B><P>
Since it is a very low-level function, there is no check on the position:
specify an invalid position can induce unexpected results.<P>
<HR>
<A NAME="topic863"></A>
<H3>wxStreamBuffer::GetLastAccess</H3>
<P>
<B>size_t</B> <B>GetLastAccess</B>() <B>const</B><P>
Returns the amount of bytes read during the last IO call to the parent stream.<P>
<HR>
<A NAME="wxstreambufferfixed"></A>
<H3>wxStreamBuffer::Fixed</H3>
<P>
<B>void</B> <B>Fixed</B>(<B>bool</B><I> fixed</I>)<P>
Toggles the fixed flag. Usually this flag is toggled at the same time as
<I>flushable</I>. This flag allows (when it has the FALSE value) or forbids
(when it has the TRUE value) the stream buffer to resize dynamically the IO buffer.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx223.htm#wxstreambuffersetbufferio">wxStreamBuffer::SetBufferIO</A><P>
<HR>
<A NAME="wxstreambufferflushable"></A>
<H3>wxStreamBuffer::Flushable</H3>
<P>
<B>void</B> <B>Flushable</B>(<B>bool</B><I> flushable</I>)<P>
Toggles the flushable flag. If <I>flushable</I> is disabled, no datas are sent
to the parent stream.<P>
<HR>
<A NAME="topic864"></A>
<H3>wxStreamBuffer::FlushBuffer</H3>
<P>
<B>bool</B> <B>FlushBuffer</B>()<P>
Flushes the IO buffer.<P>
<HR>
<A NAME="topic865"></A>
<H3>wxStreamBuffer::FillBuffer</H3>
<P>
<B>bool</B> <B>FillBuffer</B>()<P>
Fill the IO buffer.<P>
<HR>
<A NAME="topic866"></A>
<H3>wxStreamBuffer::GetDataLeft</H3>
<P>
<B>size_t</B> <B>GetDataLeft</B>()<P>
Returns the amount of available datas in the buffer.<P>
<HR>
<A NAME="topic867"></A>
<H3>wxStreamBuffer::Stream</H3>
<P>
<B>wxStreamBase*</B> <B>Stream</B>()<P>
Returns the parent stream of the stream buffer.<P>
</BODY></HTML>
|