ReactOS  0.4.14-dev-77-gd9e7c48
_ios.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999
3  * Silicon Graphics Computer Systems, Inc.
4  *
5  * Copyright (c) 1999
6  * Boris Fomitchev
7  *
8  * This material is provided "as is", with absolutely no warranty expressed
9  * or implied. Any use is at your own risk.
10  *
11  * Permission to use or copy this software for any purpose is hereby granted
12  * without fee, provided the above notices are retained on all copies.
13  * Permission to modify the code and to distribute modified code is granted,
14  * provided the above notices are retained, and a notice that the code was
15  * modified is included with the above copyright notice.
16  *
17  */
18 #ifndef _STLP_INTERNAL_IOS_H
19 #define _STLP_INTERNAL_IOS_H
20 
21 
22 #ifndef _STLP_IOS_BASE_H
23 # include <stl/_ios_base.h>
24 #endif
25 
26 #ifndef _STLP_INTERNAL_CTYPE_H
27 # include <stl/_ctype.h>
28 #endif
29 
30 #ifndef _STLP_INTERNAL_NUMPUNCT_H
31 # include <stl/_numpunct.h>
32 #endif
33 
35 
36 // ----------------------------------------------------------------------
37 
38 // Class basic_ios, a subclass of ios_base. The only important difference
39 // between the two is that basic_ios is a class template, parameterized
40 // by the character type. ios_base exists to factor out all of the
41 // common properties that don't depend on the character type.
42 
43 // The second template parameter, _Traits, defaults to char_traits<_CharT>.
44 // The default is declared in header <iosfwd>, and it isn't declared here
45 // because C++ language rules do not allow it to be declared twice.
46 
47 template <class _CharT, class _Traits>
48 class basic_ios : public ios_base {
49  friend class ios_base;
50 public: // Synonyms for types.
51  typedef _CharT char_type;
52  typedef typename _Traits::int_type int_type;
53  typedef typename _Traits::pos_type pos_type;
54  typedef typename _Traits::off_type off_type;
55  typedef _Traits traits_type;
56 
57 public: // Constructor, destructor.
58  explicit basic_ios(basic_streambuf<_CharT, _Traits>* __streambuf);
59  virtual ~basic_ios() {}
60 
61 public: // Members from clause 27.4.4.2
63  return _M_tied_ostream;
64  }
68  _M_tied_ostream = __new_tied_ostream;
69  return __tmp;
70  }
71 
73  { return _M_streambuf; }
74 
77 
78  // Copies __x's state to *this.
80 
81  char_type fill() const { return _M_fill; }
83  char_type __tmp(_M_fill);
84  _M_fill = __fill;
85  return __tmp;
86  }
87 
88 public: // Members from 27.4.4.3. These four functions
89  // can almost be defined in ios_base.
90 
91  void clear(iostate __state = goodbit) {
92  _M_clear_nothrow(this->rdbuf() ? __state : iostate(__state|ios_base::badbit));
94  }
95  void setstate(iostate __state) { this->clear(rdstate() | __state); }
96 
97  iostate exceptions() const { return this->_M_get_exception_mask(); }
98  void exceptions(iostate __mask) {
99  this->_M_set_exception_mask(__mask);
100  this->clear(this->rdstate());
101  }
102 
103 public: // Locale-related member functions.
104  locale imbue(const locale&);
105 
106  inline char narrow(_CharT, char) const ;
107  inline _CharT widen(char) const;
108 
109  // Helper function that makes testing for EOF more convenient.
110  static bool _STLP_CALL _S_eof(int_type __c) {
111  const int_type __eof = _Traits::eof();
112  return _Traits::eq_int_type(__c, __eof);
113  }
114 
115 protected:
116  // Cached copy of the curent locale's ctype facet. Set by init() and imbue().
118 
119 public:
120  // Equivalent to &use_facet< Facet >(getloc()), but faster.
122 
123 protected:
124  basic_ios();
125 
126  void init(basic_streambuf<_CharT, _Traits>* __streambuf);
127 
128 public:
129 
130  // Helper function used in istream and ostream. It is called only from
131  // a catch clause.
133 
134 private: // Data members
135  char_type _M_fill; // The fill character, used for padding.
136 
139 
140 };
141 
142 
143 template <class _CharT, class _Traits>
144 inline char
145 basic_ios<_CharT, _Traits>::narrow(_CharT __c, char __default) const
146 { return _M_ctype_facet()->narrow(__c, __default); }
147 
148 template <class _CharT, class _Traits>
149 inline _CharT
151 { return _M_ctype_facet()->widen(__c); }
152 
153 # if !defined (_STLP_NO_METHOD_SPECIALIZATION)
155 inline char
156 basic_ios<char, char_traits<char> >::narrow(char __c, char) const
157 {
158  return __c;
159 }
160 
162 inline char
163 basic_ios<char, char_traits<char> >::widen(char __c) const
164 {
165  return __c;
166 }
167 # endif /* _STLP_NO_METHOD_SPECIALIZATION */
168 
169 # if defined (_STLP_USE_TEMPLATE_EXPORT)
171 # if ! defined (_STLP_NO_WCHAR_T)
173 # endif
174 # endif /* _STLP_USE_TEMPLATE_EXPORT */
175 
177 
178 #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
179 # include <stl/_ios.c>
180 #endif
181 
182 #endif /* _STLP_IOS */
183 
184 // Local Variables:
185 // mode:C++
186 // End:
187 
static bool _STLP_CALL _S_eof(int_type __c)
Definition: _ios.h:110
void _M_clear_nothrow(iostate __state)
Definition: _ios_base.h:186
basic_streambuf< _CharT, _Traits > * _M_streambuf
Definition: _ios.h:137
basic_streambuf< _CharT, _Traits > * rdbuf() const
Definition: _ios.h:72
char_type fill() const
Definition: _ios.h:81
iostate rdstate() const
Definition: _ios_base.h:170
void _M_handle_exception(ios_base::iostate __flag)
Definition: _ios.c:114
void exceptions(iostate __mask)
Definition: _ios.h:98
#define __c
Definition: schilyio.h:209
locale imbue(const locale &)
Definition: _ios.c:69
_Traits::off_type off_type
Definition: _ios.h:54
char narrow(_CharT, char) const
Definition: _ios.h:145
Definition: _locale.h:75
const ctype< char_type > * _M_cached_ctype
Definition: _ios.h:117
void clear(iostate __state=goodbit)
Definition: _ios.h:91
_CharT widen(char) const
Definition: _ios.h:150
char_type fill(char_type __fill)
Definition: _ios.h:82
char_type _M_fill
Definition: _ios.h:135
Definition: _ios.h:48
basic_ios()
Definition: _ios.c:90
_Traits traits_type
Definition: _ios.h:55
basic_ios< _CharT, _Traits > & copyfmt(const basic_ios< _CharT, _Traits > &__x)
Definition: _ios.c:57
_Traits::int_type int_type
Definition: _ios.h:52
iostate exceptions() const
Definition: _ios.h:97
#define _STLP_EXPORT_TEMPLATE_CLASS
Definition: features.h:987
virtual ~basic_ios()
Definition: _ios.h:59
void _M_check_exception_mask()
Definition: _ios_base.h:189
int iostate
Definition: _ios_base.h:58
void init(basic_streambuf< _CharT, _Traits > *__streambuf)
Definition: _ios.c:97
basic_ostream< _CharT, _Traits > * _M_tied_ostream
Definition: _ios.h:138
void setstate(iostate __state)
Definition: _ios.h:95
#define _STLP_TEMPLATE_NULL
Definition: features.h:652
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
basic_ostream< _CharT, _Traits > * tie() const
Definition: _ios.h:62
basic_ostream< _CharT, _Traits > * tie(basic_ostream< char_type, traits_type > *__new_tied_ostream)
Definition: _ios.h:66
#define _STLP_END_NAMESPACE
Definition: features.h:503
const ctype< char_type > * _M_ctype_facet() const
Definition: _ios.h:121
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, const input_iterator_tag &, _Distance *)
Definition: _algobase.h:417
iostate _M_get_exception_mask() const
Definition: _ios_base.h:187
void _M_set_exception_mask(iostate __mask)
Definition: _ios_base.h:188
_CharT char_type
Definition: _ios.h:51
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_CALL
Definition: _bc.h:131
_Traits::pos_type pos_type
Definition: _ios.h:53