33#ifndef _GLIBCXX_SSTREAM
34#define _GLIBCXX_SSTREAM 1
36#pragma GCC system_header
42#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
43# define _GLIBCXX_LVAL_REF_QUAL &
44# define _GLIBCXX_SSTREAM_ALWAYS_INLINE
46# define _GLIBCXX_LVAL_REF_QUAL
48# define _GLIBCXX_SSTREAM_ALWAYS_INLINE [[__gnu__::__always_inline__]]
53namespace std _GLIBCXX_VISIBILITY(default)
55_GLIBCXX_BEGIN_NAMESPACE_VERSION
56_GLIBCXX_BEGIN_NAMESPACE_CXX11
76 template<
typename _CharT,
typename _Traits,
typename _Alloc>
79 struct __xfer_bufptrs;
81#if __cplusplus >= 201103L
90 typedef _CharT char_type;
91 typedef _Traits traits_type;
94 typedef _Alloc allocator_type;
95 typedef typename traits_type::int_type int_type;
96 typedef typename traits_type::pos_type pos_type;
97 typedef typename traits_type::off_type off_type;
101 typedef typename __string_type::size_type __size_type;
147 _M_string(__str.
data(), __str.
size(), __str.get_allocator())
148 { _M_stringbuf_init(__mode); }
150#if __cplusplus >= 201103L
155 { __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0); }
157#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
164 const allocator_type& __a)
165 : __streambuf_type(),
_M_mode(__mode), _M_string(__a)
173 { _M_stringbuf_init(__mode); }
175 template<
typename _SAlloc>
177 const allocator_type& __a)
181 template<
typename _SAlloc>
184 const allocator_type& __a)
185 : __streambuf_type(),
_M_mode(__mode),
186 _M_string(__s.
data(), __s.
size(), __a)
187 { _M_stringbuf_init(__mode); }
189 template<
typename _SAlloc>
199 { __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0); }
201 allocator_type get_allocator() const noexcept
213 __xfer_bufptrs __st{__rhs,
this};
214 const __streambuf_type&
__base = __rhs;
215 __streambuf_type::operator=(__base);
219 __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0);
227 __xfer_bufptrs __r_st{__rhs,
this};
228 __streambuf_type&
__base = __rhs;
229 __streambuf_type::swap(__base);
230 __rhs.pubimbue(this->
pubimbue(__rhs.getloc()));
247 str() const _GLIBCXX_LVAL_REF_QUAL
250 if (char_type* __hi = _M_high_mark())
257#if __cplusplus > 201703L
258#if _GLIBCXX_USE_CXX11_ABI
260 template<__allocator_like _SAlloc>
262 str(
const _SAlloc& __sa)
const
265 return { __sv.data(), __sv.size(), __sa };
272 if (char_type* __hi = _M_high_mark())
275 _M_string._M_set_length(_M_high_mark() - this->
pbase());
279 _M_sync(_M_string.
data(), 0, 0);
284 _GLIBCXX_SSTREAM_ALWAYS_INLINE
285 basic_string_view<char_type, traits_type>
286 view() const noexcept
288 if (char_type* __hi = _M_high_mark())
289 return { this->
pbase(), __hi };
311#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
313 template<__allocator_like _SAlloc>
314 requires (!is_same_v<_SAlloc, _Alloc>)
324 str(__string_type&& __s)
337 __size_type __len = 0;
339 __len = _M_string.
size();
340 _M_sync(
const_cast<char_type*
>(_M_string.
data()), 0, __len);
359 pbackfail(int_type __c = traits_type::eof());
362 overflow(int_type __c = traits_type::eof());
375 virtual __streambuf_type*
389 _M_sync(__s, __n, 0);
395 seekoff(off_type __off, ios_base::seekdir __way,
406 _M_sync(char_type* __base, __size_type __i, __size_type __o);
413 if (char_type* __pptr = this->
pptr())
415 char_type* __egptr = this->
egptr();
416 if (!__egptr || __pptr > __egptr)
421 this->
setg(__pptr, __pptr, __pptr);
429 _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off);
436 __attribute__((__always_inline__))
438 _M_high_mark() const _GLIBCXX_NOEXCEPT
440 if (char_type* __pptr = this->
pptr())
442 char_type* __egptr = this->
egptr();
443 if (!__egptr || __pptr > __egptr)
451#if __cplusplus >= 201103L
452#if _GLIBCXX_USE_CXX11_ABI
455 struct __xfer_bufptrs
458 : _M_to{__to}, _M_goff{-1, -1, -1}, _M_poff{-1, -1, -1}
460 const _CharT*
const __str = __from._M_string.data();
461 const _CharT* __end =
nullptr;
464 _M_goff[0] = __from.eback() - __str;
465 _M_goff[1] = __from.gptr() - __str;
466 _M_goff[2] = __from.egptr() - __str;
467 __end = __from.egptr();
471 _M_poff[0] = __from.pbase() - __str;
472 _M_poff[1] = __from.pptr() - __from.pbase();
473 _M_poff[2] = __from.epptr() - __str;
474 if (!__end || __from.pptr() > __end)
475 __end = __from.pptr();
484 __mut_from._M_string._M_length(__end - __str);
490 char_type* __str =
const_cast<char_type*
>(_M_to->_M_string.data());
491 if (_M_goff[0] != -1)
492 _M_to->setg(__str+_M_goff[0], __str+_M_goff[1], __str+_M_goff[2]);
493 if (_M_poff[0] != -1)
494 _M_to->_M_pbump(__str+_M_poff[0], __str+_M_poff[2], _M_poff[1]);
503 struct __xfer_bufptrs
512 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
516#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
521 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
544 template<
typename _CharT,
typename _Traits,
typename _Alloc>
549 typedef _CharT char_type;
550 typedef _Traits traits_type;
553 typedef _Alloc allocator_type;
554 typedef typename traits_type::int_type int_type;
555 typedef typename traits_type::pos_type pos_type;
556 typedef typename traits_type::off_type off_type;
564 __stringbuf_type _M_stringbuf;
580 { this->
init(&_M_stringbuf); }
597 { this->
init(&_M_stringbuf); }
616 { this->
init(&_M_stringbuf); }
627#if __cplusplus >= 201103L
631 : __istream_type(
std::move(__rhs)),
632 _M_stringbuf(
std::move(__rhs._M_stringbuf))
633 { __istream_type::set_rdbuf(&_M_stringbuf); }
635#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
637 : __istream_type(), _M_stringbuf(__mode | ios_base::
in, __a)
643 : __istream_type(), _M_stringbuf(
std::move(__str), __mode | ios_base::
in)
646 template<
typename _SAlloc>
648 const allocator_type& __a)
652 template<
typename _SAlloc>
655 const allocator_type& __a)
656 : __istream_type(), _M_stringbuf(__str, __mode | ios_base::
in, __a)
659 template<
typename _SAlloc>
675 __istream_type::operator=(
std::move(__rhs));
676 _M_stringbuf =
std::move(__rhs._M_stringbuf);
683 __istream_type::swap(__rhs);
684 _M_stringbuf.swap(__rhs._M_stringbuf);
697 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
704 str() const _GLIBCXX_LVAL_REF_QUAL
705 {
return _M_stringbuf.str(); }
707#if __cplusplus > 201703L
708#if _GLIBCXX_USE_CXX11_ABI
710 template<__allocator_like _SAlloc>
712 str(
const _SAlloc& __sa)
const
713 {
return _M_stringbuf.str(__sa); }
718 {
return std::move(_M_stringbuf).str(); }
721 _GLIBCXX_SSTREAM_ALWAYS_INLINE
722 basic_string_view<char_type, traits_type>
723 view() const noexcept
724 {
return _M_stringbuf.view(); }
734 str(
const __string_type& __s)
735 { _M_stringbuf.str(__s); }
737#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
739 template<__allocator_like _SAlloc>
740 requires (!is_same_v<_SAlloc, _Alloc>)
743 { _M_stringbuf.str(__s); }
747 str(__string_type&& __s)
768 template <
typename _CharT,
typename _Traits,
typename _Alloc>
773 typedef _CharT char_type;
774 typedef _Traits traits_type;
777 typedef _Alloc allocator_type;
778 typedef typename traits_type::int_type int_type;
779 typedef typename traits_type::pos_type pos_type;
780 typedef typename traits_type::off_type off_type;
788 __stringbuf_type _M_stringbuf;
804 { this->
init(&_M_stringbuf); }
821 { this->
init(&_M_stringbuf); }
840 { this->
init(&_M_stringbuf); }
851#if __cplusplus >= 201103L
855 : __ostream_type(
std::move(__rhs)),
856 _M_stringbuf(
std::move(__rhs._M_stringbuf))
857 { __ostream_type::set_rdbuf(&_M_stringbuf); }
859#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
861 : __ostream_type(), _M_stringbuf(__mode | ios_base::
out, __a)
867 : __ostream_type(), _M_stringbuf(
std::move(__str), __mode | ios_base::
out)
870 template<
typename _SAlloc>
872 const allocator_type& __a)
876 template<
typename _SAlloc>
879 const allocator_type& __a)
880 : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::
out, __a)
883 template<
typename _SAlloc>
899 __ostream_type::operator=(
std::move(__rhs));
900 _M_stringbuf =
std::move(__rhs._M_stringbuf);
907 __ostream_type::swap(__rhs);
908 _M_stringbuf.swap(__rhs._M_stringbuf);
921 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
928 str() const _GLIBCXX_LVAL_REF_QUAL
929 {
return _M_stringbuf.str(); }
931#if __cplusplus > 201703L
932#if _GLIBCXX_USE_CXX11_ABI
934 template<__allocator_like _SAlloc>
936 str(
const _SAlloc& __sa)
const
937 {
return _M_stringbuf.str(__sa); }
942 {
return std::move(_M_stringbuf).str(); }
945 _GLIBCXX_SSTREAM_ALWAYS_INLINE
946 basic_string_view<char_type, traits_type>
947 view() const noexcept
948 {
return _M_stringbuf.view(); }
958 str(
const __string_type& __s)
959 { _M_stringbuf.str(__s); }
961#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
963 template<__allocator_like _SAlloc>
964 requires (!is_same_v<_SAlloc, _Alloc>)
967 { _M_stringbuf.str(__s); }
971 str(__string_type&& __s)
992 template <
typename _CharT,
typename _Traits,
typename _Alloc>
997 typedef _CharT char_type;
998 typedef _Traits traits_type;
1001 typedef _Alloc allocator_type;
1002 typedef typename traits_type::int_type int_type;
1003 typedef typename traits_type::pos_type pos_type;
1004 typedef typename traits_type::off_type off_type;
1012 __stringbuf_type _M_stringbuf;
1028 { this->
init(&_M_stringbuf); }
1042 : __iostream_type(), _M_stringbuf(__m)
1043 { this->
init(&_M_stringbuf); }
1059 : __iostream_type(), _M_stringbuf(__str, __m)
1060 { this->
init(&_M_stringbuf); }
1071#if __cplusplus >= 201103L
1075 : __iostream_type(
std::
move(__rhs)),
1076 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
1077 { __iostream_type::set_rdbuf(&_M_stringbuf); }
1079#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1081 : __iostream_type(), _M_stringbuf(__mode, __a)
1082 { this->
init(&_M_stringbuf); }
1088 : __iostream_type(), _M_stringbuf(
std::
move(__str), __mode)
1091 template<
typename _SAlloc>
1093 const allocator_type& __a)
1097 template<
typename _SAlloc>
1100 const allocator_type& __a)
1101 : __iostream_type(), _M_stringbuf(__str, __mode, __a)
1104 template<
typename _SAlloc>
1121 __iostream_type::operator=(
std::move(__rhs));
1122 _M_stringbuf =
std::move(__rhs._M_stringbuf);
1129 __iostream_type::swap(__rhs);
1130 _M_stringbuf.swap(__rhs._M_stringbuf);
1143 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
1150 str() const _GLIBCXX_LVAL_REF_QUAL
1151 {
return _M_stringbuf.str(); }
1153#if __cplusplus > 201703L
1154#if _GLIBCXX_USE_CXX11_ABI
1156 template<__allocator_like _SAlloc>
1158 str(
const _SAlloc& __sa)
const
1159 {
return _M_stringbuf.str(__sa); }
1164 {
return std::move(_M_stringbuf).str(); }
1167 _GLIBCXX_SSTREAM_ALWAYS_INLINE
1168 basic_string_view<char_type, traits_type>
1169 view() const noexcept
1170 {
return _M_stringbuf.view(); }
1181 { _M_stringbuf.str(__s); }
1183#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1185 template<__allocator_like _SAlloc>
1186 requires (!is_same_v<_SAlloc, _Alloc>)
1189 { _M_stringbuf.str(__s); }
1193 str(__string_type&& __s)
1198#if __cplusplus >= 201103L
1200 template <
class _CharT,
class _Traits,
class _Allocator>
1204 noexcept(
noexcept(__x.swap(__y)))
1208 template <
class _CharT,
class _Traits,
class _Allocator>
1215 template <
class _CharT,
class _Traits,
class _Allocator>
1222 template <
class _CharT,
class _Traits,
class _Allocator>
1229_GLIBCXX_END_NAMESPACE_CXX11
1230_GLIBCXX_END_NAMESPACE_VERSION
1233#undef _GLIBCXX_SSTREAM_ALWAYS_INLINE
1234#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.
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.
Managing sequences of characters and character-like objects.
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.