Panda3D
 All Classes Functions Variables Enumerations
stringStreamBuf.h
1 // Filename: stringStreamBuf.h
2 // Created by: drose (02Jul07)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef STRINGSTREAMBUF_H
16 #define STRINGSTREAMBUF_H
17 
18 #include "pandabase.h"
19 #include "pvector.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Class : StringStreamBuf
23 // Description : Used by StringStream to implement an stream that
24 // reads from and/or writes to a memory buffer, whose
25 // contents can be appended to or extracted at any time
26 // by application code.
27 ////////////////////////////////////////////////////////////////////
28 class EXPCL_PANDAEXPRESS StringStreamBuf : public streambuf {
29 public:
31  virtual ~StringStreamBuf();
32 
33  void clear();
34 
35  INLINE void swap_data(pvector<unsigned char> &data);
36  INLINE const pvector<unsigned char> &get_data() const;
37 
38  size_t read_chars(char *start, size_t length);
39  void write_chars(const char *start, size_t length);
40 
41 protected:
42  virtual streampos seekoff(streamoff off, ios_seekdir dir, ios_openmode which);
43  virtual streampos seekpos(streampos pos, ios_openmode which);
44 
45  virtual int overflow(int c);
46  virtual int sync();
47  virtual int underflow();
48 
49 private:
51  char *_buffer;
52  size_t _ppos;
53  size_t _gpos;
54 };
55 
56 #include "stringStreamBuf.I"
57 
58 #endif
Used by StringStream to implement an stream that reads from and/or writes to a memory buffer...