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 &
46# define _GLIBCXX_SSTREAM_ALWAYS_INLINE
48# define _GLIBCXX_LVAL_REF_QUAL
50# define _GLIBCXX_SSTREAM_ALWAYS_INLINE [[__gnu__::__always_inline__]]
55namespace std _GLIBCXX_VISIBILITY(default)
57_GLIBCXX_BEGIN_NAMESPACE_VERSION
58_GLIBCXX_BEGIN_NAMESPACE_CXX11
78 template<
typename _CharT,
typename _Traits,
typename _Alloc>
81 struct __xfer_bufptrs;
83#if __cplusplus >= 201103L
92 typedef _CharT char_type;
93 typedef _Traits traits_type;
96 typedef _Alloc allocator_type;
97 typedef typename traits_type::int_type int_type;
98 typedef typename traits_type::pos_type pos_type;
99 typedef typename traits_type::off_type off_type;
103 typedef typename __string_type::size_type __size_type;
149 _M_string(__str.
data(), __str.
size(), __str.get_allocator())
150 { _M_stringbuf_init(__mode); }
152#if __cplusplus >= 201103L
157 { __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0); }
159#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
166 const allocator_type& __a)
167 : __streambuf_type(),
_M_mode(__mode), _M_string(__a)
175 { _M_stringbuf_init(__mode); }
177 template<
typename _SAlloc>
179 const allocator_type& __a)
183 template<
typename _SAlloc>
186 const allocator_type& __a)
187 : __streambuf_type(),
_M_mode(__mode),
188 _M_string(__s.
data(), __s.
size(), __a)
189 { _M_stringbuf_init(__mode); }
191 template<
typename _SAlloc>
201 { __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0); }
203 allocator_type get_allocator() const noexcept
215 __xfer_bufptrs __st{__rhs,
this};
216 const __streambuf_type&
__base = __rhs;
217 __streambuf_type::operator=(__base);
221 __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0);
229 __xfer_bufptrs __r_st{__rhs,
this};
230 __streambuf_type&
__base = __rhs;
231 __streambuf_type::swap(__base);
232 __rhs.pubimbue(this->
pubimbue(__rhs.getloc()));
233 std::swap(
_M_mode, __rhs._M_mode);
234 std::swap(_M_string, __rhs._M_string);
249 str() const _GLIBCXX_LVAL_REF_QUAL
252 if (char_type* __hi = _M_high_mark())
259#if __cplusplus > 201703L
260#if _GLIBCXX_USE_CXX11_ABI
262 template<__allocator_like _SAlloc>
264 str(
const _SAlloc& __sa)
const
267 return { __sv.data(), __sv.size(), __sa };
274 if (char_type* __hi = _M_high_mark())
277 _M_string._M_set_length(_M_high_mark() - this->
pbase());
281 _M_sync(_M_string.
data(), 0, 0);
286 _GLIBCXX_SSTREAM_ALWAYS_INLINE
287 basic_string_view<char_type, traits_type>
288 view() const noexcept
290 if (char_type* __hi = _M_high_mark())
291 return { this->
pbase(), __hi };
313#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
315 template<__allocator_like _SAlloc>
316 requires (!is_same_v<_SAlloc, _Alloc>)
326 str(__string_type&& __s)
339 __size_type __len = 0;
341 __len = _M_string.
size();
342 _M_sync(
const_cast<char_type*
>(_M_string.
data()), 0, __len);
361 pbackfail(int_type __c = traits_type::eof());
364 overflow(int_type __c = traits_type::eof());
377 virtual __streambuf_type*
391 _M_sync(__s, __n, 0);
397 seekoff(off_type __off, ios_base::seekdir __way,
408 _M_sync(char_type* __base, __size_type __i, __size_type __o);
415 if (char_type* __pptr = this->
pptr())
417 char_type* __egptr = this->
egptr();
418 if (!__egptr || __pptr > __egptr)
423 this->
setg(__pptr, __pptr, __pptr);
431 _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off);
438 __attribute__((__always_inline__))
440 _M_high_mark() const _GLIBCXX_NOEXCEPT
442 if (char_type* __pptr = this->
pptr())
444 char_type* __egptr = this->
egptr();
445 if (!__egptr || __pptr > __egptr)
453#if __cplusplus >= 201103L
454#if _GLIBCXX_USE_CXX11_ABI
457 struct __xfer_bufptrs
460 : _M_to{__to}, _M_goff{-1, -1, -1}, _M_poff{-1, -1, -1}
462 const _CharT*
const __str = __from._M_string.data();
463 const _CharT* __end =
nullptr;
466 _M_goff[0] = __from.eback() - __str;
467 _M_goff[1] = __from.gptr() - __str;
468 _M_goff[2] = __from.egptr() - __str;
469 __end = __from.egptr();
473 _M_poff[0] = __from.pbase() - __str;
474 _M_poff[1] = __from.pptr() - __from.pbase();
475 _M_poff[2] = __from.epptr() - __str;
476 if (!__end || __from.pptr() > __end)
477 __end = __from.pptr();
486 __mut_from._M_string._M_length(__end - __str);
492 char_type* __str =
const_cast<char_type*
>(_M_to->_M_string.data());
493 if (_M_goff[0] != -1)
494 _M_to->setg(__str+_M_goff[0], __str+_M_goff[1], __str+_M_goff[2]);
495 if (_M_poff[0] != -1)
496 _M_to->_M_pbump(__str+_M_poff[0], __str+_M_poff[2], _M_poff[1]);
505 struct __xfer_bufptrs
514 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
518#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
523 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
546 template<
typename _CharT,
typename _Traits,
typename _Alloc>
551 typedef _CharT char_type;
552 typedef _Traits traits_type;
555 typedef _Alloc allocator_type;
556 typedef typename traits_type::int_type int_type;
557 typedef typename traits_type::pos_type pos_type;
558 typedef typename traits_type::off_type off_type;
566 __stringbuf_type _M_stringbuf;
582 { this->
init(&_M_stringbuf); }
599 { this->
init(&_M_stringbuf); }
618 { this->
init(&_M_stringbuf); }
629#if __cplusplus >= 201103L
633 : __istream_type(
std::move(__rhs)),
634 _M_stringbuf(
std::move(__rhs._M_stringbuf))
635 { __istream_type::set_rdbuf(&_M_stringbuf); }
637#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
639 : __istream_type(), _M_stringbuf(__mode | ios_base::
in, __a)
645 : __istream_type(), _M_stringbuf(
std::move(__str), __mode | ios_base::
in)
648 template<
typename _SAlloc>
650 const allocator_type& __a)
654 template<
typename _SAlloc>
657 const allocator_type& __a)
658 : __istream_type(), _M_stringbuf(__str, __mode | ios_base::
in, __a)
661 template<
typename _SAlloc>
677 __istream_type::operator=(
std::move(__rhs));
678 _M_stringbuf =
std::move(__rhs._M_stringbuf);
685 __istream_type::swap(__rhs);
686 _M_stringbuf.swap(__rhs._M_stringbuf);
699 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
706 str() const _GLIBCXX_LVAL_REF_QUAL
707 {
return _M_stringbuf.str(); }
709#if __cplusplus > 201703L
710#if _GLIBCXX_USE_CXX11_ABI
712 template<__allocator_like _SAlloc>
714 str(
const _SAlloc& __sa)
const
715 {
return _M_stringbuf.str(__sa); }
720 {
return std::move(_M_stringbuf).str(); }
723 _GLIBCXX_SSTREAM_ALWAYS_INLINE
724 basic_string_view<char_type, traits_type>
725 view() const noexcept
726 {
return _M_stringbuf.view(); }
737 { _M_stringbuf.str(__s); }
739#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
741 template<__allocator_like _SAlloc>
742 requires (!is_same_v<_SAlloc, _Alloc>)
745 { _M_stringbuf.str(__s); }
749 str(__string_type&& __s)
770 template <
typename _CharT,
typename _Traits,
typename _Alloc>
775 typedef _CharT char_type;
776 typedef _Traits traits_type;
779 typedef _Alloc allocator_type;
780 typedef typename traits_type::int_type int_type;
781 typedef typename traits_type::pos_type pos_type;
782 typedef typename traits_type::off_type off_type;
790 __stringbuf_type _M_stringbuf;
806 { this->
init(&_M_stringbuf); }
823 { this->
init(&_M_stringbuf); }
842 { this->
init(&_M_stringbuf); }
853#if __cplusplus >= 201103L
857 : __ostream_type(
std::move(__rhs)),
858 _M_stringbuf(
std::move(__rhs._M_stringbuf))
859 { __ostream_type::set_rdbuf(&_M_stringbuf); }
861#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
863 : __ostream_type(), _M_stringbuf(__mode | ios_base::
out, __a)
869 : __ostream_type(), _M_stringbuf(
std::move(__str), __mode | ios_base::
out)
872 template<
typename _SAlloc>
874 const allocator_type& __a)
878 template<
typename _SAlloc>
881 const allocator_type& __a)
882 : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::
out, __a)
885 template<
typename _SAlloc>
901 __ostream_type::operator=(
std::move(__rhs));
902 _M_stringbuf =
std::move(__rhs._M_stringbuf);
909 __ostream_type::swap(__rhs);
910 _M_stringbuf.swap(__rhs._M_stringbuf);
923 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
930 str() const _GLIBCXX_LVAL_REF_QUAL
931 {
return _M_stringbuf.str(); }
933#if __cplusplus > 201703L
934#if _GLIBCXX_USE_CXX11_ABI
936 template<__allocator_like _SAlloc>
938 str(
const _SAlloc& __sa)
const
939 {
return _M_stringbuf.str(__sa); }
944 {
return std::move(_M_stringbuf).str(); }
947 _GLIBCXX_SSTREAM_ALWAYS_INLINE
948 basic_string_view<char_type, traits_type>
949 view() const noexcept
950 {
return _M_stringbuf.view(); }
961 { _M_stringbuf.str(__s); }
963#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
965 template<__allocator_like _SAlloc>
966 requires (!is_same_v<_SAlloc, _Alloc>)
969 { _M_stringbuf.str(__s); }
973 str(__string_type&& __s)
994 template <
typename _CharT,
typename _Traits,
typename _Alloc>
999 typedef _CharT char_type;
1000 typedef _Traits traits_type;
1003 typedef _Alloc allocator_type;
1004 typedef typename traits_type::int_type int_type;
1005 typedef typename traits_type::pos_type pos_type;
1006 typedef typename traits_type::off_type off_type;
1014 __stringbuf_type _M_stringbuf;
1030 { this->
init(&_M_stringbuf); }
1045 { this->
init(&_M_stringbuf); }
1062 { this->
init(&_M_stringbuf); }
1073#if __cplusplus >= 201103L
1077 : __iostream_type(
std::
move(__rhs)),
1078 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
1079 { __iostream_type::set_rdbuf(&_M_stringbuf); }
1081#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1083 : __iostream_type(), _M_stringbuf(__mode, __a)
1084 { this->
init(&_M_stringbuf); }
1090 : __iostream_type(), _M_stringbuf(
std::
move(__str), __mode)
1093 template<
typename _SAlloc>
1095 const allocator_type& __a)
1099 template<
typename _SAlloc>
1102 const allocator_type& __a)
1103 : __iostream_type(), _M_stringbuf(__str, __mode, __a)
1106 template<
typename _SAlloc>
1123 __iostream_type::operator=(
std::move(__rhs));
1124 _M_stringbuf =
std::move(__rhs._M_stringbuf);
1131 __iostream_type::swap(__rhs);
1132 _M_stringbuf.swap(__rhs._M_stringbuf);
1145 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
1152 str() const _GLIBCXX_LVAL_REF_QUAL
1153 {
return _M_stringbuf.str(); }
1155#if __cplusplus > 201703L
1156#if _GLIBCXX_USE_CXX11_ABI
1158 template<__allocator_like _SAlloc>
1160 str(
const _SAlloc& __sa)
const
1161 {
return _M_stringbuf.str(__sa); }
1166 {
return std::move(_M_stringbuf).str(); }
1169 _GLIBCXX_SSTREAM_ALWAYS_INLINE
1170 basic_string_view<char_type, traits_type>
1171 view() const noexcept
1172 {
return _M_stringbuf.view(); }
1183 { _M_stringbuf.str(__s); }
1185#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1187 template<__allocator_like _SAlloc>
1188 requires (!is_same_v<_SAlloc, _Alloc>)
1191 { _M_stringbuf.str(__s); }
1195 str(__string_type&& __s)
1200#if __cplusplus >= 201103L
1202 template <
class _CharT,
class _Traits,
class _Allocator>
1206 noexcept(
noexcept(__x.swap(__y)))
1210 template <
class _CharT,
class _Traits,
class _Allocator>
1217 template <
class _CharT,
class _Traits,
class _Allocator>
1224 template <
class _CharT,
class _Traits,
class _Allocator>
1231_GLIBCXX_END_NAMESPACE_CXX11
1232_GLIBCXX_END_NAMESPACE_VERSION
1235#undef _GLIBCXX_SSTREAM_ALWAYS_INLINE
1236#undef _GLIBCXX_LVAL_REF_QUAL
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
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.