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())
281 if (_M_string.data() == this->pbase()) [[likely]]
283 _M_string._M_set_length(__hi - this->
pbase());
285 _M_string.assign(this->
pbase(), __hi);
289 _M_sync(_M_string.data(), 0, 0);
294 _GLIBCXX_SSTREAM_ALWAYS_INLINE
295 basic_string_view<char_type, traits_type>
296 view() const noexcept
298 if (char_type* __hi = _M_high_mark())
299 return { this->
pbase(), __hi };
313 str(
const __string_type& __s)
321#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
323 template<__allocator_like _SAlloc>
324 requires (!is_same_v<_SAlloc, _Alloc>)
334 str(__string_type&& __s)
347 __size_type __len = 0;
349 __len = _M_string.size();
350 _M_sync(
const_cast<char_type*
>(_M_string.data()), 0, __len);
369 pbackfail(int_type __c = traits_type::eof());
372 overflow(int_type __c = traits_type::eof());
385 virtual __streambuf_type*
399 _M_sync(__s, __n, 0);
416 _M_sync(char_type* __base, __size_type __i, __size_type __o);
423 if (char_type* __pptr = this->
pptr())
425 char_type* __egptr = this->
egptr();
426 if (!__egptr || __pptr > __egptr)
431 this->
setg(__pptr, __pptr, __pptr);
439 _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off);
446 __attribute__((__always_inline__))
448 _M_high_mark() const _GLIBCXX_NOEXCEPT
450 if (char_type* __pptr = this->
pptr())
452 char_type* __egptr = this->
egptr();
453 if (!__egptr || __pptr > __egptr)
461#if __cplusplus >= 201103L
462#if _GLIBCXX_USE_CXX11_ABI
465 struct __xfer_bufptrs
468 : _M_to{__to}, _M_goff{-1, -1, -1}, _M_poff{-1, -1, -1}
470 const _CharT*
const __str = __from._M_string.data();
471 const _CharT* __end =
nullptr;
474 _M_goff[0] = __from.eback() - __str;
475 _M_goff[1] = __from.gptr() - __str;
476 _M_goff[2] = __from.egptr() - __str;
477 __end = __from.egptr();
481 _M_poff[0] = __from.pbase() - __str;
482 _M_poff[1] = __from.pptr() - __from.pbase();
483 _M_poff[2] = __from.epptr() - __str;
484 if (!__end || __from.pptr() > __end)
485 __end = __from.pptr();
494 __mut_from._M_string._M_length(__end - __str);
501 if (_M_goff[0] != -1)
502 _M_to->setg(__str+_M_goff[0], __str+_M_goff[1], __str+_M_goff[2]);
503 if (_M_poff[0] != -1)
504 _M_to->_M_pbump(__str+_M_poff[0], __str+_M_poff[2], _M_poff[1]);
513 struct __xfer_bufptrs
522 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
526#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
531 : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)),
554 template<
typename _CharT,
typename _Traits,
typename _Alloc>
559 typedef _CharT char_type;
560 typedef _Traits traits_type;
563 typedef _Alloc allocator_type;
564 typedef typename traits_type::int_type int_type;
565 typedef typename traits_type::pos_type pos_type;
566 typedef typename traits_type::off_type off_type;
574 __stringbuf_type _M_stringbuf;
589 : __istream_type(), _M_stringbuf(
ios_base::
in)
590 { this->
init(&_M_stringbuf); }
606 : __istream_type(), _M_stringbuf(__mode |
ios_base::
in)
607 { this->
init(&_M_stringbuf); }
625 : __istream_type(), _M_stringbuf(__str, __mode |
ios_base::
in)
626 { this->
init(&_M_stringbuf); }
637#if __cplusplus >= 201103L
641 : __istream_type(
std::
move(__rhs)),
642 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
643 { __istream_type::set_rdbuf(&_M_stringbuf); }
645#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
647 : __istream_type(), _M_stringbuf(__mode | ios_base::
in, __a)
653 : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::
in)
656 template<
typename _SAlloc>
658 const allocator_type& __a)
662 template<
typename _SAlloc>
665 const allocator_type& __a)
666 : __istream_type(), _M_stringbuf(__str, __mode | ios_base::
in, __a)
669 template<
typename _SAlloc>
685 __istream_type::operator=(
std::move(__rhs));
686 _M_stringbuf =
std::move(__rhs._M_stringbuf);
693 __istream_type::swap(__rhs);
694 _M_stringbuf.swap(__rhs._M_stringbuf);
708 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
716 str() const _GLIBCXX_LVAL_REF_QUAL
717 {
return _M_stringbuf.str(); }
719#if __cplusplus > 201703L
720#if _GLIBCXX_USE_CXX11_ABI
722 template<__allocator_like _SAlloc>
725 str(
const _SAlloc& __sa)
const
726 {
return _M_stringbuf.str(__sa); }
732 {
return std::move(_M_stringbuf).str(); }
735 _GLIBCXX_SSTREAM_ALWAYS_INLINE
736 basic_string_view<char_type, traits_type>
737 view() const noexcept
738 {
return _M_stringbuf.view(); }
748 str(
const __string_type& __s)
749 { _M_stringbuf.str(__s); }
751#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
753 template<__allocator_like _SAlloc>
754 requires (!is_same_v<_SAlloc, _Alloc>)
757 { _M_stringbuf.str(__s); }
761 str(__string_type&& __s)
782 template <
typename _CharT,
typename _Traits,
typename _Alloc>
787 typedef _CharT char_type;
788 typedef _Traits traits_type;
791 typedef _Alloc allocator_type;
792 typedef typename traits_type::int_type int_type;
793 typedef typename traits_type::pos_type pos_type;
794 typedef typename traits_type::off_type off_type;
802 __stringbuf_type _M_stringbuf;
818 { this->
init(&_M_stringbuf); }
834 : __ostream_type(), _M_stringbuf(__mode |
ios_base::
out)
835 { this->
init(&_M_stringbuf); }
853 : __ostream_type(), _M_stringbuf(__str, __mode |
ios_base::
out)
854 { this->
init(&_M_stringbuf); }
865#if __cplusplus >= 201103L
869 : __ostream_type(
std::
move(__rhs)),
870 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
871 { __ostream_type::set_rdbuf(&_M_stringbuf); }
873#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
875 : __ostream_type(), _M_stringbuf(__mode | ios_base::
out, __a)
881 : __ostream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::
out)
884 template<
typename _SAlloc>
886 const allocator_type& __a)
890 template<
typename _SAlloc>
893 const allocator_type& __a)
894 : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::
out, __a)
897 template<
typename _SAlloc>
913 __ostream_type::operator=(
std::move(__rhs));
914 _M_stringbuf =
std::move(__rhs._M_stringbuf);
921 __ostream_type::swap(__rhs);
922 _M_stringbuf.swap(__rhs._M_stringbuf);
936 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
944 str() const _GLIBCXX_LVAL_REF_QUAL
945 {
return _M_stringbuf.str(); }
947#if __cplusplus > 201703L
948#if _GLIBCXX_USE_CXX11_ABI
950 template<__allocator_like _SAlloc>
953 str(
const _SAlloc& __sa)
const
954 {
return _M_stringbuf.str(__sa); }
960 {
return std::move(_M_stringbuf).str(); }
963 _GLIBCXX_SSTREAM_ALWAYS_INLINE
964 basic_string_view<char_type, traits_type>
965 view() const noexcept
966 {
return _M_stringbuf.view(); }
976 str(
const __string_type& __s)
977 { _M_stringbuf.str(__s); }
979#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
981 template<__allocator_like _SAlloc>
982 requires (!is_same_v<_SAlloc, _Alloc>)
985 { _M_stringbuf.str(__s); }
989 str(__string_type&& __s)
1010 template <
typename _CharT,
typename _Traits,
typename _Alloc>
1015 typedef _CharT char_type;
1016 typedef _Traits traits_type;
1019 typedef _Alloc allocator_type;
1020 typedef typename traits_type::int_type int_type;
1021 typedef typename traits_type::pos_type pos_type;
1022 typedef typename traits_type::off_type off_type;
1030 __stringbuf_type _M_stringbuf;
1046 { this->
init(&_M_stringbuf); }
1060 : __iostream_type(), _M_stringbuf(__m)
1061 { this->
init(&_M_stringbuf); }
1077 : __iostream_type(), _M_stringbuf(__str, __m)
1078 { this->
init(&_M_stringbuf); }
1089#if __cplusplus >= 201103L
1093 : __iostream_type(
std::
move(__rhs)),
1094 _M_stringbuf(
std::
move(__rhs._M_stringbuf))
1095 { __iostream_type::set_rdbuf(&_M_stringbuf); }
1097#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1099 : __iostream_type(), _M_stringbuf(__mode, __a)
1100 { this->
init(&_M_stringbuf); }
1106 : __iostream_type(), _M_stringbuf(std::move(__str), __mode)
1109 template<
typename _SAlloc>
1111 const allocator_type& __a)
1115 template<
typename _SAlloc>
1118 const allocator_type& __a)
1119 : __iostream_type(), _M_stringbuf(__str, __mode, __a)
1122 template<
typename _SAlloc>
1139 __iostream_type::operator=(
std::move(__rhs));
1140 _M_stringbuf =
std::move(__rhs._M_stringbuf);
1147 __iostream_type::swap(__rhs);
1148 _M_stringbuf.swap(__rhs._M_stringbuf);
1162 {
return const_cast<__stringbuf_type*
>(&_M_stringbuf); }
1170 str() const _GLIBCXX_LVAL_REF_QUAL
1171 {
return _M_stringbuf.str(); }
1173#if __cplusplus > 201703L
1174#if _GLIBCXX_USE_CXX11_ABI
1176 template<__allocator_like _SAlloc>
1179 str(
const _SAlloc& __sa)
const
1180 {
return _M_stringbuf.str(__sa); }
1186 {
return std::move(_M_stringbuf).str(); }
1189 _GLIBCXX_SSTREAM_ALWAYS_INLINE
1190 basic_string_view<char_type, traits_type>
1191 view() const noexcept
1192 {
return _M_stringbuf.view(); }
1203 { _M_stringbuf.str(__s); }
1205#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI
1207 template<__allocator_like _SAlloc>
1208 requires (!is_same_v<_SAlloc, _Alloc>)
1211 { _M_stringbuf.str(__s); }
1215 str(__string_type&& __s)
1220#if __cplusplus >= 201103L
1222 template <
class _CharT,
class _Traits,
class _Allocator>
1226 noexcept(
noexcept(__x.swap(__y)))
1230 template <
class _CharT,
class _Traits,
class _Allocator>
1237 template <
class _CharT,
class _Traits,
class _Allocator>
1244 template <
class _CharT,
class _Traits,
class _Allocator>
1251_GLIBCXX_END_NAMESPACE_CXX11
1252_GLIBCXX_END_NAMESPACE_VERSION
1255#undef _GLIBCXX_SSTREAM_ALWAYS_INLINE
1256#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.