35 #define _SSTREAM_TCC 1
37 #ifdef _GLIBCXX_SYSHDR
38 #pragma GCC system_header
40 #pragma GCC diagnostic push
41 #pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template
43 namespace 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
49 basic_stringbuf<_CharT, _Traits, _Alloc>::
50 pbackfail(int_type __c)
52 int_type __ret = traits_type::eof();
53 if (this->eback() < this->gptr())
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
83 basic_stringbuf<_CharT, _Traits, _Alloc>::
84 overflow(int_type __c)
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();
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());
137 __tmp.reserve(__len);
139 __tmp.assign(this->pbase(), this->epptr() - this->pbase());
140 __tmp.push_back(__conv);
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
153 basic_stringbuf<_CharT, _Traits, _Alloc>::
156 int_type __ret = traits_type::eof();
163 if (this->gptr() < this->egptr())
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
171 basic_stringbuf<_CharT, _Traits, _Alloc>::
174 pos_type __ret = pos_type(off_type(-1));
175 bool __testin = (
ios_base::in & this->_M_mode & __mode) != 0;
176 bool __testout = (
ios_base::out & this->_M_mode & __mode) != 0;
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
219 basic_stringbuf<_CharT, _Traits, _Alloc>::
222 pos_type __ret = pos_type(off_type(-1));
223 const bool __testin = (
ios_base::in & this->_M_mode & __mode) != 0;
224 const bool __testout = (
ios_base::out & this->_M_mode & __mode) != 0;
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>
249 basic_stringbuf<_CharT, _Traits, _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())
269 _M_pbump(
__base, __endp, __o);
274 this->setg(__endg, __endg, __endg);
278 template <
class _CharT,
class _Traits,
class _Alloc>
280 basic_stringbuf<_CharT, _Traits, _Alloc>::
281 _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off)
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
295 extern template class basic_stringbuf<char>;
296 extern template class basic_istringstream<char>;
297 extern template class basic_ostringstream<char>;
298 extern template class basic_stringstream<char>;
300 #ifdef _GLIBCXX_USE_WCHAR_T
301 extern template class basic_stringbuf<wchar_t>;
302 extern template class basic_istringstream<wchar_t>;
303 extern template class basic_ostringstream<wchar_t>;
304 extern template class basic_stringstream<wchar_t>;
308 _GLIBCXX_END_NAMESPACE_VERSION
311 #pragma GCC diagnostic pop