33#ifndef _GLIBCXX_SSTREAM
34#define _GLIBCXX_SSTREAM 1
36#pragma GCC system_header
44#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
45# define _GLIBCXX_LVAL_REF_QUAL &
47# define _GLIBCXX_LVAL_REF_QUAL
50namespace std _GLIBCXX_VISIBILITY(default)
52_GLIBCXX_BEGIN_NAMESPACE_VERSION
53_GLIBCXX_BEGIN_NAMESPACE_CXX11
73 template<
typename _CharT,
typename _Traits,
typename _Alloc>
76 struct __xfer_bufptrs;
78#if __cplusplus >= 201103L
87 typedef _CharT char_type;
88 typedef _Traits traits_type;
91 typedef _Alloc allocator_type;
92 typedef typename traits_type::int_type int_type;
93 typedef typename traits_type::pos_type pos_type;
94 typedef typename traits_type::off_type off_type;
98 typedef typename __string_type::size_type __size_type;
144 _M_string(__str.
data(), __str.
size(), __str.get_allocator())
145 { _M_stringbuf_init(__mode); }
147#if __cplusplus >= 201103L
152 { __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0); }
154#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
161 const allocator_type& __a)
162 : __streambuf_type(),
_M_mode(__mode), _M_string(__a)
170 { _M_stringbuf_init(__mode); }
172 template<
typename _SAlloc>
174 const allocator_type& __a)
178 template<
typename _SAlloc>
181 const allocator_type& __a)
182 : __streambuf_type(),
_M_mode(__mode),
183 _M_string(__s.
data(), __s.
size(), __a)
184 { _M_stringbuf_init(__mode); }
186 template<
typename _SAlloc>
196 { __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0); }
198 allocator_type get_allocator() const noexcept
210 __xfer_bufptrs __st{__rhs,
this};
211 const __streambuf_type&
__base = __rhs;
212 __streambuf_type::operator=(
__base);
216 __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0);
224 __xfer_bufptrs __r_st{__rhs,
this};
225 __streambuf_type&
__base = __rhs;
227 __rhs.pubimbue(this->
pubimbue(__rhs.getloc()));
244 str() const _GLIBCXX_LVAL_REF_QUAL
247 if (char_type* __hi = _M_high_mark())
254#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
256 template<__allocator_like _SAlloc>
258 str(
const _SAlloc& __sa)
const
261 return { __sv.data(), __sv.size(), __sa };
268 if (char_type* __hi = _M_high_mark())
271 _M_string._M_set_length(_M_high_mark() - this->
pbase());
275 _M_sync(_M_string.
data(), 0, 0);
279 basic_string_view<char_type, traits_type>
280 view() const noexcept
282 if (char_type* __hi = _M_high_mark())
283 return { this->
pbase(), __hi };
305#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
307 template<__allocator_like _SAlloc>
308 requires (!is_same_v<_SAlloc, _Alloc>)
318 str(__string_type&& __s)
331 __size_type __len = 0;
333 __len = _M_string.
size();
334 _M_sync(
const_cast<char_type*
>(_M_string.
data()), 0, __len);
353 pbackfail(int_type __c = traits_type::eof());
356 overflow(int_type __c = traits_type::eof());
369 virtual __streambuf_type*
383 _M_sync(__s, __n, 0);
389 seekoff(off_type __off, ios_base::seekdir __way,
400 _M_sync(char_type*
__base, __size_type __i, __size_type __o);
407 if (char_type* __pptr = this->
pptr())
409 char_type* __egptr = this->
egptr();
410 if (!__egptr || __pptr > __egptr)
415 this->
setg(__pptr, __pptr, __pptr);
423 _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off);
430 __attribute__((__always_inline__))
432 _M_high_mark() const _GLIBCXX_NOEXCEPT
434 if (char_type* __pptr = this->
pptr())
436 char_type* __egptr = this->
egptr();
437 if (!__egptr || __pptr > __egptr)
445#if __cplusplus >= 201103L
446#if _GLIBCXX_USE_CXX11_ABI
449 struct __xfer_bufptrs
452 : _M_to{__to}, _M_goff{-1, -1, -1}, _M_poff{-1, -1, -1}
454 const _CharT*
const __str = __from._M_string.data();
455 const _CharT* __end =
nullptr;
458 _M_goff[0] = __from.eback() - __str;
459 _M_goff[1] = __from.gptr() - __str;
460 _M_goff[2] = __from.egptr() - __str;
461 __end = __from.egptr();
465 _M_poff[0] = __from.pbase() - __str;
466 _M_poff[1] = __from.pptr() - __from.pbase();
467 _M_poff[2] = __from.epptr() - __str;
468 if (!__end || __from.pptr() > __end)
469 __end = __from.pptr();
478 __mut_from._M_string._M_length(__end - __str);
484 char_type* __str =
const_cast<char_type*
>(_M_to->_M_string.data());
485 if (_M_goff[0] != -1)
486 _M_to->setg(__str+_M_goff[0], __str+_M_goff[1], __str+_M_goff[2]);
487 if (_M_poff[0] != -1)
488 _M_to->_M_pbump(__str+_M_poff[0], __str+_M_poff[2], _M_poff[1]);
497 struct __xfer_bufptrs
506 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
510#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
515 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
538 template<
typename _CharT,
typename _Traits,
typename _Alloc>
543 typedef _CharT char_type;
544 typedef _Traits traits_type;
547 typedef _Alloc allocator_type;
548 typedef typename traits_type::int_type int_type;
549 typedef typename traits_type::pos_type pos_type;
550 typedef typename traits_type::off_type off_type;
558 __stringbuf_type _M_stringbuf;
574 { this->
init(&_M_stringbuf); }
591 { this->
init(&_M_stringbuf); }
610 { this->
init(&_M_stringbuf); }
621#if __cplusplus >= 201103L
625 : __istream_type(
std::move(__rhs)),
626 _M_stringbuf(
std::move(__rhs._M_stringbuf))
627 { __istream_type::set_rdbuf(&_M_stringbuf); }
629#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
631 : __istream_type(), _M_stringbuf(__mode | ios_base::
in, __a)
637 : __istream_type(), _M_stringbuf(
std::move(__str), __mode | ios_base::
in)
640 template<
typename _SAlloc>
642 const allocator_type& __a)
646 template<
typename _SAlloc>
649 const allocator_type& __a)
650 : __istream_type(), _M_stringbuf(__str, __mode | ios_base::
in, __a)
653 template<
typename _SAlloc>
669 __istream_type::operator=(
std::move(__rhs));
670 _M_stringbuf =
std::move(__rhs._M_stringbuf);
677 __istream_type::swap(__rhs);
678 _M_stringbuf.swap(__rhs._M_stringbuf);
691 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
698 str() const _GLIBCXX_LVAL_REF_QUAL
699 {
return _M_stringbuf.str(); }
701#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
703 template<__allocator_like _SAlloc>
705 str(
const _SAlloc& __sa)
const
706 {
return _M_stringbuf.str(__sa); }
711 {
return std::move(_M_stringbuf).str(); }
713 basic_string_view<char_type, traits_type>
714 view() const noexcept
715 {
return _M_stringbuf.view(); }
726 { _M_stringbuf.str(__s); }
728#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
730 template<__allocator_like _SAlloc>
731 requires (!is_same_v<_SAlloc, _Alloc>)
734 { _M_stringbuf.str(__s); }
738 str(__string_type&& __s)
759 template <
typename _CharT,
typename _Traits,
typename _Alloc>
764 typedef _CharT char_type;
765 typedef _Traits traits_type;
768 typedef _Alloc allocator_type;
769 typedef typename traits_type::int_type int_type;
770 typedef typename traits_type::pos_type pos_type;
771 typedef typename traits_type::off_type off_type;
779 __stringbuf_type _M_stringbuf;
795 { this->
init(&_M_stringbuf); }
812 { this->
init(&_M_stringbuf); }
831 { this->
init(&_M_stringbuf); }
842#if __cplusplus >= 201103L
846 : __ostream_type(
std::move(__rhs)),
847 _M_stringbuf(
std::move(__rhs._M_stringbuf))
848 { __ostream_type::set_rdbuf(&_M_stringbuf); }
850#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
852 : __ostream_type(), _M_stringbuf(__mode | ios_base::
out, __a)
858 : __ostream_type(), _M_stringbuf(
std::move(__str), __mode | ios_base::
out)
861 template<
typename _SAlloc>
863 const allocator_type& __a)
867 template<
typename _SAlloc>
870 const allocator_type& __a)
871 : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::
out, __a)
874 template<
typename _SAlloc>
890 __ostream_type::operator=(
std::move(__rhs));
891 _M_stringbuf =
std::move(__rhs._M_stringbuf);
898 __ostream_type::swap(__rhs);
899 _M_stringbuf.swap(__rhs._M_stringbuf);
912 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
919 str() const _GLIBCXX_LVAL_REF_QUAL
920 {
return _M_stringbuf.str(); }
922#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
924 template<__allocator_like _SAlloc>
926 str(
const _SAlloc& __sa)
const
927 {
return _M_stringbuf.str(__sa); }
932 {
return std::move(_M_stringbuf).str(); }
934 basic_string_view<char_type, traits_type>
935 view() const noexcept
936 {
return _M_stringbuf.view(); }
947 { _M_stringbuf.str(__s); }
949#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
951 template<__allocator_like _SAlloc>
952 requires (!is_same_v<_SAlloc, _Alloc>)
955 { _M_stringbuf.str(__s); }
959 str(__string_type&& __s)
980 template <
typename _CharT,
typename _Traits,
typename _Alloc>
985 typedef _CharT char_type;
986 typedef _Traits traits_type;
989 typedef _Alloc allocator_type;
990 typedef typename traits_type::int_type int_type;
991 typedef typename traits_type::pos_type pos_type;
992 typedef typename traits_type::off_type off_type;
1000 __stringbuf_type _M_stringbuf;
1016 { this->
init(&_M_stringbuf); }
1031 { this->
init(&_M_stringbuf); }
1048 { this->
init(&_M_stringbuf); }
1059#if __cplusplus >= 201103L
1063 : __iostream_type(
std::move(__rhs)),
1064 _M_stringbuf(
std::move(__rhs._M_stringbuf))
1065 { __iostream_type::set_rdbuf(&_M_stringbuf); }
1067#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1069 : __iostream_type(), _M_stringbuf(__mode, __a)
1070 { this->
init(&_M_stringbuf); }
1076 : __iostream_type(), _M_stringbuf(
std::move(__str), __mode)
1079 template<
typename _SAlloc>
1081 const allocator_type& __a)
1085 template<
typename _SAlloc>
1088 const allocator_type& __a)
1089 : __iostream_type(), _M_stringbuf(__str, __mode, __a)
1092 template<
typename _SAlloc>
1109 __iostream_type::operator=(
std::move(__rhs));
1110 _M_stringbuf =
std::move(__rhs._M_stringbuf);
1117 __iostream_type::swap(__rhs);
1118 _M_stringbuf.swap(__rhs._M_stringbuf);
1131 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
1138 str() const _GLIBCXX_LVAL_REF_QUAL
1139 {
return _M_stringbuf.str(); }
1141#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1143 template<__allocator_like _SAlloc>
1145 str(
const _SAlloc& __sa)
const
1146 {
return _M_stringbuf.str(__sa); }
1151 {
return std::move(_M_stringbuf).str(); }
1153 basic_string_view<char_type, traits_type>
1154 view() const noexcept
1155 {
return _M_stringbuf.view(); }
1166 { _M_stringbuf.str(__s); }
1168#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1170 template<__allocator_like _SAlloc>
1171 requires (!is_same_v<_SAlloc, _Alloc>)
1174 { _M_stringbuf.str(__s); }
1178 str(__string_type&& __s)
1183#if __cplusplus >= 201103L
1185 template <
class _CharT,
class _Traits,
class _Allocator>
1189 noexcept(
noexcept(__x.swap(__y)))
1193 template <
class _CharT,
class _Traits,
class _Allocator>
1200 template <
class _CharT,
class _Traits,
class _Allocator>
1207 template <
class _CharT,
class _Traits,
class _Allocator>
1214_GLIBCXX_END_NAMESPACE_CXX11
1215_GLIBCXX_END_NAMESPACE_VERSION
1218#undef _GLIBCXX_LVAL_REF_QUAL
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
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 auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
constexpr auto data(_Container &__cont) noexcept(noexcept(__cont.data())) -> decltype(__cont.data())
Return the data pointer of a container.
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).
char_type * pptr() const
Access to the put area.
void setg(char_type *__gbeg, char_type *__gnext, char_type *__gend)
Setting the three read area pointers.
char_type * eback() const
Access to the get area.
char_type * egptr() const
Access to the get area.
char_type * gptr() const
Access to the get area.
locale pubimbue(const locale &__loc)
Entry point for imbue().
char_type * pbase() const
Access to the put area.
Template class basic_istream.
Template class basic_ostream.
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 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.
virtual __streambuf_type * setbuf(char_type *__s, streamsize __n)
Manipulates the buffer.
ios_base::openmode _M_mode
Place to stash in || out || in | out settings for current stringbuf.
Controlling input for std::string.
void str(const __string_type &__s)
Setting a new buffer.
__stringbuf_type * rdbuf() const
Accessing the underlying 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.
~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.
__stringbuf_type * rdbuf() const
Accessing the underlying buffer.
basic_stringstream(ios_base::openmode __m)
Starts with an empty string buffer.
Uniform interface to all allocator types.
typename __detected_or_t< is_empty< _Alloc >, __equal, _Alloc >::type is_always_equal
Whether all instances of the allocator type compare equal.
__detected_or_t< false_type, __pocs, _Alloc > propagate_on_container_swap
How the allocator is propagated on swap.
const _CharT * data() const noexcept
Return const pointer to contents.
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.
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.
_Ios_Openmode openmode
This is a bitmask type.
static const openmode app
Seek to end before each write.
static const openmode ate
Open and seek to end immediately after opening.