1 // Iostreams base classes -*- C++ -*-
3 // Copyright (C) 1997, 1998, 1999, 2001 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 #ifndef _CPP_BITS_BASICIOS_H
31 #define _CPP_BITS_BASICIOS_H 1
33 #pragma GCC system_header
35 #include <bits/streambuf_iterator.h>
36 #include <bits/locale_facets.h>
40 // 27.4.5 Template class basic_ios
41 template<typename _CharT
, typename _Traits
>
42 class basic_ios
: public ios_base
46 typedef _CharT char_type
;
47 typedef typename
_Traits::int_type int_type
;
48 typedef typename
_Traits::pos_type pos_type
;
49 typedef typename
_Traits::off_type off_type
;
50 typedef _Traits traits_type
;
52 // Non-standard Types:
53 typedef ctype
<_CharT
> __ctype_type
;
54 typedef ostreambuf_iterator
<_CharT
, _Traits
> __ostreambuf_iter
;
55 typedef num_put
<_CharT
, __ostreambuf_iter
> __numput_type
;
56 typedef istreambuf_iterator
<_CharT
, _Traits
> __istreambuf_iter
;
57 typedef num_get
<_CharT
, __istreambuf_iter
> __numget_type
;
61 basic_ostream
<_CharT
, _Traits
>* _M_tie
;
66 basic_streambuf
<_CharT
, _Traits
>* _M_streambuf
;
67 iostate _M_streambuf_state
;
69 // Cached use_facet<ctype>, which is based on the current locale info.
70 const __ctype_type
* _M_ios_fctype
;
72 const __numput_type
* _M_fnumput
;
74 const __numget_type
* _M_fnumget
;
77 inline const __ctype_type
*
78 _M_get_fctype_ios(void)
79 { return _M_ios_fctype
; }
81 operator void*() const
82 { return this->fail() ? 0 : const_cast<basic_ios
*>(this); }
86 { return this->fail(); }
90 { return _M_streambuf_state
; }
93 clear(iostate __state
= goodbit
)
96 _M_streambuf_state
= __state
;
98 _M_streambuf_state
= __state
| badbit
;
99 if ((this->rdstate() & this->exceptions()))
100 __throw_ios_failure("basic_ios::clear(iostate) caused exception");
104 setstate(iostate __state
)
105 { this->clear(this->rdstate() | __state
); }
109 { return this->rdstate() == 0; }
113 { return (this->rdstate() & eofbit
) != 0; }
117 { return (this->rdstate() & (badbit
| failbit
)) != 0; }
121 { return (this->rdstate() & badbit
) != 0; }
125 { return _M_exception
; }
128 exceptions(iostate __except
)
130 _M_exception
= __except
;
131 this->clear(_M_streambuf_state
);
134 // Constructor/destructor:
136 basic_ios(basic_streambuf
<_CharT
, _Traits
>* __sb
) : ios_base()
137 { this->init(__sb
); }
143 inline basic_ostream
<_CharT
, _Traits
>*
147 inline basic_ostream
<_CharT
, _Traits
>*
148 tie(basic_ostream
<_CharT
, _Traits
>* __tiestr
)
150 basic_ostream
<_CharT
, _Traits
>* __old
= _M_tie
;
155 inline basic_streambuf
<_CharT
, _Traits
>*
157 { return _M_streambuf
; }
159 basic_streambuf
<_CharT
, _Traits
>*
160 rdbuf(basic_streambuf
<_CharT
, _Traits
>* __sb
);
163 copyfmt(const basic_ios
& __rhs
);
172 char_type __old
= _M_fill
;
179 imbue(const locale
& __loc
);
182 narrow(char_type __c
, char __dfault
) const;
185 widen(char __c
) const;
188 // 27.4.5.1 basic_ios constructors
189 basic_ios() : ios_base()
193 init(basic_streambuf
<_CharT
, _Traits
>* __sb
);
196 _M_check_facet(const locale::facet
* __f
)
207 _M_cache_facets(const locale
& __loc
);
211 #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
213 #include <bits/basic_ios.tcc>
216 #endif /* _CPP_BITS_BASICIOS_H */