#include </home/zeitlin/src/wx/github/interface/wx/stream.h>
wxStreamBuffer は wxStreamBase 用のキャッシュマネージャです: このクラスはストリームに関連付けられたストリームバッファを管理します。
Each stream always has one autoinitialized stream buffer, but you may attach more of them to the same stream.
Public Types | |
enum | BufMode { read, write, read_write } |
BufMode flags. More... | |
Public Member Functions | |
wxStreamBuffer (wxStreamBase &stream, BufMode mode) | |
Constructor, creates a new stream buffer using stream as a parent stream and mode as the IO mode. | |
wxStreamBuffer (size_t bufsize, wxInputStream &stream) | |
Constructor for an input buffer of the specified size. | |
wxStreamBuffer (size_t bufsize, wxOutputStream &stream) | |
Constructor for an output buffer of the specified size. | |
wxStreamBuffer (BufMode mode) | |
Constructor; creates a new empty stream buffer which won't flush any data to a stream. | |
wxStreamBuffer (const wxStreamBuffer &buffer) | |
Copy constructor. | |
~wxStreamBuffer () | |
Destructor. | |
bool | FillBuffer () |
Fill the IO buffer. | |
void | Fixed (bool fixed) |
Toggles the fixed flag. | |
bool | FlushBuffer () |
Flushes the IO buffer. | |
void | Flushable (bool flushable) |
Toggles the flushable flag. | |
void * | GetBufferEnd () const |
Returns a pointer on the end of the stream buffer. | |
void * | GetBufferPos () const |
Returns a pointer on the current position of the stream buffer. | |
size_t | GetBufferSize () const |
Returns the size of the buffer. | |
void * | GetBufferStart () const |
Returns a pointer on the start of the stream buffer. | |
virtual char | GetChar () |
Gets a single char from the stream buffer. | |
size_t | GetDataLeft () |
Returns the amount of available data in the buffer. | |
size_t | GetIntPosition () const |
Returns the current position (counted in bytes) in the stream buffer. | |
size_t | GetLastAccess () const |
Returns the amount of bytes read during the last IO call to the parent stream. | |
virtual void | PutChar (char c) |
Puts a single char to the stream buffer. | |
virtual size_t | Read (void *buffer, size_t size) |
Reads a block of the specified size and stores the data in buffer. | |
size_t | Read (wxStreamBuffer *buffer) |
Copies data to buffer. | |
void | ResetBuffer () |
Resets to the initial state variables concerning the buffer. | |
virtual wxFileOffset | Seek (wxFileOffset pos, wxSeekMode mode) |
Changes the current position. | |
void | SetBufferIO (void *start, void *end, bool takeOwnership=false) |
Specifies which pointers to use for stream buffering. | |
void | SetBufferIO (size_t bufsize) |
Destroys or invalidates the previous IO buffer and allocates a new one of the specified size. | |
void | SetIntPosition (size_t pos) |
Sets the current position (in bytes) in the stream buffer. | |
wxStreamBase * | Stream () |
Returns the parent stream of the stream buffer. | |
virtual wxFileOffset | Tell () const |
Gets the current position in the stream. | |
void | Truncate () |
Truncates the buffer to the current position. | |
virtual size_t | Write (const void *buffer, size_t size) |
Writes a block of the specified size using data of buffer. | |
size_t | Write (wxStreamBuffer *buffer) |
See Read(). |
wxStreamBuffer::wxStreamBuffer | ( | wxStreamBase & | stream, |
BufMode | mode | ||
) |
Constructor, creates a new stream buffer using stream as a parent stream and mode as the IO mode.
stream | The parent stream. |
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' // assuming that both instances are stream buffers for the same stream
wxStreamBuffer::wxStreamBuffer | ( | size_t | bufsize, |
wxInputStream & | stream | ||
) |
Constructor for an input buffer of the specified size.
Using it is equivalent to using the constructor above with read mode and calling SetBufferIO() but is more convenient.
bufsize | The size of buffer in bytes. |
stream | The associated input stream, the buffer will be used in read mode. |
wxStreamBuffer::wxStreamBuffer | ( | size_t | bufsize, |
wxOutputStream & | stream | ||
) |
Constructor for an output buffer of the specified size.
Using it is equivalent to using the constructor above with write mode and calling SetBufferIO() but is more convenient.
bufsize | The size of buffer in bytes. |
stream | The associated output stream, the buffer will be used in write mode. |
wxStreamBuffer::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.
wxStreamBuffer::wxStreamBuffer | ( | const wxStreamBuffer & | buffer | ) |
Copy constructor.
This method 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.
wxStreamBuffer::~wxStreamBuffer | ( | ) |
Destructor.
It finalizes all IO calls and frees all internal buffers if necessary.
bool wxStreamBuffer::FillBuffer | ( | ) |
Fill the IO buffer.
void wxStreamBuffer::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.
void wxStreamBuffer::Flushable | ( | bool | flushable | ) |
Toggles the flushable flag.
If flushable is disabled, no data are sent to the parent stream.
bool wxStreamBuffer::FlushBuffer | ( | ) |
Flushes the IO buffer.
void* wxStreamBuffer::GetBufferEnd | ( | ) | const |
Returns a pointer on the end of the stream buffer.
void* wxStreamBuffer::GetBufferPos | ( | ) | const |
Returns a pointer on the current position of the stream buffer.
size_t wxStreamBuffer::GetBufferSize | ( | ) | const |
Returns the size of the buffer.
void* wxStreamBuffer::GetBufferStart | ( | ) | const |
Returns a pointer on the start of the stream buffer.
virtual char wxStreamBuffer::GetChar | ( | ) | [virtual] |
size_t wxStreamBuffer::GetDataLeft | ( | ) |
Returns the amount of available data in the buffer.
size_t wxStreamBuffer::GetIntPosition | ( | ) | const |
Returns the current position (counted in bytes) in the stream buffer.
size_t wxStreamBuffer::GetLastAccess | ( | ) | const |
Returns the amount of bytes read during the last IO call to the parent stream.
virtual void wxStreamBuffer::PutChar | ( | char | c | ) | [virtual] |
Puts a single char to the stream buffer.
size_t wxStreamBuffer::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.
virtual size_t wxStreamBuffer::Read | ( | void * | buffer, |
size_t | size | ||
) | [virtual] |
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.
void wxStreamBuffer::ResetBuffer | ( | ) |
Resets to the initial state variables concerning the buffer.
virtual wxFileOffset wxStreamBuffer::Seek | ( | wxFileOffset | pos, |
wxSeekMode | mode | ||
) | [virtual] |
Changes the current position.
Parameter mode may be one of the following:
void wxStreamBuffer::SetBufferIO | ( | void * | start, |
void * | end, | ||
bool | takeOwnership = false |
||
) |
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).
void wxStreamBuffer::SetBufferIO | ( | size_t | bufsize | ) |
Destroys or invalidates the previous IO buffer and allocates a new one of the specified size.
void wxStreamBuffer::SetIntPosition | ( | size_t | pos | ) |
Sets the current position (in bytes) in the stream buffer.
wxStreamBase* wxStreamBuffer::Stream | ( | ) |
Returns the parent stream of the stream buffer.
virtual wxFileOffset wxStreamBuffer::Tell | ( | ) | const [virtual] |
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.
void wxStreamBuffer::Truncate | ( | ) |
Truncates the buffer to the current position.
size_t wxStreamBuffer::Write | ( | wxStreamBuffer * | buffer | ) |
See Read().
virtual size_t wxStreamBuffer::Write | ( | const void * | buffer, |
size_t | size | ||
) | [virtual] |
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.