Panda3D
|
Used by StringStream to implement an stream that reads from and/or writes to a memory buffer, whose contents can be appended to or extracted at any time by application code. More...
#include "stringStreamBuf.h"
Public Member Functions | |
void | clear () |
Empties the buffer. | |
const pvector< unsigned char > & | get_data () const |
Returns a reference to the contents of the internal buffer, without any of the iostream buffer. | |
size_t | read_chars (char *start, size_t length) |
Attempts to extract the indicated number of characters from the current file position. | |
void | swap_data (pvector< unsigned char > &data) |
Swaps the indicated buffer for the contents of the internal buffer. | |
void | write_chars (const char *start, size_t length) |
Appends the indicated stream of characters to the current file position. | |
Protected Member Functions | |
virtual int | overflow (int c) |
Called by the system ostream implementation when its internal buffer is filled, plus one character. | |
virtual streampos | seekoff (streamoff off, ios_seekdir dir, ios_openmode which) |
Implements seeking within the stream. | |
virtual streampos | seekpos (streampos pos, ios_openmode which) |
A variant on seekoff() to implement seeking within a stream. | |
virtual int | sync () |
Called by the system iostream implementation to implement a flush operation. | |
virtual int | underflow () |
Called by the system istream implementation when its internal buffer needs more characters. |
Used by StringStream to implement an stream that reads from and/or writes to a memory buffer, whose contents can be appended to or extracted at any time by application code.
Definition at line 28 of file stringStreamBuf.h.
void StringStreamBuf::clear | ( | ) |
Empties the buffer.
Definition at line 66 of file stringStreamBuf.cxx.
Referenced by StringStream::clear_data(), and StringStream::set_data().
const pvector< unsigned char > & StringStreamBuf::get_data | ( | ) | const [inline] |
Returns a reference to the contents of the internal buffer, without any of the iostream buffer.
Definition at line 35 of file stringStreamBuf.I.
Referenced by StringStream::get_data(), and StringStream::get_data_size().
int StringStreamBuf::overflow | ( | int | c | ) | [protected, virtual] |
Called by the system ostream implementation when its internal buffer is filled, plus one character.
Definition at line 239 of file stringStreamBuf.cxx.
References write_chars().
size_t StringStreamBuf::read_chars | ( | char * | start, |
size_t | length | ||
) |
Attempts to extract the indicated number of characters from the current file position.
Returns the number of characters extracted.
Definition at line 83 of file stringStreamBuf.cxx.
References sync().
Referenced by underflow().
streampos StringStreamBuf::seekoff | ( | streamoff | off, |
ios_seekdir | dir, | ||
ios_openmode | which | ||
) | [protected, virtual] |
Implements seeking within the stream.
Definition at line 144 of file stringStreamBuf.cxx.
References sync().
Referenced by seekpos().
streampos StringStreamBuf::seekpos | ( | streampos | pos, |
ios_openmode | which | ||
) | [protected, virtual] |
A variant on seekoff() to implement seeking within a stream.
The MSDN Library claims that it is only necessary to redefine seekoff(), and not seekpos() as well, as the default implementation of seekpos() is supposed to map to seekoff() exactly as I am doing here; but in fact it must do something else, because seeking didn't work on Windows until I redefined this function as well.
Definition at line 228 of file stringStreamBuf.cxx.
References seekoff().
void StringStreamBuf::swap_data | ( | pvector< unsigned char > & | data | ) | [inline] |
Swaps the indicated buffer for the contents of the internal buffer.
Does not affect the ppos or gpos, or the iostream buffer.
Definition at line 24 of file stringStreamBuf.I.
Referenced by StringStream::set_data(), and StringStream::swap_data().
int StringStreamBuf::sync | ( | void | ) | [protected, virtual] |
Called by the system iostream implementation to implement a flush operation.
Definition at line 262 of file stringStreamBuf.cxx.
References write_chars().
Referenced by read_chars(), and seekoff().
int StringStreamBuf::underflow | ( | void | ) | [protected, virtual] |
Called by the system istream implementation when its internal buffer needs more characters.
Definition at line 278 of file stringStreamBuf.cxx.
References read_chars().
void StringStreamBuf::write_chars | ( | const char * | start, |
size_t | length | ||
) |
Appends the indicated stream of characters to the current file position.
Definition at line 108 of file stringStreamBuf.cxx.
Referenced by overflow(), and sync().