Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

basic_ios.h

Go to the documentation of this file.
00001 // Iostreams base classes -*- C++ -*-
00002 
00003 // Copyright (C) 1997, 1998, 1999, 2001 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // You should have received a copy of the GNU General Public License along
00017 // with this library; see the file COPYING.  If not, write to the Free
00018 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00019 // USA.
00020 
00021 // As a special exception, you may use this file as part of a free software
00022 // library without restriction.  Specifically, if other files instantiate
00023 // templates or use macros or inline functions from this file, or you compile
00024 // this file and link it with other files to produce an executable, this
00025 // file does not by itself cause the resulting executable to be covered by
00026 // the GNU General Public License.  This exception does not however
00027 // invalidate any other reasons why the executable file might be covered by
00028 // the GNU General Public License.
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   // 27.4.5  Template class basic_ios
00041   template<typename _CharT, typename _Traits>
00042     class basic_ios : public ios_base
00043     {
00044     public:
00045 
00046       // Types:
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       // Non-standard Types:
00054       typedef ctype<_CharT>                 __ctype_type;
00055       // From ostream
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       // Data members:
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       // Cached use_facet<ctype>, which is based on the current locale info.
00072       const __ctype_type*       _M_ios_fctype;      
00073       // From ostream.
00074       const __numput_type*      _M_fnumput;
00075       // From istream.
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       // Constructor/destructor:
00146       explicit 
00147       basic_ios(basic_streambuf<_CharT, _Traits>* __sb) : ios_base() 
00148       { this->init(__sb); }
00149 
00150       virtual 
00151       ~basic_ios() { }
00152       
00153       // Members:
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       // Locales:
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       // 27.4.5.1  basic_ios constructors
00200       basic_ios() : ios_base() 
00201       { }
00202 
00203       void 
00204       init(basic_streambuf<_CharT, _Traits>* __sb);
00205     };
00206   
00207 } // namespace std
00208 
00209 #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
00210 # define export
00211 #include <bits/basic_ios.tcc>
00212 #endif
00213 
00214 #endif /* _CPP_BITS_BASICIOS_H */
00215 
00216 

Generated at Tue May 1 16:28:37 2001 for libstdc++-v3 by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001