37 #define _SSTREAM_TCC 1
39 #pragma GCC system_header
41 namespace std _GLIBCXX_VISIBILITY(default)
43 _GLIBCXX_BEGIN_NAMESPACE_VERSION
45 template <
class _CharT,
class _Traits,
class _Alloc>
46 typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
47 basic_stringbuf<_CharT, _Traits, _Alloc>::
48 pbackfail(int_type __c)
50 int_type __ret = traits_type::eof();
51 if (this->eback() < this->gptr())
55 const bool __testeof = traits_type::eq_int_type(__c, __ret);
58 const bool __testeq = traits_type::eq(traits_type::
62 if (__testeq || __testout)
66 *this->gptr() = traits_type::to_char_type(__c);
73 __ret = traits_type::not_eof(__c);
79 template <
class _CharT,
class _Traits,
class _Alloc>
80 typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
81 basic_stringbuf<_CharT, _Traits, _Alloc>::
82 overflow(int_type __c)
85 if (__builtin_expect(!__testout,
false))
86 return traits_type::eof();
88 const bool __testeof = traits_type::eq_int_type(__c, traits_type::eof());
89 if (__builtin_expect(__testeof,
false))
90 return traits_type::not_eof(__c);
92 const __size_type __capacity = _M_string.capacity();
93 const __size_type __max_size = _M_string.max_size();
94 const bool __testput = this->pptr() < this->epptr();
95 if (__builtin_expect(!__testput && __capacity == __max_size,
false))
96 return traits_type::eof();
100 const char_type __conv = traits_type::to_char_type(__c);
112 const __size_type __opt_len =
std::max(__size_type(2 * __capacity),
114 const __size_type __len =
std::min(__opt_len, __max_size);
116 __tmp.reserve(__len);
118 __tmp.assign(this->pbase(), this->epptr() - this->pbase());
119 __tmp.push_back(__conv);
120 _M_string.swap(__tmp);
121 _M_sync(const_cast<char_type*>(_M_string.data()),
122 this->gptr() - this->eback(), this->pptr() - this->pbase());
125 *this->pptr() = __conv;
130 template <
class _CharT,
class _Traits,
class _Alloc>
131 typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
135 int_type __ret = traits_type::eof();
142 if (this->gptr() < this->egptr())
143 __ret = traits_type::to_int_type(*this->gptr());
148 template <
class _CharT,
class _Traits,
class _Alloc>
149 typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
151 seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode)
153 pos_type __ret = pos_type(off_type(-1));
154 bool __testin = (
ios_base::in & this->_M_mode & __mode) != 0;
155 bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
156 const bool __testboth = __testin && __testout && __way !=
ios_base::cur;
162 const char_type* __beg = __testin ? this->eback() : this->pbase();
163 if ((__beg || !__off) && (__testin || __testout || __testboth))
167 off_type __newoffi = __off;
168 off_type __newoffo = __newoffi;
171 __newoffi += this->gptr() - __beg;
172 __newoffo += this->pptr() - __beg;
175 __newoffo = __newoffi += this->egptr() - __beg;
177 if ((__testin || __testboth)
179 && this->egptr() - __beg >= __newoffi)
181 this->setg(this->eback(), this->eback() + __newoffi,
183 __ret = pos_type(__newoffi);
185 if ((__testout || __testboth)
187 && this->egptr() - __beg >= __newoffo)
189 _M_pbump(this->pbase(), this->epptr(), __newoffo);
190 __ret = pos_type(__newoffo);
196 template <
class _CharT,
class _Traits,
class _Alloc>
197 typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
199 seekpos(pos_type __sp, ios_base::openmode __mode)
201 pos_type __ret = pos_type(off_type(-1));
202 const bool __testin = (
ios_base::in & this->_M_mode & __mode) != 0;
203 const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
205 const char_type* __beg = __testin ? this->eback() : this->pbase();
206 if ((__beg || !off_type(__sp)) && (__testin || __testout))
210 const off_type __pos(__sp);
211 const bool __testpos = (0 <= __pos
212 && __pos <= this->egptr() - __beg);
216 this->setg(this->eback(), this->eback() + __pos,
219 _M_pbump(this->pbase(), this->epptr(), __pos);
226 template <
class _CharT,
class _Traits,
class _Alloc>
233 char_type* __endg = __base + _M_string.size();
234 char_type* __endp = __base + _M_string.capacity();
236 if (__base != _M_string.data())
245 this->setg(__base, __base + __i, __endg);
248 _M_pbump(__base, __endp, __o);
253 this->setg(__endg, __endg, __endg);
257 template <
class _CharT,
class _Traits,
class _Alloc>
259 basic_stringbuf<_CharT, _Traits, _Alloc>::
260 _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off)
262 this->setp(__pbeg, __pend);
263 while (__off > __gnu_cxx::__numeric_traits<int>::__max)
265 this->pbump(__gnu_cxx::__numeric_traits<int>::__max);
266 __off -= __gnu_cxx::__numeric_traits<int>::__max;
273 #if _GLIBCXX_EXTERN_TEMPLATE
274 extern template class basic_stringbuf<char>;
275 extern template class basic_istringstream<char>;
276 extern template class basic_ostringstream<char>;
277 extern template class basic_stringstream<char>;
279 #ifdef _GLIBCXX_USE_WCHAR_T
280 extern template class basic_stringbuf<wchar_t>;
281 extern template class basic_istringstream<wchar_t>;
282 extern template class basic_ostringstream<wchar_t>;
283 extern template class basic_stringstream<wchar_t>;
287 _GLIBCXX_END_NAMESPACE_VERSION
static const seekdir end
Request a seek relative to the current end of the sequence.
virtual pos_type seekpos(pos_type __sp, ios_base::openmode __mode=ios_base::in|ios_base::out)
Alters the stream positions.
const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
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.
const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
static const openmode out
Open for output. Default for ofstream and fstream.
static const openmode in
Open for input. Default for ifstream and fstream.
virtual int_type underflow()
Fetches more data from the controlled sequence.
static const seekdir cur
Request a seek relative to the current position within the sequence.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
The actual work of input and output (for std::string).This class associates either or both of its inp...