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;
520 { this->
init(&_M_stringbuf); }
537 { this->
init(&_M_stringbuf); }
557 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
565 {
return _M_stringbuf.str(); }
575 { _M_stringbuf.str(__s); }
578 _GLIBCXX_END_NAMESPACE_VERSION
static const openmode app
Seek to end before each write.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
char_type * pptr() const
Access to the put area.
virtual int_type underflow()
Fetches more data from the controlled sequence.
__string_type str() const
Copying out the 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.
char_type * eback() const
Access to the get 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.
Template class basic_ostream.This is the base class for all output streams. It provides text formatti...
basic_istringstream(ios_base::openmode __mode=ios_base::in)
Default constructor starts with an empty string buffer.
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.
static const openmode ate
Open and seek to end immediately after opening.
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
basic_stringbuf(const __string_type &__str, ios_base::openmode __mode=ios_base::in|ios_base::out)
Starts with an existing string buffer.
size_type size() const _GLIBCXX_NOEXCEPT
Returns the number of characters in the string, not including any null-termination.
const _CharT * data() const _GLIBCXX_NOEXCEPT
Return const pointer to contents.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
~basic_ostringstream()
The destructor does nothing.
virtual int_type overflow(int_type __c=traits_type::eof())
Consumes data from the buffer; writes to the controlled sequence.
static const openmode out
Open for output. Default for ofstream and fstream.
ios_base::openmode _M_mode
Place to stash in || out || in | out settings for current stringbuf.
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
basic_stringbuf(ios_base::openmode __mode=ios_base::in|ios_base::out)
Starts with an empty string buffer.
~basic_stringstream()
The destructor does nothing.
virtual streamsize showmanyc()
Investigating the data available.
basic_ostringstream(ios_base::openmode __mode=ios_base::out)
Default constructor starts with an empty string buffer.
void setg(char_type *__gbeg, char_type *__gnext, char_type *__gend)
Setting the three read area pointers.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
Template class basic_istream.This is the base class for all input streams. It provides text formattin...
virtual int_type pbackfail(int_type __c=traits_type::eof())
Tries to back up the input sequence.
~basic_istringstream()
The destructor does nothing.
basic_ostringstream(const __string_type &__str, ios_base::openmode __mode=ios_base::out)
Starts with an existing string buffer.
static const openmode in
Open for input. Default for ifstream and fstream.
__string_type str() const
Copying out the string buffer.
The base of the I/O class hierarchy.This class defines everything that can be defined about I/O that ...
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
char_type * pbase() const
Access to the put area.
basic_stringstream(const __string_type &__str, ios_base::openmode __m=ios_base::out|ios_base::in)
Starts with an existing string buffer.
virtual __streambuf_type * setbuf(char_type *__s, streamsize __n)
Manipulates the buffer.
void str(const __string_type &__s)
Setting a new buffer.
char_type * egptr() const
Access to the get area.
char_type * gptr() const
Access to the get area.
void str(const __string_type &__s)
Setting a new buffer.
The actual work of input and output (interface).This is a base class. Derived stream buffers each con...
void clear() _GLIBCXX_NOEXCEPT
void str(const __string_type &__s)
Setting a new buffer.
__string_type str() const
Copying out the string buffer.
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
basic_istringstream(const __string_type &__str, ios_base::openmode __mode=ios_base::in)
Starts with an existing string buffer.
Template class basic_iostreamThis class multiply inherits from the input and output stream classes si...
constexpr size_t size() const _GLIBCXX_NOEXCEPT
Returns the total number of bits.