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 &
45# define _GLIBCXX_LVAL_REF_QUAL
48namespace std _GLIBCXX_VISIBILITY(default)
50_GLIBCXX_BEGIN_NAMESPACE_VERSION
51_GLIBCXX_BEGIN_NAMESPACE_CXX11
71 template<
typename _CharT,
typename _Traits,
typename _Alloc>
74 struct __xfer_bufptrs;
76#if __cplusplus >= 201103L
85 typedef _CharT char_type;
86 typedef _Traits traits_type;
89 typedef _Alloc allocator_type;
90 typedef typename traits_type::int_type int_type;
91 typedef typename traits_type::pos_type pos_type;
92 typedef typename traits_type::off_type off_type;
96 typedef typename __string_type::size_type __size_type;
142 _M_string(__str.
data(), __str.
size(), __str.get_allocator())
143 { _M_stringbuf_init(__mode); }
145#if __cplusplus >= 201103L
150 { __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0); }
152#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
159 const allocator_type& __a)
160 : __streambuf_type(),
_M_mode(__mode), _M_string(__a)
168 { _M_stringbuf_init(__mode); }
170 template<
typename _SAlloc>
172 const allocator_type& __a)
176 template<
typename _SAlloc>
179 const allocator_type& __a)
180 : __streambuf_type(),
_M_mode(__mode),
181 _M_string(__s.
data(), __s.
size(), __a)
182 { _M_stringbuf_init(__mode); }
184 template<
typename _SAlloc>
194 { __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0); }
196 allocator_type get_allocator() const noexcept
208 __xfer_bufptrs __st{__rhs,
this};
209 const __streambuf_type&
__base = __rhs;
210 __streambuf_type::operator=(__base);
214 __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0);
222 __xfer_bufptrs __r_st{__rhs,
this};
223 __streambuf_type&
__base = __rhs;
224 __streambuf_type::swap(__base);
225 __rhs.pubimbue(this->
pubimbue(__rhs.getloc()));
242 str() const _GLIBCXX_LVAL_REF_QUAL
245 if (char_type* __hi = _M_high_mark())
252#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
254 template<__allocator_like _SAlloc>
256 str(
const _SAlloc& __sa)
const
259 return { __sv.data(), __sv.size(), __sa };
266 if (char_type* __hi = _M_high_mark())
269 _M_string._M_set_length(_M_high_mark() - this->
pbase());
273 _M_sync(_M_string.
data(), 0, 0);
277 basic_string_view<char_type, traits_type>
278 view() const noexcept
280 if (char_type* __hi = _M_high_mark())
281 return { this->
pbase(), __hi };
303#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
305 template<__allocator_like _SAlloc>
306 requires (!is_same_v<_SAlloc, _Alloc>)
316 str(__string_type&& __s)
329 __size_type __len = 0;
331 __len = _M_string.
size();
332 _M_sync(
const_cast<char_type*
>(_M_string.
data()), 0, __len);
351 pbackfail(int_type __c = traits_type::eof());
354 overflow(int_type __c = traits_type::eof());
367 virtual __streambuf_type*
381 _M_sync(__s, __n, 0);
387 seekoff(off_type __off, ios_base::seekdir __way,
398 _M_sync(char_type* __base, __size_type __i, __size_type __o);
405 if (char_type* __pptr = this->
pptr())
407 char_type* __egptr = this->
egptr();
408 if (!__egptr || __pptr > __egptr)
413 this->
setg(__pptr, __pptr, __pptr);
421 _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off);
428 __attribute__((__always_inline__))
430 _M_high_mark() const _GLIBCXX_NOEXCEPT
432 if (char_type* __pptr = this->
pptr())
434 char_type* __egptr = this->
egptr();
435 if (!__egptr || __pptr > __egptr)
443#if __cplusplus >= 201103L
444#if _GLIBCXX_USE_CXX11_ABI
447 struct __xfer_bufptrs
450 : _M_to{__to}, _M_goff{-1, -1, -1}, _M_poff{-1, -1, -1}
452 const _CharT*
const __str = __from._M_string.data();
453 const _CharT* __end =
nullptr;
456 _M_goff[0] = __from.eback() - __str;
457 _M_goff[1] = __from.gptr() - __str;
458 _M_goff[2] = __from.egptr() - __str;
459 __end = __from.egptr();
463 _M_poff[0] = __from.pbase() - __str;
464 _M_poff[1] = __from.pptr() - __from.pbase();
465 _M_poff[2] = __from.epptr() - __str;
466 if (!__end || __from.pptr() > __end)
467 __end = __from.pptr();
476 __mut_from._M_string._M_length(__end - __str);
482 char_type* __str =
const_cast<char_type*
>(_M_to->_M_string.data());
483 if (_M_goff[0] != -1)
484 _M_to->setg(__str+_M_goff[0], __str+_M_goff[1], __str+_M_goff[2]);
485 if (_M_poff[0] != -1)
486 _M_to->_M_pbump(__str+_M_poff[0], __str+_M_poff[2], _M_poff[1]);
495 struct __xfer_bufptrs
504 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
508#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
513 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
536 template<
typename _CharT,
typename _Traits,
typename _Alloc>
541 typedef _CharT char_type;
542 typedef _Traits traits_type;
545 typedef _Alloc allocator_type;
546 typedef typename traits_type::int_type int_type;
547 typedef typename traits_type::pos_type pos_type;
548 typedef typename traits_type::off_type off_type;
556 __stringbuf_type _M_stringbuf;
572 { this->
init(&_M_stringbuf); }
589 { this->
init(&_M_stringbuf); }
608 { this->
init(&_M_stringbuf); }
619#if __cplusplus >= 201103L
623 : __istream_type(
std::move(__rhs)),
624 _M_stringbuf(
std::move(__rhs._M_stringbuf))
625 { __istream_type::set_rdbuf(&_M_stringbuf); }
627#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
629 : __istream_type(), _M_stringbuf(__mode | ios_base::
in, __a)
635 : __istream_type(), _M_stringbuf(
std::move(__str), __mode | ios_base::
in)
638 template<
typename _SAlloc>
640 const allocator_type& __a)
644 template<
typename _SAlloc>
647 const allocator_type& __a)
648 : __istream_type(), _M_stringbuf(__str, __mode | ios_base::
in, __a)
651 template<
typename _SAlloc>
667 __istream_type::operator=(
std::move(__rhs));
668 _M_stringbuf =
std::move(__rhs._M_stringbuf);
675 __istream_type::swap(__rhs);
676 _M_stringbuf.swap(__rhs._M_stringbuf);
689 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
696 str() const _GLIBCXX_LVAL_REF_QUAL
697 {
return _M_stringbuf.str(); }
699#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
701 template<__allocator_like _SAlloc>
703 str(
const _SAlloc& __sa)
const
704 {
return _M_stringbuf.str(__sa); }
709 {
return std::move(_M_stringbuf).str(); }
711 basic_string_view<char_type, traits_type>
712 view() const noexcept
713 {
return _M_stringbuf.view(); }
724 { _M_stringbuf.str(__s); }
726#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
728 template<__allocator_like _SAlloc>
729 requires (!is_same_v<_SAlloc, _Alloc>)
732 { _M_stringbuf.str(__s); }
736 str(__string_type&& __s)
757 template <
typename _CharT,
typename _Traits,
typename _Alloc>
762 typedef _CharT char_type;
763 typedef _Traits traits_type;
766 typedef _Alloc allocator_type;
767 typedef typename traits_type::int_type int_type;
768 typedef typename traits_type::pos_type pos_type;
769 typedef typename traits_type::off_type off_type;
777 __stringbuf_type _M_stringbuf;
793 { this->
init(&_M_stringbuf); }
810 { this->
init(&_M_stringbuf); }
829 { this->
init(&_M_stringbuf); }
840#if __cplusplus >= 201103L
844 : __ostream_type(
std::move(__rhs)),
845 _M_stringbuf(
std::move(__rhs._M_stringbuf))
846 { __ostream_type::set_rdbuf(&_M_stringbuf); }
848#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
850 : __ostream_type(), _M_stringbuf(__mode | ios_base::
out, __a)
856 : __ostream_type(), _M_stringbuf(
std::move(__str), __mode | ios_base::
out)
859 template<
typename _SAlloc>
861 const allocator_type& __a)
865 template<
typename _SAlloc>
868 const allocator_type& __a)
869 : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::
out, __a)
872 template<
typename _SAlloc>
888 __ostream_type::operator=(
std::move(__rhs));
889 _M_stringbuf =
std::move(__rhs._M_stringbuf);
896 __ostream_type::swap(__rhs);
897 _M_stringbuf.swap(__rhs._M_stringbuf);
910 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
917 str() const _GLIBCXX_LVAL_REF_QUAL
918 {
return _M_stringbuf.str(); }
920#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
922 template<__allocator_like _SAlloc>
924 str(
const _SAlloc& __sa)
const
925 {
return _M_stringbuf.str(__sa); }
930 {
return std::move(_M_stringbuf).str(); }
932 basic_string_view<char_type, traits_type>
933 view() const noexcept
934 {
return _M_stringbuf.view(); }
945 { _M_stringbuf.str(__s); }
947#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
949 template<__allocator_like _SAlloc>
950 requires (!is_same_v<_SAlloc, _Alloc>)
953 { _M_stringbuf.str(__s); }
957 str(__string_type&& __s)
978 template <
typename _CharT,
typename _Traits,
typename _Alloc>
983 typedef _CharT char_type;
984 typedef _Traits traits_type;
987 typedef _Alloc allocator_type;
988 typedef typename traits_type::int_type int_type;
989 typedef typename traits_type::pos_type pos_type;
990 typedef typename traits_type::off_type off_type;
998 __stringbuf_type _M_stringbuf;
1014 { this->
init(&_M_stringbuf); }
1029 { this->
init(&_M_stringbuf); }
1046 { this->
init(&_M_stringbuf); }
1057#if __cplusplus >= 201103L
1061 : __iostream_type(
std::
move(__rhs)),
1062 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
1063 { __iostream_type::set_rdbuf(&_M_stringbuf); }
1065#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1067 : __iostream_type(), _M_stringbuf(__mode, __a)
1068 { this->
init(&_M_stringbuf); }
1074 : __iostream_type(), _M_stringbuf(
std::
move(__str), __mode)
1077 template<
typename _SAlloc>
1079 const allocator_type& __a)
1083 template<
typename _SAlloc>
1086 const allocator_type& __a)
1087 : __iostream_type(), _M_stringbuf(__str, __mode, __a)
1090 template<
typename _SAlloc>
1107 __iostream_type::operator=(
std::move(__rhs));
1108 _M_stringbuf =
std::move(__rhs._M_stringbuf);
1115 __iostream_type::swap(__rhs);
1116 _M_stringbuf.swap(__rhs._M_stringbuf);
1129 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
1136 str() const _GLIBCXX_LVAL_REF_QUAL
1137 {
return _M_stringbuf.str(); }
1139#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1141 template<__allocator_like _SAlloc>
1143 str(
const _SAlloc& __sa)
const
1144 {
return _M_stringbuf.str(__sa); }
1149 {
return std::move(_M_stringbuf).str(); }
1151 basic_string_view<char_type, traits_type>
1152 view() const noexcept
1153 {
return _M_stringbuf.view(); }
1164 { _M_stringbuf.str(__s); }
1166#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1168 template<__allocator_like _SAlloc>
1169 requires (!is_same_v<_SAlloc, _Alloc>)
1172 { _M_stringbuf.str(__s); }
1176 str(__string_type&& __s)
1181#if __cplusplus >= 201103L
1183 template <
class _CharT,
class _Traits,
class _Allocator>
1187 noexcept(
noexcept(__x.swap(__y)))
1191 template <
class _CharT,
class _Traits,
class _Allocator>
1198 template <
class _CharT,
class _Traits,
class _Allocator>
1205 template <
class _CharT,
class _Traits,
class _Allocator>
1212_GLIBCXX_END_NAMESPACE_CXX11
1213_GLIBCXX_END_NAMESPACE_VERSION
1216#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.
__detected_or_t< false_type, __pocs, _Alloc > propagate_on_container_swap
How the allocator is propagated on swap.
__detected_or_t< typename is_empty< _Alloc >::type, __equal, _Alloc > is_always_equal
Whether all instances of the allocator type compare equal.
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.