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
00041 #ifndef _SSTREAM_TCC
00042 #define _SSTREAM_TCC 1
00043
00044 #pragma GCC system_header
00045
00046 _GLIBCXX_BEGIN_NAMESPACE(std)
00047
00048 template <class _CharT, class _Traits, class _Alloc>
00049 typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
00050 basic_stringbuf<_CharT, _Traits, _Alloc>::
00051 pbackfail(int_type __c)
00052 {
00053 int_type __ret = traits_type::eof();
00054 if (this->eback() < this->gptr())
00055 {
00056
00057
00058 const bool __testeof = traits_type::eq_int_type(__c, __ret);
00059 if (!__testeof)
00060 {
00061 const bool __testeq = traits_type::eq(traits_type::
00062 to_char_type(__c),
00063 this->gptr()[-1]);
00064 const bool __testout = this->_M_mode & ios_base::out;
00065 if (__testeq || __testout)
00066 {
00067 this->gbump(-1);
00068 if (!__testeq)
00069 *this->gptr() = traits_type::to_char_type(__c);
00070 __ret = __c;
00071 }
00072 }
00073 else
00074 {
00075 this->gbump(-1);
00076 __ret = traits_type::not_eof(__c);
00077 }
00078 }
00079 return __ret;
00080 }
00081
00082 template <class _CharT, class _Traits, class _Alloc>
00083 typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
00084 basic_stringbuf<_CharT, _Traits, _Alloc>::
00085 overflow(int_type __c)
00086 {
00087 const bool __testout = this->_M_mode & ios_base::out;
00088 if (__builtin_expect(!__testout, false))
00089 return traits_type::eof();
00090
00091 const bool __testeof = traits_type::eq_int_type(__c, traits_type::eof());
00092 if (__builtin_expect(__testeof, false))
00093 return traits_type::not_eof(__c);
00094
00095 const __size_type __capacity = _M_string.capacity();
00096 const __size_type __max_size = _M_string.max_size();
00097 const bool __testput = this->pptr() < this->epptr();
00098 if (__builtin_expect(!__testput && __capacity == __max_size, false))
00099 return traits_type::eof();
00100
00101
00102
00103 const char_type __conv = traits_type::to_char_type(__c);
00104 if (!__testput)
00105 {
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 const __size_type __opt_len = std::max(__size_type(2 * __capacity),
00116 __size_type(512));
00117 const __size_type __len = std::min(__opt_len, __max_size);
00118 __string_type __tmp;
00119 __tmp.reserve(__len);
00120 if (this->pbase())
00121 __tmp.assign(this->pbase(), this->epptr() - this->pbase());
00122 __tmp.push_back(__conv);
00123 _M_string.swap(__tmp);
00124 _M_sync(const_cast<char_type*>(_M_string.data()),
00125 this->gptr() - this->eback(), this->pptr() - this->pbase());
00126 }
00127 else
00128 *this->pptr() = __conv;
00129 this->pbump(1);
00130 return __c;
00131 }
00132
00133 template <class _CharT, class _Traits, class _Alloc>
00134 typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
00135 basic_stringbuf<_CharT, _Traits, _Alloc>::
00136 underflow()
00137 {
00138 int_type __ret = traits_type::eof();
00139 const bool __testin = this->_M_mode & ios_base::in;
00140 if (__testin)
00141 {
00142
00143 _M_update_egptr();
00144
00145 if (this->gptr() < this->egptr())
00146 __ret = traits_type::to_int_type(*this->gptr());
00147 }
00148 return __ret;
00149 }
00150
00151 template <class _CharT, class _Traits, class _Alloc>
00152 typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
00153 basic_stringbuf<_CharT, _Traits, _Alloc>::
00154 seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode)
00155 {
00156 pos_type __ret = pos_type(off_type(-1));
00157 bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
00158 bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
00159 const bool __testboth = __testin && __testout && __way != ios_base::cur;
00160 __testin &= !(__mode & ios_base::out);
00161 __testout &= !(__mode & ios_base::in);
00162
00163
00164
00165 const char_type* __beg = __testin ? this->eback() : this->pbase();
00166 if ((__beg || !__off) && (__testin || __testout || __testboth))
00167 {
00168 _M_update_egptr();
00169
00170 off_type __newoffi = __off;
00171 off_type __newoffo = __newoffi;
00172 if (__way == ios_base::cur)
00173 {
00174 __newoffi += this->gptr() - __beg;
00175 __newoffo += this->pptr() - __beg;
00176 }
00177 else if (__way == ios_base::end)
00178 __newoffo = __newoffi += this->egptr() - __beg;
00179
00180 if ((__testin || __testboth)
00181 && __newoffi >= 0
00182 && this->egptr() - __beg >= __newoffi)
00183 {
00184 this->gbump((__beg + __newoffi) - this->gptr());
00185 __ret = pos_type(__newoffi);
00186 }
00187 if ((__testout || __testboth)
00188 && __newoffo >= 0
00189 && this->egptr() - __beg >= __newoffo)
00190 {
00191 this->pbump((__beg + __newoffo) - this->pptr());
00192 __ret = pos_type(__newoffo);
00193 }
00194 }
00195 return __ret;
00196 }
00197
00198 template <class _CharT, class _Traits, class _Alloc>
00199 typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
00200 basic_stringbuf<_CharT, _Traits, _Alloc>::
00201 seekpos(pos_type __sp, ios_base::openmode __mode)
00202 {
00203 pos_type __ret = pos_type(off_type(-1));
00204 const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
00205 const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
00206
00207 const char_type* __beg = __testin ? this->eback() : this->pbase();
00208 if ((__beg || !off_type(__sp)) && (__testin || __testout))
00209 {
00210 _M_update_egptr();
00211
00212 const off_type __pos(__sp);
00213 const bool __testpos = (0 <= __pos
00214 && __pos <= this->egptr() - __beg);
00215 if (__testpos)
00216 {
00217 if (__testin)
00218 this->gbump((__beg + __pos) - this->gptr());
00219 if (__testout)
00220 this->pbump((__beg + __pos) - this->pptr());
00221 __ret = __sp;
00222 }
00223 }
00224 return __ret;
00225 }
00226
00227 template <class _CharT, class _Traits, class _Alloc>
00228 void
00229 basic_stringbuf<_CharT, _Traits, _Alloc>::
00230 _M_sync(char_type* __base, __size_type __i, __size_type __o)
00231 {
00232 const bool __testin = _M_mode & ios_base::in;
00233 const bool __testout = _M_mode & ios_base::out;
00234 char_type* __endg = __base + _M_string.size();
00235 char_type* __endp = __base + _M_string.capacity();
00236
00237 if (__base != _M_string.data())
00238 {
00239
00240 __endg += __i;
00241 __i = 0;
00242 __endp = __endg;
00243 }
00244
00245 if (__testin)
00246 this->setg(__base, __base + __i, __endg);
00247 if (__testout)
00248 {
00249 this->setp(__base, __endp);
00250 this->pbump(__o);
00251
00252
00253
00254 if (!__testin)
00255 this->setg(__endg, __endg, __endg);
00256 }
00257 }
00258
00259
00260
00261
00262 #if _GLIBCXX_EXTERN_TEMPLATE
00263 extern template class basic_stringbuf<char>;
00264 extern template class basic_istringstream<char>;
00265 extern template class basic_ostringstream<char>;
00266 extern template class basic_stringstream<char>;
00267
00268 #ifdef _GLIBCXX_USE_WCHAR_T
00269 extern template class basic_stringbuf<wchar_t>;
00270 extern template class basic_istringstream<wchar_t>;
00271 extern template class basic_ostringstream<wchar_t>;
00272 extern template class basic_stringstream<wchar_t>;
00273 #endif
00274 #endif
00275
00276 _GLIBCXX_END_NAMESPACE
00277
00278 #endif