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 _CPP_BITS_BASICIOS_H
00037 #define _CPP_BITS_BASICIOS_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 ostreambuf_iterator<_CharT, _Traits> __ostreambuf_iter;
00080 typedef num_put<_CharT, __ostreambuf_iter> __numput_type;
00081 typedef istreambuf_iterator<_CharT, _Traits> __istreambuf_iter;
00082 typedef num_get<_CharT, __istreambuf_iter> __numget_type;
00084
00085 friend void ios_base::Init::_S_ios_create(bool);
00086
00087
00088 protected:
00089 basic_ostream<_CharT, _Traits>* _M_tie;
00090 mutable char_type _M_fill;
00091 mutable bool _M_fill_init;
00092 basic_streambuf<_CharT, _Traits>* _M_streambuf;
00093
00094
00095 const __ctype_type* _M_fctype;
00096
00097 const __numput_type* _M_fnumput;
00098
00099 const __numget_type* _M_fnumget;
00100
00101 public:
00103
00109 operator void*() const
00110 { return this->fail() ? 0 : const_cast<basic_ios*>(this); }
00111
00112 bool
00113 operator!() const
00114 { return this->fail(); }
00116
00124 iostate
00125 rdstate() const
00126 { return _M_streambuf_state; }
00127
00135 void
00136 clear(iostate __state = goodbit);
00137
00144 void
00145 setstate(iostate __state)
00146 { this->clear(this->rdstate() | __state); }
00147
00154 bool
00155 good() const
00156 { return this->rdstate() == 0; }
00157
00164 bool
00165 eof() const
00166 { return (this->rdstate() & eofbit) != 0; }
00167
00175 bool
00176 fail() const
00177 { return (this->rdstate() & (badbit | failbit)) != 0; }
00178
00185 bool
00186 bad() const
00187 { return (this->rdstate() & badbit) != 0; }
00188
00196 iostate
00197 exceptions() const
00198 { return _M_exception; }
00199
00231 void
00232 exceptions(iostate __except)
00233 {
00234 _M_exception = __except;
00235 this->clear(_M_streambuf_state);
00236 }
00237
00238
00244 explicit
00245 basic_ios(basic_streambuf<_CharT, _Traits>* __sb) : ios_base()
00246 { this->init(__sb); }
00247
00254 virtual
00255 ~basic_ios() { }
00256
00257
00267 basic_ostream<_CharT, _Traits>*
00268 tie() const
00269 { return _M_tie; }
00270
00279 basic_ostream<_CharT, _Traits>*
00280 tie(basic_ostream<_CharT, _Traits>* __tiestr)
00281 {
00282 basic_ostream<_CharT, _Traits>* __old = _M_tie;
00283 _M_tie = __tiestr;
00284 return __old;
00285 }
00286
00293 basic_streambuf<_CharT, _Traits>*
00294 rdbuf() const
00295 { return _M_streambuf; }
00296
00312 basic_streambuf<_CharT, _Traits>*
00313 rdbuf(basic_streambuf<_CharT, _Traits>* __sb);
00314
00318 basic_ios&
00319 copyfmt(const basic_ios& __rhs);
00320
00327 char_type
00328 fill() const
00329 {
00330 if (!_M_fill_init)
00331 {
00332 _M_fill = this->widen(' ');
00333 _M_fill_init = true;
00334 }
00335 return _M_fill;
00336 }
00337
00347 char_type
00348 fill(char_type __ch)
00349 {
00350 char_type __old = this->fill();
00351 _M_fill = __ch;
00352 return __old;
00353 }
00354
00355
00367 locale
00368 imbue(const locale& __loc);
00369
00387 char
00388 narrow(char_type __c, char __dfault) const;
00389
00405 char_type
00406 widen(char __c) const;
00407
00408 protected:
00409
00416 basic_ios() : ios_base()
00417 { }
00418
00427 void
00428 init(basic_streambuf<_CharT, _Traits>* __sb,
00429 __locale_cache<_CharT>* __cache=0);
00430
00431 bool
00432 _M_check_facet(const locale::facet* __f) const
00433 {
00434 if (!__f)
00435 __throw_bad_cast();
00436 return true;
00437 }
00438
00439 void
00440 _M_cache_locale(const locale& __loc,__locale_cache<_CharT>* __cache = 0);
00441
00442 #if 1
00443
00444 void
00445 _M_cache_facets(const locale& __loc);
00446 #endif
00447
00448
00449
00450 void
00451 _M_setstate(iostate __state) { _M_streambuf_state |= __state; }
00452 };
00453 }
00454
00455 #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
00456 # define export
00457 #include <bits/basic_ios.tcc>
00458 #endif
00459
00460 #endif