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 _GLIBCXX_BEGIN_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 const char_type __conv = traits_type::to_char_type(__c);
00105 if (!__testput)
00106 {
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 const __size_type __opt_len = std::max(__size_type(2 * __capacity),
00117 __size_type(512));
00118 const __size_type __len = std::min(__opt_len, __max_size);
00119 __string_type __tmp;
00120 __tmp.reserve(__len);
00121 if (this->pbase())
00122 __tmp.assign(this->pbase(), this->epptr() - this->pbase());
00123 __tmp.push_back(__conv);
00124 _M_string.swap(__tmp);
00125 _M_sync(const_cast<char_type*>(_M_string.data()),
00126 this->gptr() - this->eback(), this->pptr() - this->pbase());
00127 }
00128 else
00129 *this->pptr() = __conv;
00130 this->pbump(1);
00131 return __c;
00132 }
00133
00134 template <class _CharT, class _Traits, class _Alloc>
00135 typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
00136 basic_stringbuf<_CharT, _Traits, _Alloc>::
00137 underflow()
00138 {
00139 int_type __ret = traits_type::eof();
00140 const bool __testin = this->_M_mode & ios_base::in;
00141 if (__testin)
00142 {
00143
00144 _M_update_egptr();
00145
00146 if (this->gptr() < this->egptr())
00147 __ret = traits_type::to_int_type(*this->gptr());
00148 }
00149 return __ret;
00150 }
00151
00152 template <class _CharT, class _Traits, class _Alloc>
00153 typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
00154 basic_stringbuf<_CharT, _Traits, _Alloc>::
00155 seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode)
00156 {
00157 pos_type __ret = pos_type(off_type(-1));
00158 bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
00159 bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
00160 const bool __testboth = __testin && __testout && __way != ios_base::cur;
00161 __testin &= !(__mode & ios_base::out);
00162 __testout &= !(__mode & ios_base::in);
00163
00164
00165
00166 const char_type* __beg = __testin ? this->eback() : this->pbase();
00167 if ((__beg || !__off) && (__testin || __testout || __testboth))
00168 {
00169 _M_update_egptr();
00170
00171 off_type __newoffi = __off;
00172 off_type __newoffo = __newoffi;
00173 if (__way == ios_base::cur)
00174 {
00175 __newoffi += this->gptr() - __beg;
00176 __newoffo += this->pptr() - __beg;
00177 }
00178 else if (__way == ios_base::end)
00179 __newoffo = __newoffi += this->egptr() - __beg;
00180
00181 if ((__testin || __testboth)
00182 && __newoffi >= 0
00183 && this->egptr() - __beg >= __newoffi)
00184 {
00185 this->gbump((__beg + __newoffi) - this->gptr());
00186 __ret = pos_type(__newoffi);
00187 }
00188 if ((__testout || __testboth)
00189 && __newoffo >= 0
00190 && this->egptr() - __beg >= __newoffo)
00191 {
00192 this->pbump((__beg + __newoffo) - this->pptr());
00193 __ret = pos_type(__newoffo);
00194 }
00195 }
00196 return __ret;
00197 }
00198
00199 template <class _CharT, class _Traits, class _Alloc>
00200 typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
00201 basic_stringbuf<_CharT, _Traits, _Alloc>::
00202 seekpos(pos_type __sp, ios_base::openmode __mode)
00203 {
00204 pos_type __ret = pos_type(off_type(-1));
00205 const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
00206 const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
00207
00208 const char_type* __beg = __testin ? this->eback() : this->pbase();
00209 if ((__beg || !off_type(__sp)) && (__testin || __testout))
00210 {
00211 _M_update_egptr();
00212
00213 const off_type __pos(__sp);
00214 const bool __testpos = (0 <= __pos
00215 && __pos <= this->egptr() - __beg);
00216 if (__testpos)
00217 {
00218 if (__testin)
00219 this->gbump((__beg + __pos) - this->gptr());
00220 if (__testout)
00221 this->pbump((__beg + __pos) - this->pptr());
00222 __ret = __sp;
00223 }
00224 }
00225 return __ret;
00226 }
00227
00228 template <class _CharT, class _Traits, class _Alloc>
00229 void
00230 basic_stringbuf<_CharT, _Traits, _Alloc>::
00231 _M_sync(char_type* __base, __size_type __i, __size_type __o)
00232 {
00233 const bool __testin = _M_mode & ios_base::in;
00234 const bool __testout = _M_mode & ios_base::out;
00235 char_type* __endg = __base + _M_string.size();
00236 char_type* __endp = __base + _M_string.capacity();
00237
00238 if (__base != _M_string.data())
00239 {
00240
00241 __endg += __i;
00242 __i = 0;
00243 __endp = __endg;
00244 }
00245
00246 if (__testin)
00247 this->setg(__base, __base + __i, __endg);
00248 if (__testout)
00249 {
00250 this->setp(__base, __endp);
00251 this->pbump(__o);
00252
00253
00254
00255 if (!__testin)
00256 this->setg(__endg, __endg, __endg);
00257 }
00258 }
00259
00260
00261
00262
00263 #if _GLIBCXX_EXTERN_TEMPLATE
00264 extern template class basic_stringbuf<char>;
00265 extern template class basic_istringstream<char>;
00266 extern template class basic_ostringstream<char>;
00267 extern template class basic_stringstream<char>;
00268
00269 #ifdef _GLIBCXX_USE_WCHAR_T
00270 extern template class basic_stringbuf<wchar_t>;
00271 extern template class basic_istringstream<wchar_t>;
00272 extern template class basic_ostringstream<wchar_t>;
00273 extern template class basic_stringstream<wchar_t>;
00274 #endif
00275 #endif
00276
00277 _GLIBCXX_END_NAMESPACE
00278
00279 #endif