wxstreambufferderived from none include files <wx/stream.h> see also members
wxstreambuffer::wxstreambuffer
wxstreambuffer::wxstreambufferwxstreambuffer(wxstreambase& stream, bufmode mode) constructor, creates a new stream buffer using stream as a parent stream and mode as the io mode. mode 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. note that all errors and messages linked to the stream are stored in the stream, not the stream buffers:
streambuffer.read(...); streambuffer2.read(...); /* this call erases previous error messages set by ``streambuffer'' */wxstreambuffer(bufmode mode) constructor, creates a new empty stream buffer which won't flush any data to a stream. mode 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. warning the "read_write" mode doesn't currently work for standalone stream buffers. wxstreambuffer(const wxstreambuffer&buffer) constructor. it initializes the stream buffer with the data of the specified stream buffer. the new stream buffer has the same attributes, size, position and they share the same buffer. this will cause problems if the stream to which the stream buffer belong is destroyed and the newly cloned stream buffer continues to be used, trying to call functions in the (destroyed) stream. it is advised to use this feature only in very local area of the program. see also
wxstreambuffer::~wxstreambufferwxstreambuffer(~wxstreambuffer) destructor. it finalizes all io calls and frees all internal buffers if necessary.
wxstreambuffer::readsize_t read(void *buffer, size_t size) reads a block of the specified size and stores the data in buffer. this function tries to read from the buffer first and if more data has been requested, reads more data from the associated stream and updates the buffer accordingly until all requested data is read. return value it returns the size of the data read. if the returned size is different of the specified size, an error has occurred and should be tested using getlasterror. size_t read(wxstreambuffer *buffer) copies data to buffer. the function returns when buffer is full or when there isn't any more data in the current buffer. see also
wxstreambuffer::writesize_t write(const void *buffer, size_t size) writes a block of the specified size using data of buffer. the data are cached in a buffer before being sent in one block to the stream. size_t write(wxstreambuffer *buffer) see read.
wxstreambuffer::getcharchar getchar() gets a single char from the stream buffer. it acts like the read call. problem you aren't directly notified if an error occurred during the io call. see also
wxstreambuffer::putcharvoid putchar(char c) puts a single char to the stream buffer. problem you aren't directly notified if an error occurred during the io call. see also
wxstreambuffer::telloff_t tell() const gets the current position in the stream. this position is calculated from the real position in the stream and from the internal buffer position: so it gives you the position in the real stream counted from the start of the stream. return value returns the current position in the stream if possible, wxinvalidoffset in the other case.
wxstreambuffer::seekoff_t seek(off_t pos, wxseekmode mode) changes the current position. mode may be one of the following:
return value upon successful completion, it returns the new offset as measured in bytes from the beginning of the stream. otherwise, it returns wxinvalidoffset.
wxstreambuffer::resetbuffervoid resetbuffer() resets to the initial state variables concerning the buffer.
wxstreambuffer::setbufferiovoid setbufferio(char* buffer_start, char* buffer_end) 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 wxstreambuffer::wxstreambuffer). remarks when you use this function, you will 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 resize it when it is full. see also
wxstreambuffer constructor void setbufferio(size_t bufsize) destroys or invalidates the previous io buffer and allocates a new one of the specified size. warning all previous pointers aren't valid anymore. remark the created io buffer is growable by the object. see also
wxstreambuffer::fixed
wxstreambuffer::getbufferstartvoid * getbufferstart() const returns a pointer on the start of the stream buffer.
wxstreambuffer::getbufferendvoid * getbufferend() const returns a pointer on the end of the stream buffer.
wxstreambuffer::getbufferposvoid * getbufferpos() const returns a pointer on the current position of the stream buffer.
wxstreambuffer::getintpositionoff_t getintposition() const returns the current position (counted in bytes) in the stream buffer.
wxstreambuffer::setintpositionvoid setintposition(size_t pos) sets the current position (in bytes) in the stream buffer. warning since it is a very low-level function, there is no check on the position: specifying an invalid position can induce unexpected results.
wxstreambuffer::getlastaccesssize_t getlastaccess() const returns the amount of bytes read during the last io call to the parent stream.
wxstreambuffer::fixedvoid fixed(bool fixed) toggles the fixed flag. usually this flag is toggled at the same time as flushable. 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. see also
wxstreambuffer::flushablevoid flushable(bool flushable) toggles the flushable flag. if flushable is disabled, no data are sent to the parent stream.
wxstreambuffer::flushbufferbool flushbuffer() flushes the io buffer.
wxstreambuffer::fillbufferbool fillbuffer() fill the io buffer.
wxstreambuffer::getdataleftsize_t getdataleft() returns the amount of available data in the buffer.
wxstreambuffer::streamwxstreambase* stream() returns the parent stream of the stream buffer.
|