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