38#pragma GCC system_header
40#pragma GCC diagnostic push
41#pragma GCC diagnostic ignored "-Wc++11-extensions"
43namespace std _GLIBCXX_VISIBILITY(default)
45_GLIBCXX_BEGIN_NAMESPACE_VERSION
47 template <
class _CharT,
class _Traits,
class _Alloc>
48 typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
52 int_type __ret = traits_type::eof();
57 const bool __testeof = traits_type::eq_int_type(__c, __ret);
60 const bool __testeq = traits_type::eq(traits_type::
64 if (__testeq || __testout)
68 *this->
gptr() = traits_type::to_char_type(__c);
75 __ret = traits_type::not_eof(__c);
81 template <
class _CharT,
class _Traits,
class _Alloc>
82 typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
87 if (__builtin_expect(!__testout,
false))
88 return traits_type::eof();
90 const bool __testeof = traits_type::eq_int_type(__c, traits_type::eof());
91 if (__builtin_expect(__testeof,
false))
92 return traits_type::not_eof(__c);
94 const __size_type __capacity = _M_string.capacity();
96#if _GLIBCXX_USE_CXX11_ABI
97 if (
size_t(this->
epptr() - this->
pbase()) < __capacity)
100 char_type* __base =
const_cast<char_type*
>(_M_string.data());
101 _M_pbump(__base, __base + __capacity, this->
pptr() - this->
pbase());
104 const __size_type __nget = this->
gptr() - this->
eback();
105 const __size_type __eget = this->
egptr() - this->
eback();
106 this->
setg(__base, __base + __nget, __base + __eget + 1);
108 *this->
pptr() = traits_type::to_char_type(__c);
114 const __size_type __max_size = _M_string.max_size();
115 const bool __testput = this->
pptr() < this->
epptr();
116 if (__builtin_expect(!__testput && __capacity == __max_size,
false))
117 return traits_type::eof();
121 const char_type __conv = traits_type::to_char_type(__c);
133 const __size_type __opt_len =
std::max(__size_type(2 * __capacity),
135 const __size_type __len =
std::min(__opt_len, __max_size);
136 __string_type __tmp(_M_string.get_allocator());
141 _M_string.swap(__tmp);
142 _M_sync(
const_cast<char_type*
>(_M_string.data()),
143 this->gptr() - this->eback(), this->pptr() - this->pbase());
146 *this->
pptr() = __conv;
151 template <
class _CharT,
class _Traits,
class _Alloc>
152 typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
156 int_type __ret = traits_type::eof();
164 __ret = traits_type::to_int_type(*this->
gptr());
169 template <
class _CharT,
class _Traits,
class _Alloc>
170 typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
174 pos_type __ret = pos_type(off_type(-1));
177 const bool __testboth = __testin && __testout && __way !=
ios_base::cur;
183 const char_type* __beg = __testin ? this->
eback() : this->
pbase();
184 if ((__beg || !__off) && (__testin || __testout || __testboth))
188 off_type __newoffi = __off;
189 off_type __newoffo = __newoffi;
192 __newoffi += this->
gptr() - __beg;
193 __newoffo += this->
pptr() - __beg;
196 __newoffo = __newoffi += this->
egptr() - __beg;
198 if ((__testin || __testboth)
200 && this->
egptr() - __beg >= __newoffi)
202 this->
setg(this->eback(), this->eback() + __newoffi,
204 __ret = pos_type(__newoffi);
206 if ((__testout || __testboth)
208 && this->
egptr() - __beg >= __newoffo)
210 _M_pbump(this->
pbase(), this->
epptr(), __newoffo);
211 __ret = pos_type(__newoffo);
217 template <
class _CharT,
class _Traits,
class _Alloc>
218 typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
222 pos_type __ret = pos_type(off_type(-1));
226 const char_type* __beg = __testin ? this->
eback() : this->
pbase();
227 if ((__beg || !off_type(__sp)) && (__testin || __testout))
231 const off_type __pos(__sp);
232 const bool __testpos = (0 <= __pos
233 && __pos <= this->
egptr() - __beg);
237 this->
setg(this->eback(), this->eback() + __pos,
240 _M_pbump(this->
pbase(), this->
epptr(), __pos);
247 template <
class _CharT,
class _Traits,
class _Alloc>
250 _M_sync(char_type* __base, __size_type __i, __size_type __o)
254 char_type* __endg = __base + _M_string.size();
255 char_type* __endp = __base + _M_string.capacity();
257 if (__base != _M_string.data())
266 this->setg(__base, __base + __i, __endg);
269 _M_pbump(__base, __endp, __o);
274 this->setg(__endg, __endg, __endg);
278 template <
class _CharT,
class _Traits,
class _Alloc>
283 this->setp(__pbeg, __pend);
284 while (__off > __gnu_cxx::__numeric_traits<int>::__max)
286 this->pbump(__gnu_cxx::__numeric_traits<int>::__max);
287 __off -= __gnu_cxx::__numeric_traits<int>::__max;
294#if _GLIBCXX_EXTERN_TEMPLATE
300#ifdef _GLIBCXX_USE_WCHAR_T
308_GLIBCXX_END_NAMESPACE_VERSION
311#pragma GCC diagnostic pop
constexpr const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
ISO C++ entities toplevel namespace is std.
char_type * epptr() const
Access to the put area.
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.
void gbump(int __n)
Moving the read position.
void pbump(int __n)
Moving the write position.
char_type * pbase() const
Access to the put area.
The actual work of input and output (for std::string).
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.
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.
Controlling output for std::string.
Controlling input and output for std::string.
constexpr void reserve(size_type __res_arg)
Attempt to preallocate enough memory for specified number of characters.
constexpr basic_string & assign(const basic_string &__str)
Set value to contents of another string.
constexpr void push_back(_CharT __c)
Append a single character.
static const seekdir cur
Request a seek relative to the current position within the sequence.
static const seekdir end
Request a seek relative to the current end of the sequence.
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.
_Ios_Seekdir seekdir
This is an enumerated type.