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