1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | |
42 | |
43 | |
44 | |
45 | |
46 | |
47 | #ifndef _BACKWARD_STRSTREAM |
48 | #define _BACKWARD_STRSTREAM |
49 | |
50 | #include "backward_warning.h" |
51 | #include <iosfwd> |
52 | #include <ios> |
53 | #include <istream> |
54 | #include <ostream> |
55 | |
56 | namespace std _GLIBCXX_VISIBILITY(default) |
57 | { |
58 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
59 | |
60 | |
61 | |
62 | class strstreambuf : public basic_streambuf<char, char_traits<char> > |
63 | { |
64 | public: |
65 | |
66 | typedef char_traits<char> _Traits; |
67 | typedef basic_streambuf<char, _Traits> _Base; |
68 | |
69 | public: |
70 | |
71 | explicit strstreambuf(streamsize __initial_capacity = 0); |
72 | strstreambuf(void* (*__alloc)(size_t), void (*__free)(void*)); |
73 | |
74 | strstreambuf(char* __get, streamsize __n, char* __put = 0) throw (); |
75 | strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0) throw (); |
76 | strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0) throw (); |
77 | |
78 | strstreambuf(const char* __get, streamsize __n) throw (); |
79 | strstreambuf(const signed char* __get, streamsize __n) throw (); |
80 | strstreambuf(const unsigned char* __get, streamsize __n) throw (); |
81 | |
82 | virtual ~strstreambuf(); |
83 | |
84 | public: |
85 | void freeze(bool = true) throw (); |
86 | char* str() throw (); |
87 | _GLIBCXX_PURE int pcount() const throw (); |
88 | |
89 | protected: |
90 | virtual int_type overflow(int_type __c = _Traits::eof()); |
91 | virtual int_type pbackfail(int_type __c = _Traits::eof()); |
92 | virtual int_type underflow(); |
93 | virtual _Base* setbuf(char* __buf, streamsize __n); |
94 | virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir, |
95 | ios_base::openmode __mode |
96 | = ios_base::in | ios_base::out); |
97 | virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode |
98 | = ios_base::in | ios_base::out); |
99 | |
100 | private: |
101 | strstreambuf& |
102 | operator=(const strstreambuf&); |
103 | |
104 | strstreambuf(const strstreambuf&); |
105 | |
106 | |
107 | char* _M_alloc(size_t); |
108 | void _M_free(char*); |
109 | |
110 | |
111 | void _M_setup(char* __get, char* __put, streamsize __n) throw (); |
112 | |
113 | private: |
114 | |
115 | void* (*_M_alloc_fun)(size_t); |
116 | void (*_M_free_fun)(void*); |
117 | |
118 | bool _M_dynamic : 1; |
119 | bool _M_frozen : 1; |
120 | bool _M_constant : 1; |
121 | }; |
122 | |
123 | |
124 | class istrstream : public basic_istream<char> |
125 | { |
126 | public: |
127 | explicit istrstream(char*); |
128 | explicit istrstream(const char*); |
129 | istrstream(char* , streamsize); |
130 | istrstream(const char*, streamsize); |
131 | virtual ~istrstream(); |
132 | |
133 | _GLIBCXX_CONST strstreambuf* rdbuf() const throw (); |
134 | char* str() throw (); |
135 | |
136 | private: |
137 | strstreambuf _M_buf; |
138 | }; |
139 | |
140 | |
141 | class ostrstream : public basic_ostream<char> |
142 | { |
143 | public: |
144 | ostrstream(); |
145 | ostrstream(char*, int, ios_base::openmode = ios_base::out); |
146 | virtual ~ostrstream(); |
147 | |
148 | _GLIBCXX_CONST strstreambuf* rdbuf() const throw (); |
149 | void freeze(bool = true) throw(); |
150 | char* str() throw (); |
151 | _GLIBCXX_PURE int pcount() const throw (); |
152 | |
153 | private: |
154 | strstreambuf _M_buf; |
155 | }; |
156 | |
157 | |
158 | class strstream : public basic_iostream<char> |
159 | { |
160 | public: |
161 | typedef char char_type; |
162 | typedef char_traits<char>::int_type int_type; |
163 | typedef char_traits<char>::pos_type pos_type; |
164 | typedef char_traits<char>::off_type off_type; |
165 | |
166 | strstream(); |
167 | strstream(char*, int, ios_base::openmode = ios_base::in | ios_base::out); |
168 | virtual ~strstream(); |
169 | |
170 | _GLIBCXX_CONST strstreambuf* rdbuf() const throw (); |
171 | void freeze(bool = true) throw (); |
172 | _GLIBCXX_PURE int pcount() const throw (); |
173 | char* str() throw (); |
174 | |
175 | private: |
176 | strstreambuf _M_buf; |
177 | }; |
178 | |
179 | _GLIBCXX_END_NAMESPACE_VERSION |
180 | } |
181 | |
182 | #endif |
183 | |