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