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
00035 #ifndef _CPP_BITS_BASICIOS_H
00036 #define _CPP_BITS_BASICIOS_H 1
00037
00038 #pragma GCC system_header
00039
00040 #include <bits/streambuf_iterator.h>
00041 #include <bits/locale_facets.h>
00042
00043 namespace std
00044 {
00045
00046 template<typename _CharT, typename _Traits>
00047 class basic_ios : public ios_base
00048 {
00049 public:
00050
00051 typedef _CharT char_type;
00052 typedef typename _Traits::int_type int_type;
00053 typedef typename _Traits::pos_type pos_type;
00054 typedef typename _Traits::off_type off_type;
00055 typedef _Traits traits_type;
00056
00057
00058 typedef ctype<_CharT> __ctype_type;
00059 typedef ostreambuf_iterator<_CharT, _Traits> __ostreambuf_iter;
00060 typedef num_put<_CharT, __ostreambuf_iter> __numput_type;
00061 typedef istreambuf_iterator<_CharT, _Traits> __istreambuf_iter;
00062 typedef num_get<_CharT, __istreambuf_iter> __numget_type;
00063
00064
00065 protected:
00066 basic_ostream<_CharT, _Traits>* _M_tie;
00067 mutable char_type _M_fill;
00068 mutable bool _M_fill_init;
00069 basic_streambuf<_CharT, _Traits>* _M_streambuf;
00070
00071
00072 const __ctype_type* _M_fctype;
00073
00074 const __numput_type* _M_fnumput;
00075
00076 const __numget_type* _M_fnumget;
00077
00078 public:
00079 operator void*() const
00080 { return this->fail() ? 0 : const_cast<basic_ios*>(this); }
00081
00082 bool
00083 operator!() const
00084 { return this->fail(); }
00085
00086 iostate
00087 rdstate() const
00088 { return _M_streambuf_state; }
00089
00090 void
00091 clear(iostate __state = goodbit);
00092
00093 void
00094 setstate(iostate __state)
00095 { this->clear(this->rdstate() | __state); }
00096
00097 bool
00098 good() const
00099 { return this->rdstate() == 0; }
00100
00101 bool
00102 eof() const
00103 { return (this->rdstate() & eofbit) != 0; }
00104
00105 bool
00106 fail() const
00107 { return (this->rdstate() & (badbit | failbit)) != 0; }
00108
00109 bool
00110 bad() const
00111 { return (this->rdstate() & badbit) != 0; }
00112
00113 iostate
00114 exceptions() const
00115 { return _M_exception; }
00116
00117 void
00118 exceptions(iostate __except)
00119 {
00120 _M_exception = __except;
00121 this->clear(_M_streambuf_state);
00122 }
00123
00124
00125 explicit
00126 basic_ios(basic_streambuf<_CharT, _Traits>* __sb) : ios_base()
00127 { this->init(__sb); }
00128
00129 virtual
00130 ~basic_ios() { }
00131
00132
00133 basic_ostream<_CharT, _Traits>*
00134 tie() const
00135 { return _M_tie; }
00136
00137 basic_ostream<_CharT, _Traits>*
00138 tie(basic_ostream<_CharT, _Traits>* __tiestr)
00139 {
00140 basic_ostream<_CharT, _Traits>* __old = _M_tie;
00141 _M_tie = __tiestr;
00142 return __old;
00143 }
00144
00145 basic_streambuf<_CharT, _Traits>*
00146 rdbuf() const
00147 { return _M_streambuf; }
00148
00149 basic_streambuf<_CharT, _Traits>*
00150 rdbuf(basic_streambuf<_CharT, _Traits>* __sb);
00151
00152 basic_ios&
00153 copyfmt(const basic_ios& __rhs);
00154
00155 char_type
00156 fill() const
00157 {
00158 if (!_M_fill_init)
00159 {
00160 _M_fill = this->widen(' ');
00161 _M_fill_init = true;
00162 }
00163 return _M_fill;
00164 }
00165
00166 char_type
00167 fill(char_type __ch)
00168 {
00169 char_type __old = this->fill();
00170 _M_fill = __ch;
00171 return __old;
00172 }
00173
00174
00175 locale
00176 imbue(const locale& __loc);
00177
00178 char
00179 narrow(char_type __c, char __dfault) const;
00180
00181 char_type
00182 widen(char __c) const;
00183
00184 protected:
00185
00186 basic_ios() : ios_base()
00187 { }
00188
00189 void
00190 init(basic_streambuf<_CharT, _Traits>* __sb);
00191
00192 bool
00193 _M_check_facet(const locale::facet* __f) const
00194 {
00195 if (!__f)
00196 __throw_bad_cast();
00197 return true;
00198 }
00199
00200 void
00201 _M_cache_facets(const locale& __loc);
00202 };
00203 }
00204
00205 #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
00206 # define export
00207 #include <bits/basic_ios.tcc>
00208 #endif
00209
00210 #endif