00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef _SSTREAM_TCC
00041 #define _SSTREAM_TCC 1
00042
00043 #pragma GCC system_header
00044
00045 #include <sstream>
00046
00047 namespace std
00048 {
00049 template <class _CharT, class _Traits, class _Alloc>
00050 typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
00051 basic_stringbuf<_CharT, _Traits, _Alloc>::
00052 pbackfail(int_type __c)
00053 {
00054 int_type __ret = traits_type::eof();
00055 if (this->eback() < this->gptr())
00056 {
00057
00058
00059 const bool __testeof = traits_type::eq_int_type(__c, __ret);
00060 if (!__testeof)
00061 {
00062 const bool __testeq = traits_type::eq(traits_type::
00063 to_char_type(__c),
00064 this->gptr()[-1]);
00065 const bool __testout = this->_M_mode & ios_base::out;
00066 if (__testeq || __testout)
00067 {
00068 this->gbump(-1);
00069 if (!__testeq)
00070 *this->gptr() = traits_type::to_char_type(__c);
00071 __ret = __c;
00072 }
00073 }
00074 else
00075 {
00076 this->gbump(-1);
00077 __ret = traits_type::not_eof(__c);
00078 }
00079 }
00080 return __ret;
00081 }
00082
00083 template <class _CharT, class _Traits, class _Alloc>
00084 typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
00085 basic_stringbuf<_CharT, _Traits, _Alloc>::
00086 overflow(int_type __c)
00087 {
00088 const bool __testout = this->_M_mode & ios_base::out;
00089 if (__builtin_expect(!__testout, false))
00090 return traits_type::eof();
00091
00092 const bool __testeof = traits_type::eq_int_type(__c, traits_type::eof());
00093 if (__builtin_expect(__testeof, false))
00094 return traits_type::not_eof(__c);
00095
00096 const __size_type __capacity = _M_string.capacity();
00097 const __size_type __max_size = _M_string.max_size();
00098 const bool __testput = this->pptr() < this->epptr();
00099 if (__builtin_expect(!__testput && __capacity == __max_size, false))
00100 return traits_type::eof();
00101
00102
00103
00104 if (!__testput)
00105 {
00106
00107
00108
00109
00110
00111
00112 const __size_type __opt_len = std::max(__size_type(2 * __capacity),
00113 __size_type(512));
00114 const __size_type __len = std::min(__opt_len, __max_size);
00115 __string_type __tmp;
00116 __tmp.reserve(__len);
00117 if (this->pbase())
00118 __tmp.assign(this->pbase(), this->epptr() - this->pbase());
00119 _M_string.swap(__tmp);
00120 _M_sync(const_cast<char_type*>(_M_string.data()),
00121 this->gptr() - this->eback(), this->pptr() - this->pbase());
00122 }
00123 return this->sputc(traits_type::to_char_type(__c));
00124 }
00125
00126 template <class _CharT, class _Traits, class _Alloc>
00127 typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
00128 basic_stringbuf<_CharT, _Traits, _Alloc>::
00129 underflow()
00130 {
00131 int_type __ret = traits_type::eof();
00132 const bool __testin = this->_M_mode & ios_base::in;
00133 if (__testin)
00134 {
00135
00136 _M_update_egptr();
00137
00138 if (this->gptr() < this->egptr())
00139 __ret = traits_type::to_int_type(*this->gptr());
00140 }
00141 return __ret;
00142 }
00143
00144 template <class _CharT, class _Traits, class _Alloc>
00145 typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
00146 basic_stringbuf<_CharT, _Traits, _Alloc>::
00147 seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode)
00148 {
00149 pos_type __ret = pos_type(off_type(-1));
00150 bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
00151 bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
00152 const bool __testboth = __testin && __testout && __way != ios_base::cur;
00153 __testin &= !(__mode & ios_base::out);
00154 __testout &= !(__mode & ios_base::in);
00155
00156
00157
00158 const char_type* __beg = __testin ? this->eback() : this->pbase();
00159 if ((__beg || !__off) && (__testin || __testout || __testboth))
00160 {
00161 _M_update_egptr();
00162
00163 off_type __newoffi = __off;
00164 off_type __newoffo = __newoffi;
00165 if (__way == ios_base::cur)
00166 {
00167 __newoffi += this->gptr() - __beg;
00168 __newoffo += this->pptr() - __beg;
00169 }
00170 else if (__way == ios_base::end)
00171 __newoffo = __newoffi += this->egptr() - __beg;
00172
00173 if ((__testin || __testboth)
00174 && __newoffi >= 0
00175 && this->egptr() - __beg >= __newoffi)
00176 {
00177 this->gbump((__beg + __newoffi) - this->gptr());
00178 __ret = pos_type(__newoffi);
00179 }
00180 if ((__testout || __testboth)
00181 && __newoffo >= 0
00182 && this->egptr() - __beg >= __newoffo)
00183 {
00184 this->pbump((__beg + __newoffo) - this->pptr());
00185 __ret = pos_type(__newoffo);
00186 }
00187 }
00188 return __ret;
00189 }
00190
00191 template <class _CharT, class _Traits, class _Alloc>
00192 typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
00193 basic_stringbuf<_CharT, _Traits, _Alloc>::
00194 seekpos(pos_type __sp, ios_base::openmode __mode)
00195 {
00196 pos_type __ret = pos_type(off_type(-1));
00197 const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
00198 const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
00199
00200 const char_type* __beg = __testin ? this->eback() : this->pbase();
00201 if (__beg && (__testin || __testout))
00202 {
00203 _M_update_egptr();
00204
00205 const off_type __pos(__sp);
00206 const bool __testpos = 0 <= __pos
00207 && __pos <= this->egptr() - __beg;
00208 if (__testpos)
00209 {
00210 if (__testin)
00211 this->gbump((__beg + __pos) - this->gptr());
00212 if (__testout)
00213 this->pbump((__beg + __pos) - this->pptr());
00214 __ret = __sp;
00215 }
00216 }
00217 return __ret;
00218 }
00219
00220
00221
00222
00223 #if _GLIBCXX_EXTERN_TEMPLATE
00224 extern template class basic_stringbuf<char>;
00225 extern template class basic_istringstream<char>;
00226 extern template class basic_ostringstream<char>;
00227 extern template class basic_stringstream<char>;
00228
00229 #ifdef _GLIBCXX_USE_WCHAR_T
00230 extern template class basic_stringbuf<wchar_t>;
00231 extern template class basic_istringstream<wchar_t>;
00232 extern template class basic_ostringstream<wchar_t>;
00233 extern template class basic_stringstream<wchar_t>;
00234 #endif
00235 #endif
00236 }
00237
00238 #endif