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