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 
00036 #ifndef _BASIC_IOS_H
00037 #define _BASIC_IOS_H 1
00038 
00039 #pragma GCC system_header
00040 
00041 #include <bits/streambuf_iterator.h>
00042 #include <bits/localefwd.h>
00043 #include <bits/locale_classes.h>
00044 #include <bits/locale_facets.h>
00045 
00046 namespace std
00047 {
00048   
00055   template<typename _CharT, typename _Traits>
00056     class basic_ios : public ios_base
00057     {
00058     public:
00060 
00065       typedef _CharT                                 char_type;
00066       typedef typename _Traits::int_type             int_type;
00067       typedef typename _Traits::pos_type             pos_type;
00068       typedef typename _Traits::off_type             off_type;
00069       typedef _Traits                                traits_type;
00071 
00073 
00078       typedef ctype<_CharT>                          __ctype_type;
00079       typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> >
00080                              __num_put_type;
00081       typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> >
00082                              __num_get_type;
00084 
00085       
00086     protected:
00087       basic_ostream<_CharT, _Traits>*                _M_tie;
00088       mutable char_type                              _M_fill;
00089       mutable bool                                   _M_fill_init;
00090       basic_streambuf<_CharT, _Traits>*              _M_streambuf;
00091 
00092       
00093       const __ctype_type*                            _M_ctype;
00094       
00095       const __num_put_type*                          _M_num_put;
00096       
00097       const __num_get_type*                          _M_num_get;
00098 
00099     public:
00101 
00107       operator void*() const
00108       { return this->fail() ? 0 : const_cast<basic_ios*>(this); }
00109 
00110       bool
00111       operator!() const
00112       { return this->fail(); }
00114 
00122       iostate
00123       rdstate() const
00124       { return _M_streambuf_state; }
00125 
00133       void
00134       clear(iostate __state = goodbit);
00135 
00142       void
00143       setstate(iostate __state)
00144       { this->clear(this->rdstate() | __state); }
00145 
00146       
00147       
00148       
00149       void
00150       _M_setstate(iostate __state)
00151       {
00152     
00153     
00154     _M_streambuf_state |= __state;
00155     if (this->exceptions() & __state)
00156       __throw_exception_again;
00157       }
00158 
00165       bool
00166       good() const
00167       { return this->rdstate() == 0; }
00168 
00175       bool
00176       eof() const
00177       { return (this->rdstate() & eofbit) != 0; }
00178 
00186       bool
00187       fail() const
00188       { return (this->rdstate() & (badbit | failbit)) != 0; }
00189 
00196       bool
00197       bad() const
00198       { return (this->rdstate() & badbit) != 0; }
00199 
00207       iostate
00208       exceptions() const
00209       { return _M_exception; }
00210 
00242       void
00243       exceptions(iostate __except)
00244       {
00245         _M_exception = __except;
00246         this->clear(_M_streambuf_state);
00247       }
00248 
00249       
00255       explicit
00256       basic_ios(basic_streambuf<_CharT, _Traits>* __sb)
00257       : ios_base(), _M_tie(0), _M_fill(), _M_fill_init(false), _M_streambuf(0),
00258       _M_ctype(0), _M_num_put(0), _M_num_get(0)
00259       { this->init(__sb); }
00260 
00267       virtual
00268       ~basic_ios() { }
00269 
00270       
00280       basic_ostream<_CharT, _Traits>*
00281       tie() const
00282       { return _M_tie; }
00283 
00292       basic_ostream<_CharT, _Traits>*
00293       tie(basic_ostream<_CharT, _Traits>* __tiestr)
00294       {
00295         basic_ostream<_CharT, _Traits>* __old = _M_tie;
00296         _M_tie = __tiestr;
00297         return __old;
00298       }
00299 
00306       basic_streambuf<_CharT, _Traits>*
00307       rdbuf() const
00308       { return _M_streambuf; }
00309 
00332       basic_streambuf<_CharT, _Traits>*
00333       rdbuf(basic_streambuf<_CharT, _Traits>* __sb);
00334 
00346       basic_ios&
00347       copyfmt(const basic_ios& __rhs);
00348 
00355       char_type
00356       fill() const
00357       {
00358     if (!_M_fill_init)
00359       {
00360         _M_fill = this->widen(' ');
00361         _M_fill_init = true;
00362       }
00363     return _M_fill;
00364       }
00365 
00375       char_type
00376       fill(char_type __ch)
00377       {
00378     char_type __old = this->fill();
00379     _M_fill = __ch;
00380     return __old;
00381       }
00382 
00383       
00395       locale
00396       imbue(const locale& __loc);
00397 
00415       char
00416       narrow(char_type __c, char __dfault) const;
00417 
00433       char_type
00434       widen(char __c) const;
00435 
00436     protected:
00437       
00444       basic_ios()
00445       : ios_base(), _M_tie(0), _M_fill(char_type()), _M_fill_init(false), 
00446       _M_streambuf(0), _M_ctype(0), _M_num_put(0), _M_num_get(0)
00447       { }
00448 
00455       void
00456       init(basic_streambuf<_CharT, _Traits>* __sb);
00457 
00458       void
00459       _M_cache_locale(const locale& __loc);
00460     };
00461 } 
00462 
00463 #ifndef _GLIBCXX_EXPORT_TEMPLATE
00464 #include <bits/basic_ios.tcc>
00465 #endif
00466 
00467 #endif