basic_ios.tcc
Go to the documentation of this file.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 #ifndef _BASIC_IOS_TCC
00032 #define _BASIC_IOS_TCC 1
00033
00034 #pragma GCC system_header
00035
00036 _GLIBCXX_BEGIN_NAMESPACE(std)
00037
00038 template<typename _CharT, typename _Traits>
00039 void
00040 basic_ios<_CharT, _Traits>::clear(iostate __state)
00041 {
00042 if (this->rdbuf())
00043 _M_streambuf_state = __state;
00044 else
00045 _M_streambuf_state = __state | badbit;
00046 if (this->exceptions() & this->rdstate())
00047 __throw_ios_failure(__N("basic_ios::clear"));
00048 }
00049
00050 template<typename _CharT, typename _Traits>
00051 basic_streambuf<_CharT, _Traits>*
00052 basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<_CharT, _Traits>* __sb)
00053 {
00054 basic_streambuf<_CharT, _Traits>* __old = _M_streambuf;
00055 _M_streambuf = __sb;
00056 this->clear();
00057 return __old;
00058 }
00059
00060 template<typename _CharT, typename _Traits>
00061 basic_ios<_CharT, _Traits>&
00062 basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs)
00063 {
00064
00065
00066 if (this != &__rhs)
00067 {
00068
00069
00070
00071
00072 _Words* __words = (__rhs._M_word_size <= _S_local_word_size) ?
00073 _M_local_word : new _Words[__rhs._M_word_size];
00074
00075
00076 _Callback_list* __cb = __rhs._M_callbacks;
00077 if (__cb)
00078 __cb->_M_add_reference();
00079 _M_call_callbacks(erase_event);
00080 if (_M_word != _M_local_word)
00081 {
00082 delete [] _M_word;
00083 _M_word = 0;
00084 }
00085 _M_dispose_callbacks();
00086
00087
00088 _M_callbacks = __cb;
00089 for (int __i = 0; __i < __rhs._M_word_size; ++__i)
00090 __words[__i] = __rhs._M_word[__i];
00091 _M_word = __words;
00092 _M_word_size = __rhs._M_word_size;
00093
00094 this->flags(__rhs.flags());
00095 this->width(__rhs.width());
00096 this->precision(__rhs.precision());
00097 this->tie(__rhs.tie());
00098 this->fill(__rhs.fill());
00099 _M_ios_locale = __rhs.getloc();
00100 _M_cache_locale(_M_ios_locale);
00101
00102 _M_call_callbacks(copyfmt_event);
00103
00104
00105 this->exceptions(__rhs.exceptions());
00106 }
00107 return *this;
00108 }
00109
00110
00111 template<typename _CharT, typename _Traits>
00112 locale
00113 basic_ios<_CharT, _Traits>::imbue(const locale& __loc)
00114 {
00115 locale __old(this->getloc());
00116 ios_base::imbue(__loc);
00117 _M_cache_locale(__loc);
00118 if (this->rdbuf() != 0)
00119 this->rdbuf()->pubimbue(__loc);
00120 return __old;
00121 }
00122
00123 template<typename _CharT, typename _Traits>
00124 void
00125 basic_ios<_CharT, _Traits>::init(basic_streambuf<_CharT, _Traits>* __sb)
00126 {
00127
00128 ios_base::_M_init();
00129
00130
00131 _M_cache_locale(_M_ios_locale);
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 _M_fill = _CharT();
00146 _M_fill_init = false;
00147
00148 _M_tie = 0;
00149 _M_exception = goodbit;
00150 _M_streambuf = __sb;
00151 _M_streambuf_state = __sb ? goodbit : badbit;
00152 }
00153
00154 template<typename _CharT, typename _Traits>
00155 void
00156 basic_ios<_CharT, _Traits>::_M_cache_locale(const locale& __loc)
00157 {
00158 if (__builtin_expect(has_facet<__ctype_type>(__loc), true))
00159 _M_ctype = &use_facet<__ctype_type>(__loc);
00160 else
00161 _M_ctype = 0;
00162
00163 if (__builtin_expect(has_facet<__num_put_type>(__loc), true))
00164 _M_num_put = &use_facet<__num_put_type>(__loc);
00165 else
00166 _M_num_put = 0;
00167
00168 if (__builtin_expect(has_facet<__num_get_type>(__loc), true))
00169 _M_num_get = &use_facet<__num_get_type>(__loc);
00170 else
00171 _M_num_get = 0;
00172 }
00173
00174
00175
00176
00177 #if _GLIBCXX_EXTERN_TEMPLATE
00178 extern template class basic_ios<char>;
00179
00180 #ifdef _GLIBCXX_USE_WCHAR_T
00181 extern template class basic_ios<wchar_t>;
00182 #endif
00183 #endif
00184
00185 _GLIBCXX_END_NAMESPACE
00186
00187 #endif