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;
110 __string_type _M_string;
134 : __streambuf_type(),
_M_mode(__mode), _M_string()
148 : __streambuf_type(),
_M_mode(),
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)
174 : __streambuf_type(),
_M_mode(__mode), _M_string(std::
move(__s))
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
204 {
return _M_string.get_allocator(); }
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
251 __string_type __ret(_M_string.get_allocator());
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())
276 if (_M_string.data() == this->pbase()) [[likely]]
278 _M_string._M_set_length(__hi - this->
pbase());
280 _M_string.assign(this->
pbase(), __hi);
284 _M_sync(_M_string.data(), 0, 0);
289 _GLIBCXX_SSTREAM_ALWAYS_INLINE
290 basic_string_view<char_type, traits_type>
291 view() const noexcept
293 if (char_type* __hi = _M_high_mark())
294 return { this->
pbase(), __hi };
308 str(
const __string_type& __s)
316#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
318 template<__allocator_like _SAlloc>
319 requires (!is_same_v<_SAlloc, _Alloc>)
329 str(__string_type&& __s)
342 __size_type __len = 0;
344 __len = _M_string.size();
345 _M_sync(
const_cast<char_type*
>(_M_string.data()), 0, __len);
364 pbackfail(int_type __c = traits_type::eof());
367 overflow(int_type __c = traits_type::eof());
380 virtual __streambuf_type*
394 _M_sync(__s, __n, 0);
411 _M_sync(char_type* __base, __size_type __i, __size_type __o);
418 if (char_type* __pptr = this->
pptr())
420 char_type* __egptr = this->
egptr();
421 if (!__egptr || __pptr > __egptr)
426 this->
setg(__pptr, __pptr, __pptr);
434 _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off);
441 __attribute__((__always_inline__))
443 _M_high_mark() const _GLIBCXX_NOEXCEPT
445 if (char_type* __pptr = this->
pptr())
447 char_type* __egptr = this->
egptr();
448 if (!__egptr || __pptr > __egptr)
456#if __cplusplus >= 201103L
457#if _GLIBCXX_USE_CXX11_ABI
460 struct __xfer_bufptrs
463 : _M_to{__to}, _M_goff{-1, -1, -1}, _M_poff{-1, -1, -1}
465 const _CharT*
const __str = __from._M_string.data();
466 const _CharT* __end =
nullptr;
469 _M_goff[0] = __from.eback() - __str;
470 _M_goff[1] = __from.gptr() - __str;
471 _M_goff[2] = __from.egptr() - __str;
472 __end = __from.egptr();
476 _M_poff[0] = __from.pbase() - __str;
477 _M_poff[1] = __from.pptr() - __from.pbase();
478 _M_poff[2] = __from.epptr() - __str;
479 if (!__end || __from.pptr() > __end)
480 __end = __from.pptr();
489 __mut_from._M_string._M_length(__end - __str);
496 if (_M_goff[0] != -1)
497 _M_to->setg(__str+_M_goff[0], __str+_M_goff[1], __str+_M_goff[2]);
498 if (_M_poff[0] != -1)
499 _M_to->_M_pbump(__str+_M_poff[0], __str+_M_poff[2], _M_poff[1]);
508 struct __xfer_bufptrs
517 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
521#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
526 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
549 template<
typename _CharT,
typename _Traits,
typename _Alloc>
554 typedef _CharT char_type;
555 typedef _Traits traits_type;
558 typedef _Alloc allocator_type;
559 typedef typename traits_type::int_type int_type;
560 typedef typename traits_type::pos_type pos_type;
561 typedef typename traits_type::off_type off_type;
569 __stringbuf_type _M_stringbuf;
584 : __istream_type(), _M_stringbuf(
ios_base::
in)
585 { this->
init(&_M_stringbuf); }
601 : __istream_type(), _M_stringbuf(__mode |
ios_base::
in)
602 { this->
init(&_M_stringbuf); }
620 : __istream_type(), _M_stringbuf(__str, __mode |
ios_base::
in)
621 { this->
init(&_M_stringbuf); }
632#if __cplusplus >= 201103L
636 : __istream_type(
std::
move(__rhs)),
637 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
638 { __istream_type::set_rdbuf(&_M_stringbuf); }
640#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
642 : __istream_type(), _M_stringbuf(__mode | ios_base::
in, __a)
648 : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::
in)
651 template<
typename _SAlloc>
653 const allocator_type& __a)
657 template<
typename _SAlloc>
660 const allocator_type& __a)
661 : __istream_type(), _M_stringbuf(__str, __mode | ios_base::
in, __a)
664 template<
typename _SAlloc>
680 __istream_type::operator=(
std::move(__rhs));
681 _M_stringbuf =
std::move(__rhs._M_stringbuf);
688 __istream_type::swap(__rhs);
689 _M_stringbuf.swap(__rhs._M_stringbuf);
702 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
709 str() const _GLIBCXX_LVAL_REF_QUAL
710 {
return _M_stringbuf.str(); }
712#if __cplusplus > 201703L
713#if _GLIBCXX_USE_CXX11_ABI
715 template<__allocator_like _SAlloc>
717 str(
const _SAlloc& __sa)
const
718 {
return _M_stringbuf.str(__sa); }
723 {
return std::move(_M_stringbuf).str(); }
726 _GLIBCXX_SSTREAM_ALWAYS_INLINE
727 basic_string_view<char_type, traits_type>
728 view() const noexcept
729 {
return _M_stringbuf.view(); }
739 str(
const __string_type& __s)
740 { _M_stringbuf.str(__s); }
742#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
744 template<__allocator_like _SAlloc>
745 requires (!is_same_v<_SAlloc, _Alloc>)
748 { _M_stringbuf.str(__s); }
752 str(__string_type&& __s)
773 template <
typename _CharT,
typename _Traits,
typename _Alloc>
778 typedef _CharT char_type;
779 typedef _Traits traits_type;
782 typedef _Alloc allocator_type;
783 typedef typename traits_type::int_type int_type;
784 typedef typename traits_type::pos_type pos_type;
785 typedef typename traits_type::off_type off_type;
793 __stringbuf_type _M_stringbuf;
809 { this->
init(&_M_stringbuf); }
825 : __ostream_type(), _M_stringbuf(__mode |
ios_base::
out)
826 { this->
init(&_M_stringbuf); }
844 : __ostream_type(), _M_stringbuf(__str, __mode |
ios_base::
out)
845 { this->
init(&_M_stringbuf); }
856#if __cplusplus >= 201103L
860 : __ostream_type(
std::
move(__rhs)),
861 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
862 { __ostream_type::set_rdbuf(&_M_stringbuf); }
864#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
866 : __ostream_type(), _M_stringbuf(__mode | ios_base::
out, __a)
872 : __ostream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::
out)
875 template<
typename _SAlloc>
877 const allocator_type& __a)
881 template<
typename _SAlloc>
884 const allocator_type& __a)
885 : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::
out, __a)
888 template<
typename _SAlloc>
904 __ostream_type::operator=(
std::move(__rhs));
905 _M_stringbuf =
std::move(__rhs._M_stringbuf);
912 __ostream_type::swap(__rhs);
913 _M_stringbuf.swap(__rhs._M_stringbuf);
926 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
933 str() const _GLIBCXX_LVAL_REF_QUAL
934 {
return _M_stringbuf.str(); }
936#if __cplusplus > 201703L
937#if _GLIBCXX_USE_CXX11_ABI
939 template<__allocator_like _SAlloc>
941 str(
const _SAlloc& __sa)
const
942 {
return _M_stringbuf.str(__sa); }
947 {
return std::move(_M_stringbuf).str(); }
950 _GLIBCXX_SSTREAM_ALWAYS_INLINE
951 basic_string_view<char_type, traits_type>
952 view() const noexcept
953 {
return _M_stringbuf.view(); }
963 str(
const __string_type& __s)
964 { _M_stringbuf.str(__s); }
966#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
968 template<__allocator_like _SAlloc>
969 requires (!is_same_v<_SAlloc, _Alloc>)
972 { _M_stringbuf.str(__s); }
976 str(__string_type&& __s)
997 template <
typename _CharT,
typename _Traits,
typename _Alloc>
1002 typedef _CharT char_type;
1003 typedef _Traits traits_type;
1006 typedef _Alloc allocator_type;
1007 typedef typename traits_type::int_type int_type;
1008 typedef typename traits_type::pos_type pos_type;
1009 typedef typename traits_type::off_type off_type;
1017 __stringbuf_type _M_stringbuf;
1033 { this->
init(&_M_stringbuf); }
1047 : __iostream_type(), _M_stringbuf(__m)
1048 { this->
init(&_M_stringbuf); }
1064 : __iostream_type(), _M_stringbuf(__str, __m)
1065 { this->
init(&_M_stringbuf); }
1076#if __cplusplus >= 201103L
1080 : __iostream_type(
std::
move(__rhs)),
1081 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
1082 { __iostream_type::set_rdbuf(&_M_stringbuf); }
1084#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1086 : __iostream_type(), _M_stringbuf(__mode, __a)
1087 { this->
init(&_M_stringbuf); }
1093 : __iostream_type(), _M_stringbuf(std::move(__str), __mode)
1096 template<
typename _SAlloc>
1098 const allocator_type& __a)
1102 template<
typename _SAlloc>
1105 const allocator_type& __a)
1106 : __iostream_type(), _M_stringbuf(__str, __mode, __a)
1109 template<
typename _SAlloc>
1126 __iostream_type::operator=(
std::move(__rhs));
1127 _M_stringbuf =
std::move(__rhs._M_stringbuf);
1134 __iostream_type::swap(__rhs);
1135 _M_stringbuf.swap(__rhs._M_stringbuf);
1148 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
1155 str() const _GLIBCXX_LVAL_REF_QUAL
1156 {
return _M_stringbuf.str(); }
1158#if __cplusplus > 201703L
1159#if _GLIBCXX_USE_CXX11_ABI
1161 template<__allocator_like _SAlloc>
1163 str(
const _SAlloc& __sa)
const
1164 {
return _M_stringbuf.str(__sa); }
1169 {
return std::move(_M_stringbuf).str(); }
1172 _GLIBCXX_SSTREAM_ALWAYS_INLINE
1173 basic_string_view<char_type, traits_type>
1174 view() const noexcept
1175 {
return _M_stringbuf.view(); }
1186 { _M_stringbuf.str(__s); }
1188#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1190 template<__allocator_like _SAlloc>
1191 requires (!is_same_v<_SAlloc, _Alloc>)
1194 { _M_stringbuf.str(__s); }
1198 str(__string_type&& __s)
1203#if __cplusplus >= 201103L
1205 template <
class _CharT,
class _Traits,
class _Allocator>
1209 noexcept(
noexcept(__x.swap(__y)))
1213 template <
class _CharT,
class _Traits,
class _Allocator>
1220 template <
class _CharT,
class _Traits,
class _Allocator>
1227 template <
class _CharT,
class _Traits,
class _Allocator>
1234_GLIBCXX_END_NAMESPACE_CXX11
1235_GLIBCXX_END_NAMESPACE_VERSION
1238#undef _GLIBCXX_SSTREAM_ALWAYS_INLINE
1239#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.
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.
traits_type::off_type off_type
basic_streambuf()
Base constructor.
basic_istream(__streambuf_type *__sb)
Base constructor.
basic_ostream(__streambuf_type *__sb)
Base constructor.
basic_iostream(basic_streambuf< _CharT, _Traits > *__sb)
Constructor does nothing.
The actual work of input and output (for std::string).
virtual streamsize showmanyc()
Investigating the data available.
virtual int_type underflow()
Fetches more data from the controlled sequence.
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.
__string_type str() const &
Copying out the string buffer.
virtual __streambuf_type * setbuf(char_type *__s, streamsize __n)
Manipulates the buffer.
ios_base::openmode _M_mode
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.
basic_istringstream(const __string_type &__str, ios_base::openmode __mode=ios_base::in)
Starts with an existing string buffer.
__string_type str() const &
Copying out the 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.
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.
__string_type str() const &
Copying out the 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.
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.
__string_type str() const &
Copying out the string 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.
constexpr size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
constexpr const _CharT * data() const noexcept
Return const pointer to contents.
constexpr basic_string & assign(const basic_string &__str)
Set value to contents of another 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.
_Ios_Seekdir seekdir
This is an enumerated type.
static const openmode ate
Open and seek to end immediately after opening.