00001 // Filename: stringStream.h 00002 // Created by: drose (03Jul07) 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 STRINGSTREAM_H 00016 #define STRINGSTREAM_H 00017 00018 #include "pandabase.h" 00019 #include "stringStreamBuf.h" 00020 00021 //////////////////////////////////////////////////////////////////// 00022 // Class : StringStream 00023 // Description : A bi-directional stream object that reads and writes 00024 // data to an internal buffer, which can be retrieved 00025 // and/or set as a string. 00026 //////////////////////////////////////////////////////////////////// 00027 class EXPCL_PANDAEXPRESS StringStream : public iostream { 00028 PUBLISHED: 00029 INLINE StringStream(); 00030 INLINE StringStream(const string &source); 00031 00032 INLINE void clear_data(); 00033 INLINE size_t get_data_size(); 00034 00035 INLINE string get_data(); 00036 INLINE void set_data(const string &data); 00037 INLINE void swap_data(pvector<unsigned char> &data); 00038 00039 private: 00040 StringStreamBuf _buf; 00041 }; 00042 00043 #include "stringStream.I" 00044 00045 #endif 00046