33#ifndef _GLIBCXX_SSTREAM
34#define _GLIBCXX_SSTREAM 1
37#pragma GCC system_header
46#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
47# define _GLIBCXX_LVAL_REF_QUAL &
48# define _GLIBCXX_SSTREAM_ALWAYS_INLINE
50# define _GLIBCXX_LVAL_REF_QUAL
52# define _GLIBCXX_SSTREAM_ALWAYS_INLINE [[__gnu__::__always_inline__]]
57namespace std _GLIBCXX_VISIBILITY(default)
59_GLIBCXX_BEGIN_NAMESPACE_VERSION
60_GLIBCXX_BEGIN_NAMESPACE_CXX11
80 template<
typename _CharT,
typename _Traits,
typename _Alloc>
83 struct __xfer_bufptrs;
85#if __cplusplus >= 201103L
94 typedef _CharT char_type;
95 typedef _Traits traits_type;
98 typedef _Alloc allocator_type;
99 typedef typename traits_type::int_type int_type;
100 typedef typename traits_type::pos_type pos_type;
101 typedef typename traits_type::off_type off_type;
105 typedef typename __string_type::size_type __size_type;
112 __string_type _M_string;
136 : __streambuf_type(),
_M_mode(__mode), _M_string()
150 : __streambuf_type(),
_M_mode(),
151 _M_string(__str.
data(), __str.
size(), __str.get_allocator())
152 { _M_stringbuf_init(__mode); }
154#if __cplusplus >= 201103L
159 { __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0); }
161#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
168 const allocator_type& __a)
169 : __streambuf_type(),
_M_mode(__mode), _M_string(__a)
176 : __streambuf_type(),
_M_mode(__mode), _M_string(std::
move(__s))
177 { _M_stringbuf_init(__mode); }
179 template<
typename _SAlloc>
181 const allocator_type& __a)
185 template<
typename _SAlloc>
188 const allocator_type& __a)
189 : __streambuf_type(),
_M_mode(__mode),
190 _M_string(__s.
data(), __s.
size(), __a)
191 { _M_stringbuf_init(__mode); }
193 template<
typename _SAlloc>
203 { __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0); }
205 allocator_type get_allocator() const noexcept
206 {
return _M_string.get_allocator(); }
217 __xfer_bufptrs __st{__rhs,
this};
218 const __streambuf_type&
__base = __rhs;
219 __streambuf_type::operator=(__base);
223 __rhs._M_sync(
const_cast<char_type*
>(__rhs._M_string.data()), 0, 0);
231 __xfer_bufptrs __r_st{__rhs,
this};
232 __streambuf_type&
__base = __rhs;
233 __streambuf_type::swap(__base);
234 __rhs.pubimbue(this->
pubimbue(__rhs.getloc()));
235 std::swap(
_M_mode, __rhs._M_mode);
236 std::swap(_M_string, __rhs._M_string);
252 str() const _GLIBCXX_LVAL_REF_QUAL
254 __string_type __ret(_M_string.get_allocator());
255 if (char_type* __hi = _M_high_mark())
262#if __cplusplus > 201703L
263#if _GLIBCXX_USE_CXX11_ABI
265 template<__allocator_like _SAlloc>
268 str(
const _SAlloc& __sa)
const
271 return { __sv.data(), __sv.size(), __sa };
279 if (char_type* __hi = _M_high_mark())
282 _M_string._M_set_length(_M_high_mark() - this->
pbase());
286 _M_sync(_M_string.data(), 0, 0);
291 _GLIBCXX_SSTREAM_ALWAYS_INLINE
292 basic_string_view<char_type, traits_type>
293 view() const noexcept
295 if (char_type* __hi = _M_high_mark())
296 return { this->
pbase(), __hi };
310 str(
const __string_type& __s)
318#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
320 template<__allocator_like _SAlloc>
321 requires (!is_same_v<_SAlloc, _Alloc>)
331 str(__string_type&& __s)
344 __size_type __len = 0;
346 __len = _M_string.size();
347 _M_sync(
const_cast<char_type*
>(_M_string.data()), 0, __len);
366 pbackfail(int_type __c = traits_type::eof());
369 overflow(int_type __c = traits_type::eof());
382 virtual __streambuf_type*
396 _M_sync(__s, __n, 0);
413 _M_sync(char_type* __base, __size_type __i, __size_type __o);
420 if (char_type* __pptr = this->
pptr())
422 char_type* __egptr = this->
egptr();
423 if (!__egptr || __pptr > __egptr)
428 this->
setg(__pptr, __pptr, __pptr);
436 _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off);
443 __attribute__((__always_inline__))
445 _M_high_mark() const _GLIBCXX_NOEXCEPT
447 if (char_type* __pptr = this->
pptr())
449 char_type* __egptr = this->
egptr();
450 if (!__egptr || __pptr > __egptr)
458#if __cplusplus >= 201103L
459#if _GLIBCXX_USE_CXX11_ABI
462 struct __xfer_bufptrs
465 : _M_to{__to}, _M_goff{-1, -1, -1}, _M_poff{-1, -1, -1}
467 const _CharT*
const __str = __from._M_string.data();
468 const _CharT* __end =
nullptr;
471 _M_goff[0] = __from.eback() - __str;
472 _M_goff[1] = __from.gptr() - __str;
473 _M_goff[2] = __from.egptr() - __str;
474 __end = __from.egptr();
478 _M_poff[0] = __from.pbase() - __str;
479 _M_poff[1] = __from.pptr() - __from.pbase();
480 _M_poff[2] = __from.epptr() - __str;
481 if (!__end || __from.pptr() > __end)
482 __end = __from.pptr();
491 __mut_from._M_string._M_length(__end - __str);
498 if (_M_goff[0] != -1)
499 _M_to->setg(__str+_M_goff[0], __str+_M_goff[1], __str+_M_goff[2]);
500 if (_M_poff[0] != -1)
501 _M_to->_M_pbump(__str+_M_poff[0], __str+_M_poff[2], _M_poff[1]);
510 struct __xfer_bufptrs
519 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
523#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
528 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
551 template<
typename _CharT,
typename _Traits,
typename _Alloc>
556 typedef _CharT char_type;
557 typedef _Traits traits_type;
560 typedef _Alloc allocator_type;
561 typedef typename traits_type::int_type int_type;
562 typedef typename traits_type::pos_type pos_type;
563 typedef typename traits_type::off_type off_type;
571 __stringbuf_type _M_stringbuf;
586 : __istream_type(), _M_stringbuf(
ios_base::
in)
587 { this->
init(&_M_stringbuf); }
603 : __istream_type(), _M_stringbuf(__mode |
ios_base::
in)
604 { this->
init(&_M_stringbuf); }
622 : __istream_type(), _M_stringbuf(__str, __mode |
ios_base::
in)
623 { this->
init(&_M_stringbuf); }
634#if __cplusplus >= 201103L
638 : __istream_type(
std::
move(__rhs)),
639 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
640 { __istream_type::set_rdbuf(&_M_stringbuf); }
642#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
644 : __istream_type(), _M_stringbuf(__mode | ios_base::
in, __a)
650 : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::
in)
653 template<
typename _SAlloc>
655 const allocator_type& __a)
659 template<
typename _SAlloc>
662 const allocator_type& __a)
663 : __istream_type(), _M_stringbuf(__str, __mode | ios_base::
in, __a)
666 template<
typename _SAlloc>
682 __istream_type::operator=(
std::move(__rhs));
683 _M_stringbuf =
std::move(__rhs._M_stringbuf);
690 __istream_type::swap(__rhs);
691 _M_stringbuf.swap(__rhs._M_stringbuf);
705 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
713 str() const _GLIBCXX_LVAL_REF_QUAL
714 {
return _M_stringbuf.str(); }
716#if __cplusplus > 201703L
717#if _GLIBCXX_USE_CXX11_ABI
719 template<__allocator_like _SAlloc>
722 str(
const _SAlloc& __sa)
const
723 {
return _M_stringbuf.str(__sa); }
729 {
return std::move(_M_stringbuf).str(); }
732 _GLIBCXX_SSTREAM_ALWAYS_INLINE
733 basic_string_view<char_type, traits_type>
734 view() const noexcept
735 {
return _M_stringbuf.view(); }
745 str(
const __string_type& __s)
746 { _M_stringbuf.str(__s); }
748#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
750 template<__allocator_like _SAlloc>
751 requires (!is_same_v<_SAlloc, _Alloc>)
754 { _M_stringbuf.str(__s); }
758 str(__string_type&& __s)
779 template <
typename _CharT,
typename _Traits,
typename _Alloc>
784 typedef _CharT char_type;
785 typedef _Traits traits_type;
788 typedef _Alloc allocator_type;
789 typedef typename traits_type::int_type int_type;
790 typedef typename traits_type::pos_type pos_type;
791 typedef typename traits_type::off_type off_type;
799 __stringbuf_type _M_stringbuf;
815 { this->
init(&_M_stringbuf); }
831 : __ostream_type(), _M_stringbuf(__mode |
ios_base::
out)
832 { this->
init(&_M_stringbuf); }
850 : __ostream_type(), _M_stringbuf(__str, __mode |
ios_base::
out)
851 { this->
init(&_M_stringbuf); }
862#if __cplusplus >= 201103L
866 : __ostream_type(
std::
move(__rhs)),
867 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
868 { __ostream_type::set_rdbuf(&_M_stringbuf); }
870#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
872 : __ostream_type(), _M_stringbuf(__mode | ios_base::
out, __a)
878 : __ostream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::
out)
881 template<
typename _SAlloc>
883 const allocator_type& __a)
887 template<
typename _SAlloc>
890 const allocator_type& __a)
891 : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::
out, __a)
894 template<
typename _SAlloc>
910 __ostream_type::operator=(
std::move(__rhs));
911 _M_stringbuf =
std::move(__rhs._M_stringbuf);
918 __ostream_type::swap(__rhs);
919 _M_stringbuf.swap(__rhs._M_stringbuf);
933 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
941 str() const _GLIBCXX_LVAL_REF_QUAL
942 {
return _M_stringbuf.str(); }
944#if __cplusplus > 201703L
945#if _GLIBCXX_USE_CXX11_ABI
947 template<__allocator_like _SAlloc>
950 str(
const _SAlloc& __sa)
const
951 {
return _M_stringbuf.str(__sa); }
957 {
return std::move(_M_stringbuf).str(); }
960 _GLIBCXX_SSTREAM_ALWAYS_INLINE
961 basic_string_view<char_type, traits_type>
962 view() const noexcept
963 {
return _M_stringbuf.view(); }
973 str(
const __string_type& __s)
974 { _M_stringbuf.str(__s); }
976#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
978 template<__allocator_like _SAlloc>
979 requires (!is_same_v<_SAlloc, _Alloc>)
982 { _M_stringbuf.str(__s); }
986 str(__string_type&& __s)
1007 template <
typename _CharT,
typename _Traits,
typename _Alloc>
1012 typedef _CharT char_type;
1013 typedef _Traits traits_type;
1016 typedef _Alloc allocator_type;
1017 typedef typename traits_type::int_type int_type;
1018 typedef typename traits_type::pos_type pos_type;
1019 typedef typename traits_type::off_type off_type;
1027 __stringbuf_type _M_stringbuf;
1043 { this->
init(&_M_stringbuf); }
1057 : __iostream_type(), _M_stringbuf(__m)
1058 { this->
init(&_M_stringbuf); }
1074 : __iostream_type(), _M_stringbuf(__str, __m)
1075 { this->
init(&_M_stringbuf); }
1086#if __cplusplus >= 201103L
1090 : __iostream_type(
std::
move(__rhs)),
1091 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
1092 { __iostream_type::set_rdbuf(&_M_stringbuf); }
1094#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1096 : __iostream_type(), _M_stringbuf(__mode, __a)
1097 { this->
init(&_M_stringbuf); }
1103 : __iostream_type(), _M_stringbuf(std::move(__str), __mode)
1106 template<
typename _SAlloc>
1108 const allocator_type& __a)
1112 template<
typename _SAlloc>
1115 const allocator_type& __a)
1116 : __iostream_type(), _M_stringbuf(__str, __mode, __a)
1119 template<
typename _SAlloc>
1136 __iostream_type::operator=(
std::move(__rhs));
1137 _M_stringbuf =
std::move(__rhs._M_stringbuf);
1144 __iostream_type::swap(__rhs);
1145 _M_stringbuf.swap(__rhs._M_stringbuf);
1159 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
1167 str() const _GLIBCXX_LVAL_REF_QUAL
1168 {
return _M_stringbuf.str(); }
1170#if __cplusplus > 201703L
1171#if _GLIBCXX_USE_CXX11_ABI
1173 template<__allocator_like _SAlloc>
1176 str(
const _SAlloc& __sa)
const
1177 {
return _M_stringbuf.str(__sa); }
1183 {
return std::move(_M_stringbuf).str(); }
1186 _GLIBCXX_SSTREAM_ALWAYS_INLINE
1187 basic_string_view<char_type, traits_type>
1188 view() const noexcept
1189 {
return _M_stringbuf.view(); }
1200 { _M_stringbuf.str(__s); }
1202#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1204 template<__allocator_like _SAlloc>
1205 requires (!is_same_v<_SAlloc, _Alloc>)
1208 { _M_stringbuf.str(__s); }
1212 str(__string_type&& __s)
1217#if __cplusplus >= 201103L
1219 template <
class _CharT,
class _Traits,
class _Allocator>
1223 noexcept(
noexcept(__x.swap(__y)))
1227 template <
class _CharT,
class _Traits,
class _Allocator>
1234 template <
class _CharT,
class _Traits,
class _Allocator>
1241 template <
class _CharT,
class _Traits,
class _Allocator>
1248_GLIBCXX_END_NAMESPACE_CXX11
1249_GLIBCXX_END_NAMESPACE_VERSION
1252#undef _GLIBCXX_SSTREAM_ALWAYS_INLINE
1253#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.