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;
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);
429 _M_high_mark() const _GLIBCXX_NOEXCEPT
431 if (char_type* __pptr = this->
pptr())
433 char_type* __egptr = this->
egptr();
434 if (!__egptr || __pptr > __egptr)
442#if __cplusplus >= 201103L
443#if _GLIBCXX_USE_CXX11_ABI
446 struct __xfer_bufptrs
449 : _M_to{__to}, _M_goff{-1, -1, -1}, _M_poff{-1, -1, -1}
451 const _CharT*
const __str = __from._M_string.data();
452 const _CharT* __end =
nullptr;
455 _M_goff[0] = __from.eback() - __str;
456 _M_goff[1] = __from.gptr() - __str;
457 _M_goff[2] = __from.egptr() - __str;
458 __end = __from.egptr();
462 _M_poff[0] = __from.pbase() - __str;
463 _M_poff[1] = __from.pptr() - __from.pbase();
464 _M_poff[2] = __from.epptr() - __str;
465 if (!__end || __from.pptr() > __end)
466 __end = __from.pptr();
475 __mut_from._M_string._M_length(__end - __str);
481 char_type* __str =
const_cast<char_type*
>(_M_to->_M_string.data());
482 if (_M_goff[0] != -1)
483 _M_to->setg(__str+_M_goff[0], __str+_M_goff[1], __str+_M_goff[2]);
484 if (_M_poff[0] != -1)
485 _M_to->_M_pbump(__str+_M_poff[0], __str+_M_poff[2], _M_poff[1]);
494 struct __xfer_bufptrs
503 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
507#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
512 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
535 template<
typename _CharT,
typename _Traits,
typename _Alloc>
544 typedef _Alloc allocator_type;
545 typedef typename traits_type::int_type
int_type;
546 typedef typename traits_type::pos_type
pos_type;
547 typedef typename traits_type::off_type
off_type;
555 __stringbuf_type _M_stringbuf;
571 { this->
init(&_M_stringbuf); }
588 { this->
init(&_M_stringbuf); }
607 { this->
init(&_M_stringbuf); }
618#if __cplusplus >= 201103L
622 : __istream_type(
std::move(__rhs)),
623 _M_stringbuf(
std::move(__rhs._M_stringbuf))
624 { __istream_type::set_rdbuf(&_M_stringbuf); }
626#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
628 : __istream_type(), _M_stringbuf(__mode | ios_base::
in, __a)
634 : __istream_type(), _M_stringbuf(
std::move(__str), __mode | ios_base::
in)
637 template<
typename _SAlloc>
639 const allocator_type& __a)
643 template<
typename _SAlloc>
646 const allocator_type& __a)
647 : __istream_type(), _M_stringbuf(__str, __mode | ios_base::
in, __a)
650 template<
typename _SAlloc>
666 __istream_type::operator=(
std::move(__rhs));
667 _M_stringbuf =
std::move(__rhs._M_stringbuf);
674 __istream_type::swap(__rhs);
675 _M_stringbuf.swap(__rhs._M_stringbuf);
688 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
695 str() const _GLIBCXX_LVAL_REF_QUAL
696 {
return _M_stringbuf.str(); }
698#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
700 template<__allocator_like _SAlloc>
702 str(
const _SAlloc& __sa)
const
703 {
return _M_stringbuf.str(__sa); }
708 {
return std::move(_M_stringbuf).str(); }
710 basic_string_view<char_type, traits_type>
711 view() const noexcept
712 {
return _M_stringbuf.view(); }
723 { _M_stringbuf.str(__s); }
725#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
727 template<__allocator_like _SAlloc>
728 requires (!is_same_v<_SAlloc, _Alloc>)
731 { _M_stringbuf.str(__s); }
735 str(__string_type&& __s)
756 template <
typename _CharT,
typename _Traits,
typename _Alloc>
765 typedef _Alloc allocator_type;
766 typedef typename traits_type::int_type
int_type;
767 typedef typename traits_type::pos_type
pos_type;
768 typedef typename traits_type::off_type
off_type;
776 __stringbuf_type _M_stringbuf;
792 { this->
init(&_M_stringbuf); }
809 { this->
init(&_M_stringbuf); }
828 { this->
init(&_M_stringbuf); }
839#if __cplusplus >= 201103L
843 : __ostream_type(
std::move(__rhs)),
844 _M_stringbuf(
std::move(__rhs._M_stringbuf))
845 { __ostream_type::set_rdbuf(&_M_stringbuf); }
847#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
849 : __ostream_type(), _M_stringbuf(__mode | ios_base::
out, __a)
855 : __ostream_type(), _M_stringbuf(
std::move(__str), __mode | ios_base::
out)
858 template<
typename _SAlloc>
860 const allocator_type& __a)
864 template<
typename _SAlloc>
867 const allocator_type& __a)
868 : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::
out, __a)
871 template<
typename _SAlloc>
887 __ostream_type::operator=(
std::move(__rhs));
888 _M_stringbuf =
std::move(__rhs._M_stringbuf);
895 __ostream_type::swap(__rhs);
896 _M_stringbuf.swap(__rhs._M_stringbuf);
909 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
916 str() const _GLIBCXX_LVAL_REF_QUAL
917 {
return _M_stringbuf.str(); }
919#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
921 template<__allocator_like _SAlloc>
923 str(
const _SAlloc& __sa)
const
924 {
return _M_stringbuf.str(__sa); }
929 {
return std::move(_M_stringbuf).str(); }
931 basic_string_view<char_type, traits_type>
932 view() const noexcept
933 {
return _M_stringbuf.view(); }
944 { _M_stringbuf.str(__s); }
946#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
948 template<__allocator_like _SAlloc>
949 requires (!is_same_v<_SAlloc, _Alloc>)
952 { _M_stringbuf.str(__s); }
956 str(__string_type&& __s)
977 template <
typename _CharT,
typename _Traits,
typename _Alloc>
986 typedef _Alloc allocator_type;
987 typedef typename traits_type::int_type
int_type;
988 typedef typename traits_type::pos_type
pos_type;
989 typedef typename traits_type::off_type
off_type;
997 __stringbuf_type _M_stringbuf;
1013 { this->
init(&_M_stringbuf); }
1028 { this->
init(&_M_stringbuf); }
1045 { this->
init(&_M_stringbuf); }
1056#if __cplusplus >= 201103L
1060 : __iostream_type(
std::move(__rhs)),
1061 _M_stringbuf(
std::move(__rhs._M_stringbuf))
1062 { __iostream_type::set_rdbuf(&_M_stringbuf); }
1064#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1066 : __iostream_type(), _M_stringbuf(__mode, __a)
1067 { this->
init(&_M_stringbuf); }
1073 : __iostream_type(), _M_stringbuf(
std::move(__str), __mode)
1076 template<
typename _SAlloc>
1078 const allocator_type& __a)
1082 template<
typename _SAlloc>
1085 const allocator_type& __a)
1086 : __iostream_type(), _M_stringbuf(__str, __mode, __a)
1089 template<
typename _SAlloc>
1106 __iostream_type::operator=(
std::move(__rhs));
1107 _M_stringbuf =
std::move(__rhs._M_stringbuf);
1114 __iostream_type::swap(__rhs);
1115 _M_stringbuf.swap(__rhs._M_stringbuf);
1128 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
1135 str() const _GLIBCXX_LVAL_REF_QUAL
1136 {
return _M_stringbuf.str(); }
1138#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1140 template<__allocator_like _SAlloc>
1142 str(
const _SAlloc& __sa)
const
1143 {
return _M_stringbuf.str(__sa); }
1148 {
return std::move(_M_stringbuf).str(); }
1150 basic_string_view<char_type, traits_type>
1151 view() const noexcept
1152 {
return _M_stringbuf.view(); }
1163 { _M_stringbuf.str(__s); }
1165#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1167 template<__allocator_like _SAlloc>
1168 requires (!is_same_v<_SAlloc, _Alloc>)
1171 { _M_stringbuf.str(__s); }
1175 str(__string_type&& __s)
1180#if __cplusplus >= 201103L
1182 template <
class _CharT,
class _Traits,
class _Allocator>
1186 noexcept(noexcept(__x.swap(__y)))
1190 template <
class _CharT,
class _Traits,
class _Allocator>
1197 template <
class _CharT,
class _Traits,
class _Allocator>
1204 template <
class _CharT,
class _Traits,
class _Allocator>
1211_GLIBCXX_END_NAMESPACE_CXX11
1212_GLIBCXX_END_NAMESPACE_VERSION
1215#undef _GLIBCXX_LVAL_REF_QUAL
auto_ptr & operator=(auto_ptr &__a)
auto_ptr assignment operator.
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_string< _CharT, _Traits, _Alloc > &__lhs, basic_string< _CharT, _Traits, _Alloc > &__rhs) noexcept(/*conditional */)
Swap contents of two strings.
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)
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.
_Traits::pos_type pos_type
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
_Traits::off_type off_type
_Traits::int_type int_type
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.
_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.
The actual work of input and output (interface).
char_type * gptr() const
Access to the get area.
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.
char_type * egptr() const
Access to the get area.
char_type * pptr() 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 __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.