Panda3D
 All Classes Functions Variables Enumerations
stringStreamBuf.h
00001 // Filename: stringStreamBuf.h
00002 // Created by:  drose (02Jul07)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef STRINGSTREAMBUF_H
00016 #define STRINGSTREAMBUF_H
00017 
00018 #include "pandabase.h"
00019 #include "pvector.h"
00020 
00021 ////////////////////////////////////////////////////////////////////
00022 //       Class : StringStreamBuf
00023 // Description : Used by StringStream to implement an stream that
00024 //               reads from and/or writes to a memory buffer, whose
00025 //               contents can be appended to or extracted at any time
00026 //               by application code.
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
 All Classes Functions Variables Enumerations