29 #ifndef PT_STRINGSTREAM_H
30 #define PT_STRINGSTREAM_H
33 #include <Pt/String.h>
34 #include <Pt/StreamBuffer.h>
35 #include <Pt/IOStream.h>
56 typedef typename traits_type::int_type
int_type;
59 typedef typename traits_type::pos_type
pos_type;
62 typedef typename traits_type::off_type
off_type;
65 explicit StringBuffer(std::ios::openmode mode = std::ios::in|std::ios::out);
68 std::ios::openmode mode = std::ios::in|std::ios::out);
79 virtual std::streamsize showmanyc()
override;
81 virtual int sync()
override;
85 virtual int_type underflow()
override;
89 virtual std::streamsize xsgetn(
char_type* s, std::streamsize n)
override;
91 virtual std::streamsize xsputn(
const char_type* s, std::streamsize n)
override;
94 std::ios_base::openmode m = std::ios_base::in|std::ios_base::out)
override;
97 std::ios_base::openmode m = std::ios_base::in|std::ios_base::out)
override;
100 std::ios_base::openmode _mode;
109 #if defined(_MSC_VER) && __cplusplus >= 202002L
113 class PT_API
IStringStream :
public std::basic_istream<Pt::Char>
117 typedef std::char_traits<Pt::Char> traits_type;
118 typedef std::allocator<Pt::Char> allocator_type;
119 typedef traits_type::int_type int_type;
120 typedef traits_type::pos_type pos_type;
121 typedef traits_type::off_type off_type;
124 explicit IStringStream(std::ios_base::openmode mode = ios_base::in);
127 std::ios_base::openmode mode = std::ios_base::in);
129 StringBuffer* rdbuf()
const
133 {
return _buffer.str(); }
136 { _buffer.str(str); }
143 class PT_API
OStringStream :
public std::basic_ostream<Pt::Char>
147 typedef std::char_traits<Pt::Char> traits_type;
148 typedef std::allocator<Pt::Char> allocator_type;
149 typedef traits_type::int_type int_type;
150 typedef traits_type::pos_type pos_type;
151 typedef traits_type::off_type off_type;
154 explicit OStringStream(std::ios_base::openmode mode = ios_base::out);
157 std::ios_base::openmode mode = std::ios_base::out);
159 StringBuffer* rdbuf()
const
163 {
return _buffer.str(); }
166 { _buffer.str(str); }
173 class PT_API
StringStream :
public std::basic_iostream<Pt::Char>
177 typedef std::char_traits<Pt::Char> traits_type;
178 typedef std::allocator<Pt::Char> allocator_type;
179 typedef traits_type::int_type int_type;
180 typedef traits_type::pos_type pos_type;
181 typedef traits_type::off_type off_type;
184 explicit StringStream(std::ios_base::openmode mode = ios_base::in | ios_base::out);
187 std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out);
189 StringBuffer* rdbuf()
const
193 {
return _buffer.str(); }
196 { _buffer.str(str); }