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