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.

181 lines
5.2 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. #ifdef __FORCE_INSTANCE
  92. template class _CRTIMP2 basic_ios<char, char_traits<char> >;
  93. template class _CRTIMP2 basic_ios<wchar_t, char_traits<wchar_t> >;
  94. #else // __FORCE_INSTANCE
  95. #pragma warning(disable:4231) /* the extern before template is a non-standard extension */
  96. extern template class _CRTIMP2 basic_ios<char, char_traits<char> >;
  97. extern template class _CRTIMP2 basic_ios<wchar_t, char_traits<wchar_t> >;
  98. #pragma warning(default:4231) /* restore previous warning */
  99. #endif // __FORCE_INSTANCE
  100. #endif // _DLL
  101. // MANIPULATORS
  102. inline ios_base& __cdecl boolalpha(ios_base& _I)
  103. {_I.setf(ios_base::boolalpha);
  104. return (_I); }
  105. inline ios_base& __cdecl dec(ios_base& _I)
  106. {_I.setf(ios_base::dec, ios_base::basefield);
  107. return (_I); }
  108. inline ios_base& __cdecl fixed(ios_base& _I)
  109. {_I.setf(ios_base::fixed, ios_base::floatfield);
  110. return (_I); }
  111. inline ios_base& __cdecl hex(ios_base& _I)
  112. {_I.setf(ios_base::hex, ios_base::basefield);
  113. return (_I); }
  114. inline ios_base& __cdecl internal(ios_base& _I)
  115. {_I.setf(ios_base::internal, ios_base::adjustfield);
  116. return (_I); }
  117. inline ios_base& __cdecl left(ios_base& _I)
  118. {_I.setf(ios_base::left, ios_base::adjustfield);
  119. return (_I); }
  120. inline ios_base& __cdecl noboolalpha(ios_base& _I)
  121. {_I.unsetf(ios_base::boolalpha);
  122. return (_I); }
  123. inline ios_base& __cdecl noshowbase(ios_base& _I)
  124. {_I.unsetf(ios_base::showbase);
  125. return (_I); }
  126. inline ios_base& __cdecl noshowpoint(ios_base& _I)
  127. {_I.unsetf(ios_base::showpoint);
  128. return (_I); }
  129. inline ios_base& __cdecl noshowpos(ios_base& _I)
  130. {_I.unsetf(ios_base::showpos);
  131. return (_I); }
  132. inline ios_base& __cdecl noskipws(ios_base& _I)
  133. {_I.unsetf(ios_base::skipws);
  134. return (_I); }
  135. inline ios_base& __cdecl nounitbuf(ios_base& _I)
  136. {_I.unsetf(ios_base::unitbuf);
  137. return (_I); }
  138. inline ios_base& __cdecl nouppercase(ios_base& _I)
  139. {_I.unsetf(ios_base::uppercase);
  140. return (_I); }
  141. inline ios_base& __cdecl oct(ios_base& _I)
  142. {_I.setf(ios_base::oct, ios_base::basefield);
  143. return (_I); }
  144. inline ios_base& __cdecl right(ios_base& _I)
  145. {_I.setf(ios_base::right, ios_base::adjustfield);
  146. return (_I); }
  147. inline ios_base& __cdecl scientific(ios_base& _I)
  148. {_I.setf(ios_base::scientific, ios_base::floatfield);
  149. return (_I); }
  150. inline ios_base& __cdecl showbase(ios_base& _I)
  151. {_I.setf(ios_base::showbase);
  152. return (_I); }
  153. inline ios_base& __cdecl showpoint(ios_base& _I)
  154. {_I.setf(ios_base::showpoint);
  155. return (_I); }
  156. inline ios_base& __cdecl showpos(ios_base& _I)
  157. {_I.setf(ios_base::showpos);
  158. return (_I); }
  159. inline ios_base& __cdecl skipws(ios_base& _I)
  160. {_I.setf(ios_base::skipws);
  161. return (_I); }
  162. inline ios_base& __cdecl unitbuf(ios_base& _I)
  163. {_I.setf(ios_base::unitbuf);
  164. return (_I); }
  165. inline ios_base& __cdecl uppercase(ios_base& _I)
  166. {_I.setf(ios_base::uppercase);
  167. return (_I); }
  168. _STD_END
  169. #ifdef _MSC_VER
  170. #pragma pack(pop)
  171. #endif /* _MSC_VER */
  172. #endif /* _IOS_ */
  173. /*
  174. * Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
  175. * Consult your license regarding permissions and restrictions.
  176. */