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
44 _GLIBCXX_BEGIN_NAMESPACE_CXX11
64 template<
typename _CharT,
typename _Traits,
typename _Alloc>
67 struct __xfer_bufptrs;
70 typedef _CharT char_type;
71 typedef _Traits traits_type;
74 typedef _Alloc allocator_type;
75 typedef typename traits_type::int_type int_type;
76 typedef typename traits_type::pos_type pos_type;
77 typedef typename traits_type::off_type off_type;
81 typedef typename __string_type::size_type __size_type;
127 _M_string(__str.data(), __str.size(), __str.get_allocator())
128 { _M_stringbuf_init(__mode); }
130 #if __cplusplus >= 201103L
135 { __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0); }
145 __xfer_bufptrs __st{__rhs,
this};
146 const __streambuf_type&
__base = __rhs;
147 __streambuf_type::operator=(
__base);
151 __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0);
159 __xfer_bufptrs __r_st{__rhs,
this};
160 __streambuf_type&
__base = __rhs;
162 __rhs.pubimbue(this->
pubimbue(__rhs.getloc()));
163 std::swap(
_M_mode, __rhs._M_mode);
164 std::swap(_M_string, __rhs._M_string);
184 if (this->pptr() > this->egptr())
213 _M_stringbuf_init(ios_base::openmode __mode)
216 __size_type __len = 0;
218 __len = _M_string.
size();
219 _M_sync(
const_cast<char_type*
>(_M_string.
data()), 0, __len);
229 __ret = this->egptr() - this->gptr();
238 pbackfail(int_type __c = traits_type::eof());
241 overflow(int_type __c = traits_type::eof());
254 virtual __streambuf_type*
268 _M_sync(__s, __n, 0);
274 seekoff(off_type __off, ios_base::seekdir __way,
285 _M_sync(char_type*
__base, __size_type __i, __size_type __o);
293 if (this->pptr() && this->pptr() > this->egptr())
296 this->
setg(this->
eback(), this->gptr(), this->pptr());
298 this->
setg(this->pptr(), this->pptr(), this->pptr());
305 _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off);
308 #if __cplusplus >= 201103L
309 #if _GLIBCXX_USE_CXX11_ABI
312 struct __xfer_bufptrs
315 : _M_to{__to}, _M_goff{-1, -1, -1}, _M_poff{-1, -1, -1}
317 const _CharT*
const __str = __from._M_string.data();
318 const _CharT* __end =
nullptr;
321 _M_goff[0] = __from.eback() - __str;
322 _M_goff[1] = __from.gptr() - __str;
323 _M_goff[2] = __from.egptr() - __str;
324 __end = __from.egptr();
328 _M_poff[0] = __from.pbase() - __str;
329 _M_poff[1] = __from.pptr() - __from.pbase();
330 _M_poff[2] = __from.epptr() - __str;
331 if (__from.pptr() > __end)
332 __end = __from.pptr();
341 __mut_from._M_string._M_length(__end - __str);
347 char_type* __str =
const_cast<char_type*
>(_M_to->_M_string.data());
348 if (_M_goff[0] != -1)
349 _M_to->setg(__str+_M_goff[0], __str+_M_goff[1], __str+_M_goff[2]);
350 if (_M_poff[0] != -1)
351 _M_to->_M_pbump(__str+_M_poff[0], __str+_M_poff[2], _M_poff[1]);
360 struct __xfer_bufptrs
369 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
391 template<
typename _CharT,
typename _Traits,
typename _Alloc>
396 typedef _CharT char_type;
397 typedef _Traits traits_type;
400 typedef _Alloc allocator_type;
401 typedef typename traits_type::int_type int_type;
402 typedef typename traits_type::pos_type pos_type;
403 typedef typename traits_type::off_type off_type;
411 __stringbuf_type _M_stringbuf;
427 { this->
init(&_M_stringbuf); }
444 { this->
init(&_M_stringbuf); }
463 { this->
init(&_M_stringbuf); }
474 #if __cplusplus >= 201103L
478 : __istream_type(
std::move(__rhs)),
479 _M_stringbuf(
std::move(__rhs._M_stringbuf))
480 { __istream_type::set_rdbuf(&_M_stringbuf); }
491 _M_stringbuf =
std::move(__rhs._M_stringbuf);
499 _M_stringbuf.swap(__rhs._M_stringbuf);
512 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
520 {
return _M_stringbuf.str(); }
530 { _M_stringbuf.str(__s); }
549 template <
typename _CharT,
typename _Traits,
typename _Alloc>
554 typedef _CharT char_type;
555 typedef _Traits traits_type;
558 typedef _Alloc allocator_type;
559 typedef typename traits_type::int_type int_type;
560 typedef typename traits_type::pos_type pos_type;
561 typedef typename traits_type::off_type off_type;
569 __stringbuf_type _M_stringbuf;
585 { this->
init(&_M_stringbuf); }
602 { this->
init(&_M_stringbuf); }
621 { this->
init(&_M_stringbuf); }
632 #if __cplusplus >= 201103L
636 : __ostream_type(
std::move(__rhs)),
637 _M_stringbuf(
std::move(__rhs._M_stringbuf))
638 { __ostream_type::set_rdbuf(&_M_stringbuf); }
649 _M_stringbuf =
std::move(__rhs._M_stringbuf);
657 _M_stringbuf.swap(__rhs._M_stringbuf);
670 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
678 {
return _M_stringbuf.str(); }
688 { _M_stringbuf.str(__s); }
707 template <
typename _CharT,
typename _Traits,
typename _Alloc>
712 typedef _CharT char_type;
713 typedef _Traits traits_type;
716 typedef _Alloc allocator_type;
717 typedef typename traits_type::int_type int_type;
718 typedef typename traits_type::pos_type pos_type;
719 typedef typename traits_type::off_type off_type;
727 __stringbuf_type _M_stringbuf;
743 { this->
init(&_M_stringbuf); }
758 { this->
init(&_M_stringbuf); }
775 { this->
init(&_M_stringbuf); }
786 #if __cplusplus >= 201103L
790 : __iostream_type(
std::move(__rhs)),
791 _M_stringbuf(
std::move(__rhs._M_stringbuf))
792 { __iostream_type::set_rdbuf(&_M_stringbuf); }
802 __iostream_type::operator=(
std::move(__rhs));
803 _M_stringbuf =
std::move(__rhs._M_stringbuf);
810 __iostream_type::swap(__rhs);
811 _M_stringbuf.swap(__rhs._M_stringbuf);
824 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
832 {
return _M_stringbuf.str(); }
842 { _M_stringbuf.str(__s); }
845 #if __cplusplus >= 201103L
847 template <
class _CharT,
class _Traits,
class _Allocator>
854 template <
class _CharT,
class _Traits,
class _Allocator>
861 template <
class _CharT,
class _Traits,
class _Allocator>
868 template <
class _CharT,
class _Traits,
class _Allocator>
875 _GLIBCXX_END_NAMESPACE_CXX11
876 _GLIBCXX_END_NAMESPACE_VERSION
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
ISO C++ entities toplevel namespace is std.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
void swap(basic_stringstream< _CharT, _Traits, _Allocator > &__x, basic_stringstream< _CharT, _Traits, _Allocator > &__y)
Swap specialization for stringstreams.
constexpr _Iterator __base(_Iterator __it)
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
The actual work of input and output (interface).
void setg(char_type *__gbeg, char_type *__gnext, char_type *__gend)
Setting the three read area pointers.
char_type * pbase() const
Access to the put area.
locale pubimbue(const locale &__loc)
Entry point for imbue().
char_type * eback() const
Access to the get area.
Template class basic_istream.
void swap(basic_istream &__rhs)
Simple extraction.
basic_istream & operator=(const basic_istream &)=delete
Simple extraction.
Template class basic_ostream.
void swap(basic_ostream &__rhs)
Simple insertion.
basic_ostream & operator=(const basic_ostream &)=delete
Simple insertion.
Template class basic_iostream.
The actual work of input and output (for std::string).
virtual streamsize showmanyc()
Investigating the data available.
basic_stringbuf(ios_base::openmode __mode)
Starts with an empty string buffer.
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.
virtual int_type underflow()
Fetches more data from the controlled sequence.
void str(const __string_type &__s)
Setting a new buffer.
__string_type str() const
Copying out the string buffer.
virtual pos_type seekpos(pos_type __sp, ios_base::openmode __mode=ios_base::in|ios_base::out)
Alters the stream positions.
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.
virtual int_type overflow(int_type __c=traits_type::eof())
Consumes data from the buffer; writes to the controlled sequence.
basic_stringbuf()
Starts with an empty string buffer.
virtual int_type pbackfail(int_type __c=traits_type::eof())
Tries to back up the input sequence.
ios_base::openmode _M_mode
Place to stash in || out || in | out settings for current stringbuf.
Controlling input for std::string.
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
void str(const __string_type &__s)
Setting a new buffer.
~basic_istringstream()
The destructor does nothing.
__string_type str() const
Copying out the string buffer.
basic_istringstream(const __string_type &__str, ios_base::openmode __mode=ios_base::in)
Starts with an existing string buffer.
basic_istringstream()
Default constructor starts with an empty string buffer.
basic_istringstream(ios_base::openmode __mode)
Starts with an empty string buffer.
Controlling output for std::string.
~basic_ostringstream()
The destructor does nothing.
void str(const __string_type &__s)
Setting a new buffer.
__string_type str() const
Copying out the string buffer.
basic_ostringstream()
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.
basic_ostringstream(ios_base::openmode __mode)
Starts with an empty string buffer.
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
Controlling input and output for std::string.
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
~basic_stringstream()
The destructor does nothing.
__string_type str() const
Copying out the string buffer.
basic_stringstream(const __string_type &__str, ios_base::openmode __m=ios_base::out|ios_base::in)
Starts with an existing string buffer.
basic_stringstream()
Default constructor starts with an empty string buffer.
void str(const __string_type &__s)
Setting a new buffer.
basic_stringstream(ios_base::openmode __m)
Starts with an empty string buffer.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
const _CharT * data() const noexcept
Return const pointer to contents.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
The base of the I/O class hierarchy.
static const openmode in
Open for input. Default for ifstream and fstream.
static const openmode out
Open for output. Default for ofstream and fstream.
static const openmode app
Seek to end before each write.
static const openmode ate
Open and seek to end immediately after opening.