Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygen_ios.h
Go to the documentation of this file.
00001 /* 00002 * Copyright (c) 1999 00003 * Silicon Graphics Computer Systems, Inc. 00004 * 00005 * Copyright (c) 1999 00006 * Boris Fomitchev 00007 * 00008 * This material is provided "as is", with absolutely no warranty expressed 00009 * or implied. Any use is at your own risk. 00010 * 00011 * Permission to use or copy this software for any purpose is hereby granted 00012 * without fee, provided the above notices are retained on all copies. 00013 * Permission to modify the code and to distribute modified code is granted, 00014 * provided the above notices are retained, and a notice that the code was 00015 * modified is included with the above copyright notice. 00016 * 00017 */ 00018 #ifndef _STLP_INTERNAL_IOS_H 00019 #define _STLP_INTERNAL_IOS_H 00020 00021 00022 #ifndef _STLP_IOS_BASE_H 00023 # include <stl/_ios_base.h> 00024 #endif 00025 00026 #ifndef _STLP_INTERNAL_CTYPE_H 00027 # include <stl/_ctype.h> 00028 #endif 00029 00030 #ifndef _STLP_INTERNAL_NUMPUNCT_H 00031 # include <stl/_numpunct.h> 00032 #endif 00033 00034 _STLP_BEGIN_NAMESPACE 00035 00036 // ---------------------------------------------------------------------- 00037 00038 // Class basic_ios, a subclass of ios_base. The only important difference 00039 // between the two is that basic_ios is a class template, parameterized 00040 // by the character type. ios_base exists to factor out all of the 00041 // common properties that don't depend on the character type. 00042 00043 // The second template parameter, _Traits, defaults to char_traits<_CharT>. 00044 // The default is declared in header <iosfwd>, and it isn't declared here 00045 // because C++ language rules do not allow it to be declared twice. 00046 00047 template <class _CharT, class _Traits> 00048 class basic_ios : public ios_base { 00049 friend class ios_base; 00050 public: // Synonyms for types. 00051 typedef _CharT char_type; 00052 typedef typename _Traits::int_type int_type; 00053 typedef typename _Traits::pos_type pos_type; 00054 typedef typename _Traits::off_type off_type; 00055 typedef _Traits traits_type; 00056 00057 public: // Constructor, destructor. 00058 explicit basic_ios(basic_streambuf<_CharT, _Traits>* __streambuf); 00059 virtual ~basic_ios() {} 00060 00061 public: // Members from clause 27.4.4.2 00062 basic_ostream<_CharT, _Traits>* tie() const { 00063 return _M_tied_ostream; 00064 } 00065 basic_ostream<_CharT, _Traits>* 00066 tie(basic_ostream<char_type, traits_type>* __new_tied_ostream) { 00067 basic_ostream<char_type, traits_type>* __tmp = _M_tied_ostream; 00068 _M_tied_ostream = __new_tied_ostream; 00069 return __tmp; 00070 } 00071 00072 basic_streambuf<_CharT, _Traits>* rdbuf() const 00073 { return _M_streambuf; } 00074 00075 basic_streambuf<_CharT, _Traits>* 00076 rdbuf(basic_streambuf<char_type, traits_type>*); 00077 00078 // Copies __x's state to *this. 00079 basic_ios<_CharT, _Traits>& copyfmt(const basic_ios<_CharT, _Traits>& __x); 00080 00081 char_type fill() const { return _M_fill; } 00082 char_type fill(char_type __fill) { 00083 char_type __tmp(_M_fill); 00084 _M_fill = __fill; 00085 return __tmp; 00086 } 00087 00088 public: // Members from 27.4.4.3. These four functions 00089 // can almost be defined in ios_base. 00090 00091 void clear(iostate __state = goodbit) { 00092 _M_clear_nothrow(this->rdbuf() ? __state : iostate(__state|ios_base::badbit)); 00093 _M_check_exception_mask(); 00094 } 00095 void setstate(iostate __state) { this->clear(rdstate() | __state); } 00096 00097 iostate exceptions() const { return this->_M_get_exception_mask(); } 00098 void exceptions(iostate __mask) { 00099 this->_M_set_exception_mask(__mask); 00100 this->clear(this->rdstate()); 00101 } 00102 00103 public: // Locale-related member functions. 00104 locale imbue(const locale&); 00105 00106 inline char narrow(_CharT, char) const ; 00107 inline _CharT widen(char) const; 00108 00109 // Helper function that makes testing for EOF more convenient. 00110 static bool _STLP_CALL _S_eof(int_type __c) { 00111 const int_type __eof = _Traits::eof(); 00112 return _Traits::eq_int_type(__c, __eof); 00113 } 00114 00115 protected: 00116 // Cached copy of the curent locale's ctype facet. Set by init() and imbue(). 00117 const ctype<char_type>* _M_cached_ctype; 00118 00119 public: 00120 // Equivalent to &use_facet< Facet >(getloc()), but faster. 00121 const ctype<char_type>* _M_ctype_facet() const { return _M_cached_ctype; } 00122 00123 protected: 00124 basic_ios(); 00125 00126 void init(basic_streambuf<_CharT, _Traits>* __streambuf); 00127 00128 public: 00129 00130 // Helper function used in istream and ostream. It is called only from 00131 // a catch clause. 00132 void _M_handle_exception(ios_base::iostate __flag); 00133 00134 private: // Data members 00135 char_type _M_fill; // The fill character, used for padding. 00136 00137 basic_streambuf<_CharT, _Traits>* _M_streambuf; 00138 basic_ostream<_CharT, _Traits>* _M_tied_ostream; 00139 00140 }; 00141 00142 00143 template <class _CharT, class _Traits> 00144 inline char 00145 basic_ios<_CharT, _Traits>::narrow(_CharT __c, char __default) const 00146 { return _M_ctype_facet()->narrow(__c, __default); } 00147 00148 template <class _CharT, class _Traits> 00149 inline _CharT 00150 basic_ios<_CharT, _Traits>::widen(char __c) const 00151 { return _M_ctype_facet()->widen(__c); } 00152 00153 # if !defined (_STLP_NO_METHOD_SPECIALIZATION) 00154 _STLP_TEMPLATE_NULL 00155 inline char 00156 basic_ios<char, char_traits<char> >::narrow(char __c, char) const 00157 { 00158 return __c; 00159 } 00160 00161 _STLP_TEMPLATE_NULL 00162 inline char 00163 basic_ios<char, char_traits<char> >::widen(char __c) const 00164 { 00165 return __c; 00166 } 00167 # endif /* _STLP_NO_METHOD_SPECIALIZATION */ 00168 00169 # if defined (_STLP_USE_TEMPLATE_EXPORT) 00170 _STLP_EXPORT_TEMPLATE_CLASS basic_ios<char, char_traits<char> >; 00171 # if ! defined (_STLP_NO_WCHAR_T) 00172 _STLP_EXPORT_TEMPLATE_CLASS basic_ios<wchar_t, char_traits<wchar_t> >; 00173 # endif 00174 # endif /* _STLP_USE_TEMPLATE_EXPORT */ 00175 00176 _STLP_END_NAMESPACE 00177 00178 #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) 00179 # include <stl/_ios.c> 00180 #endif 00181 00182 #endif /* _STLP_IOS */ 00183 00184 // Local Variables: 00185 // mode:C++ 00186 // End: 00187 Generated on Fri May 25 2012 04:27:41 for ReactOS by
1.7.6.1
|