Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
5.0 KiB

  1. // ios standard header
  2. #ifndef _IOS_
  3. #define _IOS_
  4. #include <streambuf>
  5. #ifdef _MSC_VER
  6. #pragma pack(push,8)
  7. #endif /* _MSC_VER */
  8. _STD_BEGIN
  9. // TEMPLATE CLASS basic_ios
  10. template<class _E, class _Tr /* = char_traits<_E> */ >
  11. class basic_ios : public ios_base {
  12. public:
  13. typedef basic_ios<_E, _Tr> _Myt;
  14. typedef basic_ostream<_E, _Tr> _Myos;
  15. typedef basic_streambuf<_E, _Tr> _Mysb;
  16. typedef ctype<_E> _Ctype;
  17. explicit basic_ios(_Mysb *_S)
  18. {init(_S); }
  19. basic_ios(const _Myt& _R)
  20. {init(0), *this = _R; }
  21. virtual ~basic_ios()
  22. {}
  23. typedef _E char_type;
  24. typedef _Tr traits_type;
  25. typedef typename _Tr::int_type int_type;
  26. typedef typename _Tr::pos_type pos_type;
  27. typedef typename _Tr::off_type off_type;
  28. void clear(iostate _St = goodbit, bool _Ex = false)
  29. {ios_base::clear(_Sb == 0 ? (int)_St | (int)badbit
  30. : (int)_St, _Ex); }
  31. void clear(io_state _St)
  32. {clear((iostate)_St); }
  33. void setstate(iostate _St, bool _Ex = false)
  34. {if (_St != goodbit)
  35. clear((iostate)((int)rdstate() | (int)_St), _Ex); }
  36. void setstate(io_state _St)
  37. {setstate((iostate)_St); }
  38. _Myt& copyfmt(const _Myt& _R)
  39. {_Tiestr = _R.tie();
  40. _Fillch = _R.fill();
  41. ios_base::copyfmt(_R);
  42. return (*this); }
  43. _Myos *tie() const
  44. {return (_Tiestr); }
  45. _Myos *tie(_Myos *_N)
  46. {_Myos *_O = _Tiestr;
  47. _Tiestr = _N;
  48. return (_O); }
  49. _Mysb *rdbuf() const
  50. {return (_Sb); }
  51. _Mysb *rdbuf(_Mysb *_N)
  52. {_Mysb *_O = _Sb;
  53. _Sb = _N;
  54. clear();
  55. return (_O); }
  56. locale imbue(const locale& _Ln)
  57. {if (rdbuf() != 0)
  58. rdbuf()->pubimbue(_Ln);
  59. return (ios_base::imbue(_Ln)); }
  60. _E fill() const
  61. {return (_Fillch); }
  62. _E fill(_E _Nf)
  63. {_E _Of = _Fillch;
  64. _Fillch = _Nf;
  65. return (_Of); }
  66. char narrow(_E _C, char _D = '\0') const
  67. {const _Ctype& _Fac = _USE(getloc(), _Ctype);
  68. return (_Fac.narrow(_C, _D)); }
  69. _E widen(char _C) const
  70. {const _Ctype& _Fac = _USE(getloc(), _Ctype);
  71. return (_Fac.widen(_C)); }
  72. protected:
  73. void init(_Mysb *_S = 0,
  74. bool _Isstd = false)
  75. {_Sb = _S;
  76. _Tiestr = 0;
  77. _Fillch = _WIDEN(_E, ' ');
  78. _Init();
  79. if (_Sb == 0)
  80. setstate(badbit);
  81. if (_Isstd)
  82. _Addstd(); }
  83. basic_ios()
  84. {}
  85. private:
  86. _Mysb *_Sb;
  87. _Myos *_Tiestr;
  88. _E _Fillch;
  89. };
  90. #ifdef _DLL
  91. #pragma warning(disable:4231) /* the extern before template is a non-standard extension */
  92. extern template class _CRTIMP basic_ios<char, char_traits<char> >;
  93. extern template class _CRTIMP basic_ios<wchar_t, char_traits<wchar_t> >;
  94. #pragma warning(default:4231) /* restore previous warning */
  95. #endif // _DLL
  96. // MANIPULATORS
  97. inline ios_base& __cdecl boolalpha(ios_base& _I)
  98. {_I.setf(ios_base::boolalpha);
  99. return (_I); }
  100. inline ios_base& __cdecl dec(ios_base& _I)
  101. {_I.setf(ios_base::dec, ios_base::basefield);
  102. return (_I); }
  103. inline ios_base& __cdecl fixed(ios_base& _I)
  104. {_I.setf(ios_base::fixed, ios_base::floatfield);
  105. return (_I); }
  106. inline ios_base& __cdecl hex(ios_base& _I)
  107. {_I.setf(ios_base::hex, ios_base::basefield);
  108. return (_I); }
  109. inline ios_base& __cdecl internal(ios_base& _I)
  110. {_I.setf(ios_base::internal, ios_base::adjustfield);
  111. return (_I); }
  112. inline ios_base& __cdecl left(ios_base& _I)
  113. {_I.setf(ios_base::left, ios_base::adjustfield);
  114. return (_I); }
  115. inline ios_base& __cdecl noboolalpha(ios_base& _I)
  116. {_I.unsetf(ios_base::boolalpha);
  117. return (_I); }
  118. inline ios_base& __cdecl noshowbase(ios_base& _I)
  119. {_I.unsetf(ios_base::showbase);
  120. return (_I); }
  121. inline ios_base& __cdecl noshowpoint(ios_base& _I)
  122. {_I.unsetf(ios_base::showpoint);
  123. return (_I); }
  124. inline ios_base& __cdecl noshowpos(ios_base& _I)
  125. {_I.unsetf(ios_base::showpos);
  126. return (_I); }
  127. inline ios_base& __cdecl noskipws(ios_base& _I)
  128. {_I.unsetf(ios_base::skipws);
  129. return (_I); }
  130. inline ios_base& __cdecl nounitbuf(ios_base& _I)
  131. {_I.unsetf(ios_base::unitbuf);
  132. return (_I); }
  133. inline ios_base& __cdecl nouppercase(ios_base& _I)
  134. {_I.unsetf(ios_base::uppercase);
  135. return (_I); }
  136. inline ios_base& __cdecl oct(ios_base& _I)
  137. {_I.setf(ios_base::oct, ios_base::basefield);
  138. return (_I); }
  139. inline ios_base& __cdecl right(ios_base& _I)
  140. {_I.setf(ios_base::right, ios_base::adjustfield);
  141. return (_I); }
  142. inline ios_base& __cdecl scientific(ios_base& _I)
  143. {_I.setf(ios_base::scientific, ios_base::floatfield);
  144. return (_I); }
  145. inline ios_base& __cdecl showbase(ios_base& _I)
  146. {_I.setf(ios_base::showbase);
  147. return (_I); }
  148. inline ios_base& __cdecl showpoint(ios_base& _I)
  149. {_I.setf(ios_base::showpoint);
  150. return (_I); }
  151. inline ios_base& __cdecl showpos(ios_base& _I)
  152. {_I.setf(ios_base::showpos);
  153. return (_I); }
  154. inline ios_base& __cdecl skipws(ios_base& _I)
  155. {_I.setf(ios_base::skipws);
  156. return (_I); }
  157. inline ios_base& __cdecl unitbuf(ios_base& _I)
  158. {_I.setf(ios_base::unitbuf);
  159. return (_I); }
  160. inline ios_base& __cdecl uppercase(ios_base& _I)
  161. {_I.setf(ios_base::uppercase);
  162. return (_I); }
  163. _STD_END
  164. #ifdef _MSC_VER
  165. #pragma pack(pop)
  166. #endif /* _MSC_VER */
  167. #endif /* _IOS_ */
  168. /*
  169. * Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
  170. * Consult your license regarding permissions and restrictions.
  171. */