33 #ifndef _GLIBCXX_SSTREAM
34 #define _GLIBCXX_SSTREAM 1
36 #pragma GCC system_header
41 namespace std _GLIBCXX_VISIBILITY(default)
43 _GLIBCXX_BEGIN_NAMESPACE_VERSION
63 template<
typename _CharT,
typename _Traits,
typename _Alloc>
64 class basic_stringbuf :
public basic_streambuf<_CharT, _Traits>
68 typedef _CharT char_type;
69 typedef _Traits traits_type;
72 typedef _Alloc allocator_type;
73 typedef typename traits_type::int_type int_type;
74 typedef typename traits_type::pos_type pos_type;
75 typedef typename traits_type::off_type off_type;
77 typedef basic_streambuf<char_type, traits_type> __streambuf_type;
78 typedef basic_string<char_type, _Traits, _Alloc> __string_type;
79 typedef typename __string_type::size_type __size_type;
114 { _M_stringbuf_init(__mode); }
160 _M_stringbuf_init(ios_base::openmode __mode)
163 __size_type __len = 0;
165 __len = _M_string.
size();
166 _M_sync(const_cast<char_type*>(_M_string.
data()), 0, __len);
185 pbackfail(int_type __c = traits_type::eof());
188 overflow(int_type __c = traits_type::eof());
201 virtual __streambuf_type*
215 _M_sync(__s, __n, 0);
221 seekoff(off_type __off, ios_base::seekdir __way,
232 _M_sync(char_type*
__base, __size_type __i, __size_type __o);
252 _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off);
271 template<
typename _CharT,
typename _Traits,
typename _Alloc>
272 class basic_istringstream :
public basic_istream<_CharT, _Traits>
276 typedef _CharT char_type;
277 typedef _Traits traits_type;
280 typedef _Alloc allocator_type;
281 typedef typename traits_type::int_type int_type;
282 typedef typename traits_type::pos_type pos_type;
283 typedef typename traits_type::off_type off_type;
286 typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
287 typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type;
288 typedef basic_istream<char_type, traits_type> __istream_type;
291 __stringbuf_type _M_stringbuf;
310 { this->
init(&_M_stringbuf); }
327 ios_base::openmode __mode = ios_base::in)
329 { this->
init(&_M_stringbuf); }
349 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
357 {
return _M_stringbuf.str(); }
367 { _M_stringbuf.str(__s); }
386 template <
typename _CharT,
typename _Traits,
typename _Alloc>
387 class basic_ostringstream :
public basic_ostream<_CharT, _Traits>
391 typedef _CharT char_type;
392 typedef _Traits traits_type;
395 typedef _Alloc allocator_type;
396 typedef typename traits_type::int_type int_type;
397 typedef typename traits_type::pos_type pos_type;
398 typedef typename traits_type::off_type off_type;
401 typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
402 typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type;
403 typedef basic_ostream<char_type, traits_type> __ostream_type;
406 __stringbuf_type _M_stringbuf;
425 { this->
init(&_M_stringbuf); }
444 { this->
init(&_M_stringbuf); }
464 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
472 {
return _M_stringbuf.str(); }
482 { _M_stringbuf.str(__s); }
501 template <
typename _CharT,
typename _Traits,
typename _Alloc>
502 class basic_stringstream :
public basic_iostream<_CharT, _Traits>
506 typedef _CharT char_type;
507 typedef _Traits traits_type;
510 typedef _Alloc allocator_type;
511 typedef typename traits_type::int_type int_type;
512 typedef typename traits_type::pos_type pos_type;
513 typedef typename traits_type::off_type off_type;
516 typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
517 typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type;
518 typedef basic_iostream<char_type, traits_type> __iostream_type;
521 __stringbuf_type _M_stringbuf;
539 { this->
init(&_M_stringbuf); }
556 { this->
init(&_M_stringbuf); }
576 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
584 {
return _M_stringbuf.str(); }
594 { _M_stringbuf.str(__s); }
597 _GLIBCXX_END_NAMESPACE_VERSION
const _CharT * data() const noexcept
Return const pointer to contents.
virtual __streambuf_type * setbuf(char_type *__s, streamsize __n)
Manipulates the buffer.
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
static const openmode out
Open for output. Default for ofstream and fstream.
The base of the I/O class hierarchy.This class defines everything that can be defined about I/O that ...
~basic_istringstream()
The destructor does nothing.
static const openmode ate
Open and seek to end immediately after opening.
basic_istringstream(const __string_type &__str, ios_base::openmode __mode=ios_base::in)
Starts with an existing string buffer.
~basic_ostringstream()
The destructor does nothing.
Template class basic_istream.
basic_ostringstream(ios_base::openmode __mode=ios_base::out)
Default constructor starts with an empty string buffer.
char_type * pptr() const
Access to the put area.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
static const openmode app
Seek to end before each write.
ios_base::openmode _M_mode
Place to stash in || out || in | out settings for current stringbuf.
char_type * pbase() const
Access to the put area.
__string_type str() const
Copying out the string buffer.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
virtual pos_type seekpos(pos_type __sp, ios_base::openmode __mode=ios_base::in|ios_base::out)
Alters the stream positions.
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
basic_ostringstream(const __string_type &__str, ios_base::openmode __mode=ios_base::out)
Starts with an existing string buffer.
basic_stringstream(ios_base::openmode __m=ios_base::out|ios_base::in)
Default constructor starts with an empty string buffer.
__string_type str() const
Copying out the string buffer.
constexpr size_t size() const noexcept
Returns the total number of bits.
virtual streamsize showmanyc()
Investigating the data available.
char_type * eback() const
Access to the get area.
void str(const __string_type &__s)
Setting a new buffer.
void str(const __string_type &__s)
Setting a new buffer.
static const openmode in
Open for input. Default for ifstream and fstream.
basic_stringbuf(const __string_type &__str, ios_base::openmode __mode=ios_base::in|ios_base::out)
Starts with an existing string buffer.
Template class basic_iostream.
basic_stringstream(const __string_type &__str, ios_base::openmode __m=ios_base::out|ios_base::in)
Starts with an existing string buffer.
char_type * gptr() const
Access to the get area.
virtual int_type underflow()
Fetches more data from the controlled sequence.
The actual work of input and output (interface).
virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode=ios_base::in|ios_base::out)
Alters the stream positions.
void str(const __string_type &__s)
Setting a new buffer.
void setg(char_type *__gbeg, char_type *__gnext, char_type *__gend)
Setting the three read area pointers.
char_type * egptr() const
Access to the get area.
__string_type str() const
Copying out the string buffer.
~basic_stringstream()
The destructor does nothing.
basic_istringstream(ios_base::openmode __mode=ios_base::in)
Default constructor starts with an empty string buffer.
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
Template class basic_ostream.
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
basic_stringbuf(ios_base::openmode __mode=ios_base::in|ios_base::out)
Starts with an empty string buffer.
__string_type str() const
Copying out the string buffer.
void str(const __string_type &__s)
Setting a new buffer.