34 #ifndef _GLIBCXX_SSTREAM
35 #define _GLIBCXX_SSTREAM 1
37 #pragma GCC system_header
42 namespace std _GLIBCXX_VISIBILITY(default)
44 _GLIBCXX_BEGIN_NAMESPACE_VERSION
59 template<
typename _CharT,
typename _Traits,
typename _Alloc>
60 class basic_stringbuf :
public basic_streambuf<_CharT, _Traits>
64 typedef _CharT char_type;
65 typedef _Traits traits_type;
68 typedef _Alloc allocator_type;
69 typedef typename traits_type::int_type int_type;
70 typedef typename traits_type::pos_type pos_type;
71 typedef typename traits_type::off_type off_type;
73 typedef basic_streambuf<char_type, traits_type> __streambuf_type;
74 typedef basic_string<char_type, _Traits, _Alloc> __string_type;
75 typedef typename __string_type::size_type __size_type;
110 { _M_stringbuf_init(__mode); }
156 _M_stringbuf_init(ios_base::openmode __mode)
159 __size_type __len = 0;
161 __len = _M_string.
size();
162 _M_sync(const_cast<char_type*>(_M_string.
data()), 0, __len);
181 pbackfail(int_type __c = traits_type::eof());
184 overflow(int_type __c = traits_type::eof());
197 virtual __streambuf_type*
211 _M_sync(__s, __n, 0);
217 seekoff(off_type __off, ios_base::seekdir __way,
228 _M_sync(char_type*
__base, __size_type __i, __size_type __o);
248 _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off);
262 template<
typename _CharT,
typename _Traits,
typename _Alloc>
263 class basic_istringstream :
public basic_istream<_CharT, _Traits>
267 typedef _CharT char_type;
268 typedef _Traits traits_type;
271 typedef _Alloc allocator_type;
272 typedef typename traits_type::int_type int_type;
273 typedef typename traits_type::pos_type pos_type;
274 typedef typename traits_type::off_type off_type;
277 typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
278 typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type;
279 typedef basic_istream<char_type, traits_type> __istream_type;
282 __stringbuf_type _M_stringbuf;
301 { this->
init(&_M_stringbuf); }
318 ios_base::openmode __mode = ios_base::in)
320 { this->
init(&_M_stringbuf); }
340 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
348 {
return _M_stringbuf.str(); }
358 { _M_stringbuf.str(__s); }
372 template <
typename _CharT,
typename _Traits,
typename _Alloc>
373 class basic_ostringstream :
public basic_ostream<_CharT, _Traits>
377 typedef _CharT char_type;
378 typedef _Traits traits_type;
381 typedef _Alloc allocator_type;
382 typedef typename traits_type::int_type int_type;
383 typedef typename traits_type::pos_type pos_type;
384 typedef typename traits_type::off_type off_type;
387 typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
388 typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type;
389 typedef basic_ostream<char_type, traits_type> __ostream_type;
392 __stringbuf_type _M_stringbuf;
411 { this->
init(&_M_stringbuf); }
430 { this->
init(&_M_stringbuf); }
450 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
458 {
return _M_stringbuf.str(); }
468 { _M_stringbuf.str(__s); }
482 template <
typename _CharT,
typename _Traits,
typename _Alloc>
483 class basic_stringstream :
public basic_iostream<_CharT, _Traits>
487 typedef _CharT char_type;
488 typedef _Traits traits_type;
491 typedef _Alloc allocator_type;
492 typedef typename traits_type::int_type int_type;
493 typedef typename traits_type::pos_type pos_type;
494 typedef typename traits_type::off_type off_type;
497 typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
498 typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type;
499 typedef basic_iostream<char_type, traits_type> __iostream_type;
502 __stringbuf_type _M_stringbuf;
519 { this->
init(&_M_stringbuf); }
536 { this->
init(&_M_stringbuf); }
556 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
564 {
return _M_stringbuf.str(); }
574 { _M_stringbuf.str(__s); }
577 _GLIBCXX_END_NAMESPACE_VERSION
The base of the I/O class hierarchy.This class defines everything that can be defined about I/O that ...
virtual int_type pbackfail(int_type __c=traits_type::eof())
Tries to back up the input sequence.
basic_stringbuf(const __string_type &__str, ios_base::openmode __mode=ios_base::in|ios_base::out)
Starts with an existing string buffer.
virtual __streambuf_type * setbuf(char_type *__s, streamsize __n)
Manipulates the buffer.
basic_ostringstream(ios_base::openmode __mode=ios_base::out)
Default constructor starts with an empty string buffer.
char_type * eback() const
Access to the get area.
char_type * pbase() const
Access to the put area.
basic_stringstream(ios_base::openmode __m=ios_base::out|ios_base::in)
Default constructor starts with an empty string buffer.
void str(const __string_type &__s)
Setting a new buffer.
Controlling output.This is the base class for all output streams. It provides text formatting of all ...
basic_stringstream(const __string_type &__str, ios_base::openmode __m=ios_base::out|ios_base::in)
Starts with an existing string buffer.
virtual streamsize showmanyc()
Investigating the data available.
~basic_stringstream()
The destructor does nothing.
__string_type str() const
Copying out the string buffer.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
const _CharT * data() const
Return const pointer to contents.
void str(const __string_type &__s)
Setting a new buffer.
basic_istringstream(ios_base::openmode __mode=ios_base::in)
Default constructor starts with an empty string buffer.
basic_ostringstream(const __string_type &__str, ios_base::openmode __mode=ios_base::out)
Starts with an existing string buffer.
__string_type str() const
Copying out the string buffer.
Controlling input.This is the base class for all input streams. It provides text formatting of all bu...
static const openmode ate
Open and seek to end immediately after opening.
void setg(char_type *__gbeg, char_type *__gnext, char_type *__gend)
Setting the three read area pointers.
basic_stringbuf(ios_base::openmode __mode=ios_base::in|ios_base::out)
Starts with an empty string buffer.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
void str(const __string_type &__s)
Setting a new buffer.
static const openmode app
Seek to end before each write.
__string_type str() const
Copying out the string buffer.
constexpr size_t size() const
Returns the total number of bits.
basic_istringstream(const __string_type &__str, ios_base::openmode __mode=ios_base::in)
Starts with an existing string buffer.
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.
char_type * egptr() const
Access to the get area.
static const openmode in
Open for input. Default for ifstream and fstream.
size_type size() const
Returns the number of characters in the string, not including any null-termination.
char_type * gptr() const
Access to the get area.
virtual int_type overflow(int_type __c=traits_type::eof())
Consumes data from the buffer; writes to the controlled sequence.
Merging istream and ostream capabilities.This class multiply inherits from the input and output strea...
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
static const openmode out
Open for output. Default for ofstream and fstream.
virtual int_type underflow()
Fetches more data from the controlled sequence.
The actual work of input and output (interface).This is a base class. Derived stream buffers each con...
~basic_ostringstream()
The destructor does nothing.
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
char_type * pptr() const
Access to the put area.
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
ios_base::openmode _M_mode
Place to stash in || out || in | out settings for current stringbuf.
virtual pos_type seekpos(pos_type __sp, ios_base::openmode __mode=ios_base::in|ios_base::out)
Alters the stream positions.
__string_type str() const
Copying out the string buffer.
~basic_istringstream()
The destructor does nothing.