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.

522 lines
15 KiB

  1. // iosfwd standard header
  2. #pragma once
  3. #ifndef _IOSFWD_
  4. #define _IOSFWD_
  5. #include <cstdio>
  6. #include <cstring>
  7. #include <cwchar>
  8. #include <xstddef>
  9. #pragma pack(push,8)
  10. #pragma warning(push,3)
  11. _STD_BEGIN
  12. // STREAM POSITIONING TYPES (from <streambuf>)
  13. #ifdef _WIN64
  14. typedef __int64 streamoff;
  15. typedef __int64 streamsize;
  16. #else
  17. typedef long streamoff;
  18. typedef int streamsize;
  19. #endif
  20. extern _CRTIMP2 fpos_t _Fpz;
  21. extern _CRTIMP2 const streamoff _BADOFF;
  22. // TEMPLATE CLASS fpos (from <streambuf>)
  23. template<class _Statetype>
  24. class fpos
  25. { // store arbitrary file position
  26. typedef fpos<_Statetype> _Myt;
  27. public:
  28. fpos(streamoff _Off = 0)
  29. : _Myoff(_Off), _Fpos(_Fpz), _Mystate(_Stz)
  30. { // construct with stream offset
  31. }
  32. fpos(_Statetype _State, fpos_t _Fileposition)
  33. : _Myoff(0), _Fpos(_Fileposition), _Mystate(_State)
  34. { // construct with conversion state and C file position
  35. }
  36. _Statetype state() const
  37. { // return conversion state
  38. return (_Mystate);
  39. }
  40. void state(_Statetype _State)
  41. { // set conversion state
  42. _Mystate = _State;
  43. }
  44. fpos_t seekpos() const
  45. { // return C file position
  46. return (_Fpos);
  47. }
  48. operator streamoff() const
  49. { // return offset
  50. return (_Myoff + _FPOSOFF(_Fpos));
  51. }
  52. streamoff operator-(const _Myt& _Right) const
  53. { // return difference of file positions as an offset
  54. return ((streamoff)*this - (streamoff)_Right);
  55. }
  56. _Myt& operator+=(streamoff _Off)
  57. { // add offset
  58. _Myoff += _Off;
  59. return (*this);
  60. }
  61. _Myt& operator-=(streamoff _Off)
  62. { // subtract offset
  63. _Myoff -= _Off;
  64. return (*this);
  65. }
  66. _Myt operator+(streamoff _Off) const
  67. { // return this + offset
  68. _Myt _Tmp = *this;
  69. return (_Tmp += _Off);
  70. }
  71. _Myt operator-(streamoff _Off) const
  72. { // return this - offset
  73. _Myt _Tmp = *this;
  74. return (_Tmp -= _Off);
  75. }
  76. bool operator==(const _Myt& _Right) const
  77. { // test for file position equality
  78. return ((streamoff)*this == (streamoff)_Right);
  79. }
  80. bool operator!=(const _Myt& _Right) const
  81. { // test for file position inequality
  82. return (!(*this == _Right));
  83. }
  84. private:
  85. static _Statetype _Stz; // initial conversion state
  86. streamoff _Myoff; // stream offset
  87. fpos_t _Fpos; // C file position
  88. _Statetype _Mystate; // current conversion state
  89. };
  90. // STATIC fpos::_Stz OBJECT
  91. template<class _Statetype>
  92. _Statetype fpos<_Statetype>::_Stz;
  93. typedef fpos<mbstate_t> streampos;
  94. typedef streampos wstreampos;
  95. // TEMPLATE STRUCT char_traits (FROM <string>)
  96. template<class _Elem>
  97. struct char_traits
  98. { // properties of a string or stream element
  99. typedef _Elem char_type;
  100. typedef _Elem int_type;
  101. typedef streampos pos_type;
  102. typedef streamoff off_type;
  103. typedef mbstate_t state_type;
  104. static void __cdecl assign(_Elem& _Left, const _Elem& _Right)
  105. { // assign an element
  106. _Left = _Right;
  107. }
  108. static bool __cdecl eq(const _Elem& _Left, const _Elem& _Right)
  109. { // test for element equality
  110. return (_Left == _Right);
  111. }
  112. static bool __cdecl lt(const _Elem& _Left, const _Elem& _Right)
  113. { // test if _Left precedes _Right
  114. return (_Left < _Right);
  115. }
  116. static int __cdecl compare(const _Elem *_First1, const _Elem *_First2,
  117. size_t _Count)
  118. { // compare [_First1, _First1 + _Count) with [_First2, ...)
  119. for (; 0 < _Count; --_Count, ++_First1, ++_First2)
  120. if (!eq(*_First1, *_First2))
  121. return (lt(*_First1, *_First2) ? -1 : +1);
  122. return (0);
  123. }
  124. static size_t __cdecl length(const _Elem *_First)
  125. { // find length of null-terminated sequence
  126. size_t _Count;
  127. for (_Count = 0; !eq(*_First, _Elem()); ++_First)
  128. ++_Count;
  129. return (_Count);
  130. }
  131. static _Elem *__cdecl copy(_Elem *_First1, const _Elem *_First2,
  132. size_t _Count)
  133. { // copy [_First1, _First1 + _Count) to [_First2, ...)
  134. _Elem *_Next = _First1;
  135. for (; 0 < _Count; --_Count, ++_Next, ++_First2)
  136. assign(*_Next, *_First2);
  137. return (_First1);
  138. }
  139. static const _Elem *__cdecl find(const _Elem *_First, size_t _Count,
  140. const _Elem& _Ch)
  141. { // look for _Ch in [_First, _First + _Count)
  142. for (; 0 < _Count; --_Count, ++_First)
  143. if (eq(*_First, _Ch))
  144. return (_First);
  145. return (0);
  146. }
  147. static _Elem *__cdecl move(_Elem *_First1, const _Elem *_First2,
  148. size_t _Count)
  149. { // copy [_First1, _First1 + _Count) to [_First2, ...)
  150. _Elem *_Next = _First1;
  151. if (_First2 < _Next && _Next < _First2 + _Count)
  152. for (_Next += _Count, _First2 += _Count; 0 < _Count; --_Count)
  153. assign(*--_Next, *--_First2);
  154. else
  155. for (; 0 < _Count; --_Count, ++_Next, ++_First2)
  156. assign(*_Next, *_First2);
  157. return (_First1);
  158. }
  159. static _Elem *__cdecl assign(_Elem *_First, size_t _Count, _Elem _Ch)
  160. { // assign _Count * _Ch to [_First, ...)
  161. _Elem *_Next = _First;
  162. for (; 0 < _Count; --_Count, ++_Next)
  163. assign(*_Next, _Ch);
  164. return (_First);
  165. }
  166. static _Elem __cdecl to_char_type(const int_type& _Meta)
  167. { // convert metacharacter to character
  168. return (_Meta);
  169. }
  170. static int_type __cdecl to_int_type(const _Elem& _Ch)
  171. { // convert character to metacharacter
  172. return (_Ch);
  173. }
  174. static bool __cdecl eq_int_type(const int_type& _Left,
  175. const int_type& _Right)
  176. { // test for metacharacter equality
  177. return (_Left == _Right);
  178. }
  179. static int_type __cdecl eof()
  180. { // return end-of-file metacharacter
  181. return ((int_type)EOF);
  182. }
  183. static int_type __cdecl not_eof(const int_type& _Meta)
  184. { // return anything but EOF
  185. return (_Meta != eof() ? _Meta : !eof());
  186. }
  187. };
  188. // STRUCT char_traits<wchar_t>
  189. template<> struct _CRTIMP2 char_traits<wchar_t>
  190. { // properties of a string or stream wchar_t element
  191. typedef wchar_t _Elem;
  192. typedef _Elem char_type; // for overloads
  193. typedef wint_t int_type;
  194. typedef streampos pos_type;
  195. typedef streamoff off_type;
  196. typedef mbstate_t state_type;
  197. static void __cdecl assign(_Elem& _Left, const _Elem& _Right)
  198. { // assign an element
  199. _Left = _Right;
  200. }
  201. static bool __cdecl eq(const _Elem& _Left, const _Elem& _Right)
  202. { // test for element equality
  203. return (_Left == _Right);
  204. }
  205. static bool __cdecl lt(const _Elem& _Left, const _Elem& _Right)
  206. { // test if _Left precedes _Right
  207. return (_Left < _Right);
  208. }
  209. static int __cdecl compare(const _Elem *_First1, const _Elem *_First2,
  210. size_t _Count)
  211. { // compare [_First1, _First1 + _Count) with [_First2, ...)
  212. return (::wmemcmp(_First1, _First2, _Count));
  213. }
  214. static size_t __cdecl length(const _Elem *_First)
  215. { // find length of null-terminated sequence
  216. return (::wcslen(_First));
  217. }
  218. static _Elem *__cdecl copy(_Elem *_First1, const _Elem *_First2,
  219. size_t _Count)
  220. { // copy [_First1, _First1 + _Count) to [_First2, ...)
  221. return (::wmemcpy(_First1, _First2, _Count));
  222. }
  223. static const _Elem *__cdecl find(const _Elem *_First, size_t _Count,
  224. const _Elem& _Ch)
  225. { // look for _Ch in [_First, _First + _Count)
  226. return ((const _Elem *)::wmemchr(_First, _Ch, _Count));
  227. }
  228. static _Elem *__cdecl move(_Elem *_First1, const _Elem *_First2,
  229. size_t _Count)
  230. { // copy [_First1, _First1 + _Count) to [_First2, ...)
  231. return (::wmemmove(_First1, _First2, _Count));
  232. }
  233. static _Elem *__cdecl assign(_Elem *_First, size_t _Count, _Elem _Ch)
  234. { // assign _Count * _Ch to [_First, ...)
  235. return (::wmemset(_First, _Ch, _Count));
  236. }
  237. static _Elem __cdecl to_char_type(const int_type& _Meta)
  238. { // convert metacharacter to character
  239. return (_Meta);
  240. }
  241. static int_type __cdecl to_int_type(const _Elem& _Ch)
  242. { // convert character to metacharacter
  243. return (_Ch);
  244. }
  245. static bool __cdecl eq_int_type(const int_type& _Left,
  246. const int_type& _Right)
  247. { // test for metacharacter equality
  248. return (_Left == _Right);
  249. }
  250. static int_type __cdecl eof()
  251. { // return end-of-file metacharacter
  252. return (WEOF);
  253. }
  254. static int_type __cdecl not_eof(const int_type& _Meta)
  255. { // return anything but EOF
  256. return (_Meta != eof() ? _Meta : !eof());
  257. }
  258. };
  259. // STRUCT char_traits<char> (FROM <string>)
  260. template<> struct _CRTIMP2 char_traits<char>
  261. { // properties of a string or stream char element
  262. typedef char _Elem;
  263. typedef _Elem char_type;
  264. typedef int int_type;
  265. typedef streampos pos_type;
  266. typedef streamoff off_type;
  267. typedef mbstate_t state_type;
  268. static void __cdecl assign(_Elem& _Left, const _Elem& _Right)
  269. { // assign an element
  270. _Left = _Right;
  271. }
  272. static bool __cdecl eq(const _Elem& _Left, const _Elem& _Right)
  273. { // test for element equality
  274. return (_Left == _Right);
  275. }
  276. static bool __cdecl lt(const _Elem& _Left, const _Elem& _Right)
  277. { // test if _Left precedes _Right
  278. return (_Left < _Right);
  279. }
  280. static int __cdecl compare(const _Elem *_First1, const _Elem *_First2,
  281. size_t _Count)
  282. { // compare [_First1, _First1 + _Count) with [_First2, ...)
  283. return (::memcmp(_First1, _First2, _Count));
  284. }
  285. static size_t __cdecl length(const _Elem *_First)
  286. { // find length of null-terminated string
  287. return (::strlen(_First));
  288. }
  289. static _Elem *__cdecl copy(_Elem *_First1, const _Elem *_First2,
  290. size_t _Count)
  291. { // copy [_First1, _First1 + _Count) to [_First2, ...)
  292. return ((_Elem *)::memcpy(_First1, _First2, _Count));
  293. }
  294. static const _Elem *__cdecl find(const _Elem *_First, size_t _Count,
  295. const _Elem& _Ch)
  296. { // look for _Ch in [_First, _First + _Count)
  297. return ((const _Elem *)::memchr(_First, _Ch, _Count));
  298. }
  299. static _Elem *__cdecl move(_Elem *_First1, const _Elem *_First2,
  300. size_t _Count)
  301. { // copy [_First1, _First1 + _Count) to [_First2, ...)
  302. return ((_Elem *)::memmove(_First1, _First2, _Count));
  303. }
  304. static _Elem *__cdecl assign(_Elem *_First, size_t _Count, _Elem _Ch)
  305. { // assign _Count * _Ch to [_First, ...)
  306. return ((_Elem *)::memset(_First, _Ch, _Count));
  307. }
  308. static _Elem __cdecl to_char_type(const int_type& _Meta)
  309. { // convert metacharacter to character
  310. return ((_Elem)_Meta);
  311. }
  312. static int_type __cdecl to_int_type(const _Elem& _Ch)
  313. { // convert character to metacharacter
  314. return ((unsigned char)_Ch);
  315. }
  316. static bool __cdecl eq_int_type(const int_type& _Left,
  317. const int_type& _Right)
  318. { // test for metacharacter equality
  319. return (_Left == _Right);
  320. }
  321. static int_type __cdecl eof()
  322. { // return end-of-file metacharacter
  323. return (EOF);
  324. }
  325. static int_type __cdecl not_eof(const int_type& _Meta)
  326. { // return anything but EOF
  327. return (_Meta != eof() ? _Meta : !eof());
  328. }
  329. };
  330. // FORWARD REFERENCES
  331. template<class _Ty>
  332. class allocator;
  333. class ios_base;
  334. template<class _Elem,
  335. class _Traits = char_traits<_Elem> >
  336. class basic_ios;
  337. template<class _Elem,
  338. class _Traits = char_traits<_Elem> >
  339. class istreambuf_iterator;
  340. template<class _Elem,
  341. class _Traits = char_traits<_Elem> >
  342. class ostreambuf_iterator;
  343. template<class _Elem,
  344. class _Traits = char_traits<_Elem> >
  345. class basic_streambuf;
  346. template<class _Elem,
  347. class _Traits = char_traits<_Elem> >
  348. class basic_istream;
  349. template<class _Elem,
  350. class _Traits = char_traits<_Elem> >
  351. class basic_ostream;
  352. template<class _Elem,
  353. class _Traits = char_traits<_Elem> >
  354. class basic_iostream;
  355. template<class _Elem,
  356. class _Traits = char_traits<_Elem>,
  357. class _Alloc = allocator<_Elem> >
  358. class basic_stringbuf;
  359. template<class _Elem,
  360. class _Traits = char_traits<_Elem>,
  361. class _Alloc = allocator<_Elem> >
  362. class basic_istringstream;
  363. template<class _Elem,
  364. class _Traits = char_traits<_Elem>,
  365. class _Alloc = allocator<_Elem> >
  366. class basic_ostringstream;
  367. template<class _Elem,
  368. class _Traits = char_traits<_Elem>,
  369. class _Alloc = allocator<_Elem> >
  370. class basic_stringstream;
  371. template<class _Elem,
  372. class _Traits = char_traits<_Elem> >
  373. class basic_filebuf;
  374. template<class _Elem,
  375. class _Traits = char_traits<_Elem> >
  376. class basic_ifstream;
  377. template<class _Elem,
  378. class _Traits = char_traits<_Elem> >
  379. class basic_ofstream;
  380. template<class _Elem,
  381. class _Traits = char_traits<_Elem> >
  382. class basic_fstream;
  383. #ifdef _DLL_CPPLIB
  384. template<class _Elem,
  385. class _InIt >
  386. class num_get;
  387. template<class _Elem,
  388. class _OutIt >
  389. class num_put;
  390. template<class _Elem>
  391. class collate;
  392. #endif // _DLL_CPPLIB
  393. // char TYPEDEFS
  394. typedef basic_ios<char, char_traits<char> > ios;
  395. typedef basic_streambuf<char, char_traits<char> > streambuf;
  396. typedef basic_istream<char, char_traits<char> > istream;
  397. typedef basic_ostream<char, char_traits<char> > ostream;
  398. typedef basic_iostream<char, char_traits<char> > iostream;
  399. typedef basic_stringbuf<char, char_traits<char>,
  400. allocator<char> > stringbuf;
  401. typedef basic_istringstream<char, char_traits<char>,
  402. allocator<char> > istringstream;
  403. typedef basic_ostringstream<char, char_traits<char>,
  404. allocator<char> > ostringstream;
  405. typedef basic_stringstream<char, char_traits<char>,
  406. allocator<char> > stringstream;
  407. typedef basic_filebuf<char, char_traits<char> > filebuf;
  408. typedef basic_ifstream<char, char_traits<char> > ifstream;
  409. typedef basic_ofstream<char, char_traits<char> > ofstream;
  410. typedef basic_fstream<char, char_traits<char> > fstream;
  411. // wchat_t TYPEDEFS
  412. typedef basic_ios<wchar_t, char_traits<wchar_t> > wios;
  413. typedef basic_streambuf<wchar_t, char_traits<wchar_t> >
  414. wstreambuf;
  415. typedef basic_istream<wchar_t, char_traits<wchar_t> > wistream;
  416. typedef basic_ostream<wchar_t, char_traits<wchar_t> > wostream;
  417. typedef basic_iostream<wchar_t, char_traits<wchar_t> > wiostream;
  418. typedef basic_stringbuf<wchar_t, char_traits<wchar_t>,
  419. allocator<wchar_t> > wstringbuf;
  420. typedef basic_istringstream<wchar_t, char_traits<wchar_t>,
  421. allocator<wchar_t> > wistringstream;
  422. typedef basic_ostringstream<wchar_t, char_traits<wchar_t>,
  423. allocator<wchar_t> > wostringstream;
  424. typedef basic_stringstream<wchar_t, char_traits<wchar_t>,
  425. allocator<wchar_t> > wstringstream;
  426. typedef basic_filebuf<wchar_t, char_traits<wchar_t> > wfilebuf;
  427. typedef basic_ifstream<wchar_t, char_traits<wchar_t> > wifstream;
  428. typedef basic_ofstream<wchar_t, char_traits<wchar_t> > wofstream;
  429. typedef basic_fstream<wchar_t, char_traits<wchar_t> > wfstream;
  430. #ifdef _DLL_CPPLIB
  431. typedef num_get<char, istreambuf_iterator<char, char_traits<char> > >
  432. numget;
  433. typedef num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >
  434. wnumget;
  435. typedef num_put<char, ostreambuf_iterator<char, char_traits<char> > >
  436. numput;
  437. typedef num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >
  438. wnumput;
  439. typedef collate<char> ncollate;
  440. typedef collate<wchar_t> wcollate;
  441. #endif // _DLL_CPPLIB
  442. _STD_END
  443. #pragma warning(pop)
  444. #pragma pack(pop)
  445. #endif /* _IOSFWD_ */
  446. /*
  447. * Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
  448. * Consult your license regarding permissions and restrictions.
  449. V3.10:0009 */