00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef STRINGSTREAMBUF_H
00016 #define STRINGSTREAMBUF_H
00017
00018 #include "pandabase.h"
00019 #include "pvector.h"
00020
00021
00022
00023
00024
00025
00026
00027
00028 class EXPCL_PANDAEXPRESS StringStreamBuf : public streambuf {
00029 public:
00030 StringStreamBuf();
00031 virtual ~StringStreamBuf();
00032
00033 void clear();
00034
00035 INLINE void swap_data(pvector<unsigned char> &data);
00036 INLINE const pvector<unsigned char> &get_data() const;
00037
00038 size_t read_chars(char *start, size_t length);
00039 void write_chars(const char *start, size_t length);
00040
00041 protected:
00042 virtual streampos seekoff(streamoff off, ios_seekdir dir, ios_openmode which);
00043 virtual streampos seekpos(streampos pos, ios_openmode which);
00044
00045 virtual int overflow(int c);
00046 virtual int sync();
00047 virtual int underflow();
00048
00049 private:
00050 pvector<unsigned char> _data;
00051 char *_buffer;
00052 size_t _ppos;
00053 size_t _gpos;
00054 };
00055
00056 #include "stringStreamBuf.I"
00057
00058 #endif