34 #ifndef _GLIBCXX_SSTREAM
35 #define _GLIBCXX_SSTREAM 1
37 #pragma GCC system_header
42 _GLIBCXX_BEGIN_NAMESPACE(std)
57 template<typename _CharT, typename _Traits, typename _Alloc>
58 class basic_stringbuf : public basic_streambuf<_CharT, _Traits>
62 typedef _CharT char_type;
63 typedef _Traits traits_type;
66 typedef _Alloc allocator_type;
67 typedef typename traits_type::int_type int_type;
68 typedef typename traits_type::pos_type pos_type;
69 typedef typename traits_type::off_type off_type;
71 typedef basic_streambuf<char_type, traits_type> __streambuf_type;
72 typedef basic_string<char_type, _Traits, _Alloc> __string_type;
73 typedef typename __string_type::size_type __size_type;
80 __string_type _M_string;
93 : __streambuf_type(), _M_mode(__mode), _M_string()
106 ios_base::openmode __mode = ios_base::in | ios_base::out)
107 : __streambuf_type(), _M_mode(), _M_string(__str.data(), __str.size())
108 { _M_stringbuf_init(__mode); }
126 if (this->pptr() > this->egptr())
127 __ret = __string_type(this->pbase(), this->pptr());
129 __ret = __string_type(this->pbase(), this->egptr());
144 str(
const __string_type& __s)
148 _M_stringbuf_init(_M_mode);
154 _M_stringbuf_init(ios_base::openmode __mode)
157 __size_type __len = 0;
158 if (_M_mode & (ios_base::ate | ios_base::app))
159 __len = _M_string.
size();
160 _M_sync(const_cast<char_type*>(_M_string.
data()), 0, __len);
167 if (_M_mode & ios_base::in)
170 __ret = this->egptr() - this->gptr();
179 pbackfail(int_type __c = traits_type::eof());
182 overflow(int_type __c = traits_type::eof());
195 virtual __streambuf_type*
209 _M_sync(__s, __n, 0);
215 seekoff(off_type __off, ios_base::seekdir __way,
216 ios_base::openmode __mode = ios_base::in | ios_base::out);
219 seekpos(pos_type __sp,
220 ios_base::openmode __mode = ios_base::in | ios_base::out);
226 _M_sync(char_type* __base, __size_type __i, __size_type __o);
233 const bool __testin = _M_mode & ios_base::in;
234 if (this->pptr() && this->pptr() > this->egptr())
237 this->setg(this->eback(), this->gptr(), this->pptr());
239 this->setg(this->pptr(), this->pptr(), this->pptr());
255 template<
typename _CharT,
typename _Traits,
typename _Alloc>
256 class basic_istringstream :
public basic_istream<_CharT, _Traits>
260 typedef _CharT char_type;
261 typedef _Traits traits_type;
264 typedef _Alloc allocator_type;
265 typedef typename traits_type::int_type int_type;
266 typedef typename traits_type::pos_type pos_type;
267 typedef typename traits_type::off_type off_type;
270 typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
271 typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type;
272 typedef basic_istream<char_type, traits_type> __istream_type;
275 __stringbuf_type _M_stringbuf;
294 { this->init(&_M_stringbuf); }
311 ios_base::openmode __mode = ios_base::in)
313 { this->init(&_M_stringbuf); }
333 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
341 {
return _M_stringbuf.
str(); }
350 str(
const __string_type& __s)
351 { _M_stringbuf.str(__s); }
365 template <
typename _CharT,
typename _Traits,
typename _Alloc>
366 class basic_ostringstream :
public basic_ostream<_CharT, _Traits>
370 typedef _CharT char_type;
371 typedef _Traits traits_type;
374 typedef _Alloc allocator_type;
375 typedef typename traits_type::int_type int_type;
376 typedef typename traits_type::pos_type pos_type;
377 typedef typename traits_type::off_type off_type;
380 typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
381 typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type;
382 typedef basic_ostream<char_type, traits_type> __ostream_type;
385 __stringbuf_type _M_stringbuf;
404 { this->init(&_M_stringbuf); }
421 ios_base::openmode __mode = ios_base::out)
423 { this->init(&_M_stringbuf); }
443 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
451 {
return _M_stringbuf.
str(); }
460 str(
const __string_type& __s)
461 { _M_stringbuf.str(__s); }
475 template <
typename _CharT,
typename _Traits,
typename _Alloc>
476 class basic_stringstream :
public basic_iostream<_CharT, _Traits>
480 typedef _CharT char_type;
481 typedef _Traits traits_type;
484 typedef _Alloc allocator_type;
485 typedef typename traits_type::int_type int_type;
486 typedef typename traits_type::pos_type pos_type;
487 typedef typename traits_type::off_type off_type;
490 typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
491 typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type;
492 typedef basic_iostream<char_type, traits_type> __iostream_type;
495 __stringbuf_type _M_stringbuf;
512 { this->init(&_M_stringbuf); }
527 ios_base::openmode __m = ios_base::out | ios_base::in)
529 { this->init(&_M_stringbuf); }
549 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
557 {
return _M_stringbuf.
str(); }
566 str(
const __string_type& __s)
567 { _M_stringbuf.str(__s); }
570 _GLIBCXX_END_NAMESPACE
572 #ifndef _GLIBCXX_EXPORT_TEMPLATE