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
00052 template<typename _CharT, typename _Traits>
00053 class basic_ios : public ios_base
00054 {
00055 public:
00057
00062 typedef _CharT char_type;
00063 typedef typename _Traits::int_type int_type;
00064 typedef typename _Traits::pos_type pos_type;
00065 typedef typename _Traits::off_type off_type;
00066 typedef _Traits traits_type;
00068
00070
00075 typedef ctype<_CharT> __ctype_type;
00076 typedef ostreambuf_iterator<_CharT, _Traits> __ostreambuf_iter;
00077 typedef num_put<_CharT, __ostreambuf_iter> __numput_type;
00078 typedef istreambuf_iterator<_CharT, _Traits> __istreambuf_iter;
00079 typedef num_get<_CharT, __istreambuf_iter> __numget_type;
00081
00082
00083 protected:
00084 basic_ostream<_CharT, _Traits>* _M_tie;
00085 mutable char_type _M_fill;
00086 mutable bool _M_fill_init;
00087 basic_streambuf<_CharT, _Traits>* _M_streambuf;
00088
00089
00090 const __ctype_type* _M_fctype;
00091
00092 const __numput_type* _M_fnumput;
00093
00094 const __numget_type* _M_fnumget;
00095
00096 public:
00098
00104 operator void*() const
00105 { return this->fail() ? 0 : const_cast<basic_ios*>(this); }
00106
00107 bool
00108 operator!() const
00109 { return this->fail(); }
00111
00119 iostate
00120 rdstate() const
00121 { return _M_streambuf_state; }
00122
00130 void
00131 clear(iostate __state = goodbit);
00132
00139 void
00140 setstate(iostate __state)
00141 { this->clear(this->rdstate() | __state); }
00142
00149 bool
00150 good() const
00151 { return this->rdstate() == 0; }
00152
00159 bool
00160 eof() const
00161 { return (this->rdstate() & eofbit) != 0; }
00162
00170 bool
00171 fail() const
00172 { return (this->rdstate() & (badbit | failbit)) != 0; }
00173
00180 bool
00181 bad() const
00182 { return (this->rdstate() & badbit) != 0; }
00183
00191 iostate
00192 exceptions() const
00193 { return _M_exception; }
00194
00226 void
00227 exceptions(iostate __except)
00228 {
00229 _M_exception = __except;
00230 this->clear(_M_streambuf_state);
00231 }
00232
00233
00239 explicit
00240 basic_ios(basic_streambuf<_CharT, _Traits>* __sb) : ios_base()
00241 { this->init(__sb); }
00242
00249 virtual
00250 ~basic_ios() { }
00251
00252
00262 basic_ostream<_CharT, _Traits>*
00263 tie() const
00264 { return _M_tie; }
00265
00274 basic_ostream<_CharT, _Traits>*
00275 tie(basic_ostream<_CharT, _Traits>* __tiestr)
00276 {
00277 basic_ostream<_CharT, _Traits>* __old = _M_tie;
00278 _M_tie = __tiestr;
00279 return __old;
00280 }
00281
00288 basic_streambuf<_CharT, _Traits>*
00289 rdbuf() const
00290 { return _M_streambuf; }
00291
00307 basic_streambuf<_CharT, _Traits>*
00308 rdbuf(basic_streambuf<_CharT, _Traits>* __sb);
00309
00313 basic_ios&
00314 copyfmt(const basic_ios& __rhs);
00315
00322 char_type
00323 fill() const
00324 {
00325 if (!_M_fill_init)
00326 {
00327 _M_fill = this->widen(' ');
00328 _M_fill_init = true;
00329 }
00330 return _M_fill;
00331 }
00332
00342 char_type
00343 fill(char_type __ch)
00344 {
00345 char_type __old = this->fill();
00346 _M_fill = __ch;
00347 return __old;
00348 }
00349
00350
00362 locale
00363 imbue(const locale& __loc);
00364
00382 char
00383 narrow(char_type __c, char __dfault) const;
00384
00400 char_type
00401 widen(char __c) const;
00402
00403 protected:
00404
00411 basic_ios() : ios_base()
00412 { }
00413
00420 void
00421 init(basic_streambuf<_CharT, _Traits>* __sb);
00422
00423 bool
00424 _M_check_facet(const locale::facet* __f) const
00425 {
00426 if (!__f)
00427 __throw_bad_cast();
00428 return true;
00429 }
00430
00431 void
00432 _M_cache_facets(const locale& __loc);
00433 };
00434 }
00435
00436 #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
00437 # define export
00438 #include <bits/basic_ios.tcc>
00439 #endif
00440
00441 #endif