home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / iosfwd < prev    next >
Text File  |  1998-06-16  |  13KB  |  321 lines

  1. // iosfwd standard header
  2.  
  3. #if     _MSC_VER > 1000
  4. #pragma once
  5. #endif
  6.  
  7. #ifndef _IOSFWD_
  8. #define _IOSFWD_
  9. #include <cstdio>
  10. #include <cstring>
  11. #include <cwchar>
  12. #include <xstddef>
  13.  
  14. #ifdef  _MSC_VER
  15. #pragma pack(push,8)
  16. #endif  /* _MSC_VER */
  17. _STD_BEGIN
  18.                 // STREAM POSITIONING TYPES (from <streambuf>)
  19. typedef long streamoff;
  20. const streamoff _BADOFF = -1;
  21. typedef int streamsize;
  22. extern _CRTIMP const fpos_t _Fpz;
  23.                 // TEMPLATE CLASS fpos (from <streambuf>)
  24. template<class _St>
  25.         class fpos {
  26.         typedef fpos<_St> _Myt;
  27. public:
  28. #ifdef  _MT
  29.         fpos(streamoff _O = 0)
  30.                 : _Off(_O), _Fpos(_Fpz)
  31.                 {_Lockit _Lk;
  32.                 _State = _Stz; }
  33. #else
  34.         fpos(streamoff _O = 0)
  35.                 : _Off(_O), _Fpos(_Fpz), _State(_Stz) {}
  36. #endif
  37.         fpos(_St _S, fpos_t _F)
  38.                 : _Off(0), _Fpos(_F), _State(_S) {}
  39.         _St state() const
  40.                 {return (_State); }
  41.         void state(_St _S)
  42.                 {_State = _S; }
  43.         fpos_t get_fpos_t() const
  44.                 {return (_Fpos); }
  45.         operator streamoff() const
  46.                 {return (_Off + _FPOSOFF(_Fpos)); }
  47.         streamoff operator-(const _Myt& _R) const
  48.                 {return ((streamoff)*this - (streamoff)_R); }
  49.         _Myt& operator+=(streamoff _O)
  50.                 {_Off += _O;
  51.                 return (*this); }
  52.         _Myt& operator-=(streamoff _O)
  53.                 {_Off -= _O;
  54.                 return (*this); }
  55.         _Myt operator+(streamoff _O) const
  56.                 {_Myt _Tmp = *this;
  57.                 return (_Tmp += _O); }
  58.         _Myt operator-(streamoff _O) const
  59.                 {_Myt _Tmp = *this;
  60.                 return (_Tmp -= _O); }
  61.         bool operator==(const _Myt& _R) const
  62.                 {return ((streamoff)*this == (streamoff)_R); }
  63.         bool operator!=(const _Myt& _R) const
  64.                 {return (!(*this == _R)); }
  65. private:
  66.         static _St _Stz;
  67.         streamoff _Off;
  68.         fpos_t _Fpos;
  69.         _St _State;
  70.         };
  71. template<class _St>
  72.         _St fpos<_St>::_Stz;
  73. typedef fpos<mbstate_t> streampos;
  74. typedef streampos wstreampos;
  75.                 // TEMPLATE STRUCT char_traits (FROM <string>)
  76. template<class _E>
  77.         struct char_traits {
  78.         typedef _E char_type;
  79.         typedef _E int_type;
  80.         typedef streampos pos_type;
  81.         typedef streamoff off_type;
  82.         typedef mbstate_t state_type;
  83.         static void __cdecl assign(_E& _X, const _E& _Y)
  84.                 {_X = _Y; }
  85.         static bool __cdecl eq(const _E& _X, const _E& _Y)
  86.                 {return (_X == _Y); }
  87.         static bool __cdecl lt(const _E& _X, const _E& _Y)
  88.                 {return (_X < _Y); }
  89.         static int __cdecl compare(const _E *_U, const _E *_V, size_t _N)
  90.                 {for (size_t _I = 0; _I < _N; ++_I, ++_U, ++_V)
  91.                         if (!eq(*_U, *_V))
  92.                                 return (lt(*_U, *_V) ? -1 : +1);
  93.                 return (0); }
  94.         static size_t __cdecl length(const _E *_U)
  95.                 {size_t _N;
  96.                 for (_N = 0; !eq(*_U, _E(0)); ++_U)
  97.                         ++_N;
  98.                 return (_N); }
  99.         static _E * __cdecl copy(_E *_U, const _E *_V, size_t _N)
  100.                 {_E *_S = _U;
  101.                 for (; 0 < _N; --_N, ++_U, ++_V)
  102.                         assign(*_U, *_V);
  103.                 return (_S); }
  104.         static const _E * __cdecl find(const _E *_U, size_t _N,
  105.                 const _E& _C)
  106.                 {for (; 0 < _N; --_N, ++_U)
  107.                         if (eq(*_U, _C))
  108.                                 return (_U);
  109.                 return (0); }
  110.         static _E * __cdecl move(_E *_U, const _E *_V, size_t _N)
  111.                 {_E *_Ans = _U;
  112.                 if (_V < _U && _U < _V + _N)
  113.                         for (_U += _N, _V += _N; 0 < _N; --_N)
  114.                                 assign(*--_U, *--_V);
  115.                 else
  116.                         for (; 0 < _N; --_N, ++_U, ++_V)
  117.                                 assign(*_U, *_V);
  118.                 return (_Ans); }
  119.         static _E * __cdecl assign(_E *_U, size_t _N, const _E& _C)
  120.                 {_E *_Ans = _U;
  121.                 for (; 0 < _N; --_N, ++_U)
  122.                         assign(*_U, _C);
  123.                 return (_Ans); }
  124.         static _E __cdecl to_char_type(const int_type& _C)
  125.                 {return ((_E)_C); }
  126.         static int_type __cdecl to_int_type(const _E& _C)
  127.                 {return ((int_type)_C); }
  128.         static bool __cdecl eq_int_type(const int_type& _X,
  129.                 const int_type& _Y)
  130.                 {return (_X == _Y); }
  131.         static int_type __cdecl eof()
  132.                 {return (EOF); }
  133.         static int_type __cdecl not_eof(const int_type& _C)
  134.                 {return (_C != eof() ? _C : !eof()); }
  135.         };
  136.                 // STRUCT char_traits<wchar_t>
  137. template<> struct _CRTIMP char_traits<wchar_t> {
  138.         typedef wchar_t _E;
  139.         typedef _E char_type;   // for overloads
  140.         typedef wint_t int_type;
  141.         typedef streampos pos_type;
  142.         typedef streamoff off_type;
  143.         typedef mbstate_t state_type;
  144.         static void __cdecl assign(_E& _X, const _E& _Y)
  145.                 {_X = _Y; }
  146.         static bool __cdecl eq(const _E& _X, const _E& _Y)
  147.                 {return (_X == _Y); }
  148.         static bool __cdecl lt(const _E& _X, const _E& _Y)
  149.                 {return (_X < _Y); }
  150.         static int __cdecl compare(const _E *_U, const _E *_V, size_t _N)
  151.                 {return (wmemcmp(_U, _V, _N)); }
  152.         static size_t __cdecl length(const _E *_U)
  153.                 {return (wcslen(_U)); }
  154.         static _E *__cdecl copy(_E *_U, const _E *_V, size_t _N)
  155.                 {return (wmemcpy(_U, _V, _N)); }
  156.         static const _E * __cdecl find(const _E *_U, size_t _N,
  157.                 const _E& _C)
  158.                 {return ((const _E *)wmemchr(_U, _C, _N)); }
  159.         static _E * __cdecl move(_E *_U, const _E *_V, size_t _N)
  160.                 {return (wmemmove(_U, _V, _N)); }
  161.         static _E * __cdecl assign(_E *_U, size_t _N, const _E& _C)
  162.                 {return (wmemset(_U, _C, _N)); }
  163.         static _E __cdecl to_char_type(const int_type& _C)
  164.                 {return ((_E)_C); }
  165.         static int_type __cdecl to_int_type(const _E& _C)
  166.                 {return ((int_type)_C); }
  167.         static bool __cdecl eq_int_type(const int_type& _X,
  168.                 const int_type& _Y)
  169.                 {return (_X == _Y); }
  170.         static int_type __cdecl eof()
  171.                 {return (WEOF); }
  172.         static int_type __cdecl not_eof(const int_type& _C)
  173.                 {return (_C != eof() ? _C : !eof()); }
  174.         };
  175.                 // STRUCT char_traits<char> (FROM <string>)
  176. template<> struct _CRTIMP char_traits<char> {
  177.         typedef char _E;
  178.         typedef _E char_type;
  179.         typedef int int_type;
  180.         typedef streampos pos_type;
  181.         typedef streamoff off_type;
  182.         typedef mbstate_t state_type;
  183.         static void __cdecl assign(_E& _X, const _E& _Y)
  184.                 {_X = _Y; }
  185.         static bool __cdecl eq(const _E& _X, const _E& _Y)
  186.                 {return (_X == _Y); }
  187.         static bool __cdecl lt(const _E& _X, const _E& _Y)
  188.                 {return (_X < _Y); }
  189.         static int __cdecl compare(const _E *_U, const _E *_V, size_t _N)
  190.                 {return (memcmp(_U, _V, _N)); }
  191.         static size_t __cdecl length(const _E *_U)
  192.                 {return (strlen(_U)); }
  193.         static _E * __cdecl copy(_E *_U, const _E *_V, size_t _N)
  194.                 {return ((_E *)memcpy(_U, _V, _N)); }
  195.         static const _E * __cdecl find(const _E *_U, size_t _N,
  196.                 const _E& _C)
  197.                 {return ((const _E *)memchr(_U, _C, _N)); }
  198.         static _E * __cdecl move(_E *_U, const _E *_V, size_t _N)
  199.                 {return ((_E *)memmove(_U, _V, _N)); }
  200.         static _E * __cdecl assign(_E *_U, size_t _N, const _E& _C)
  201.                 {return ((_E *)memset(_U, _C, _N)); }
  202.         static _E __cdecl to_char_type(const int_type& _C)
  203.                 {return ((_E)_C); }
  204.         static int_type __cdecl to_int_type(const _E& _C)
  205.                 {return ((int_type)((unsigned char)_C)); }
  206.         static bool __cdecl eq_int_type(const int_type& _X,
  207.                 const int_type& _Y)
  208.                 {return (_X == _Y); }
  209.         static int_type __cdecl eof()
  210.                 {return (EOF); }
  211.         static int_type __cdecl not_eof(const int_type& _C)
  212.                 {return (_C != eof() ? _C : !eof()); }
  213.         };
  214.                 // FORWARD REFERENCES
  215. template<class T>
  216.         class allocator;
  217. class ios_base;
  218. template<class _E, class _Tr = char_traits<_E> >
  219.         class basic_ios;
  220. template<class _E, class _Tr = char_traits<_E> >
  221.         class istreambuf_iterator;
  222. template<class _E, class _Tr = char_traits<_E> >
  223.         class ostreambuf_iterator;
  224. template<class _E, class _Tr = char_traits<_E> >
  225.         class basic_streambuf;
  226. template<class _E, class _Tr = char_traits<_E> >
  227.         class basic_istream;
  228. template<class _E, class _Tr = char_traits<_E> >
  229.         class basic_ostream;
  230. template<class _E, class _Tr = char_traits<_E> >
  231.         class basic_iostream;
  232. template<class _E, class _Tr = char_traits<_E>,
  233.         class _A = allocator<_E> >
  234.         class basic_stringbuf;
  235. template<class _E, class _Tr = char_traits<_E>,
  236.         class _A = allocator<_E> >
  237.         class basic_istringstream;
  238. template<class _E, class _Tr = char_traits<_E>,
  239.         class _A = allocator<_E> >
  240.         class basic_ostringstream;
  241. template<class _E, class _Tr = char_traits<_E>,
  242.         class _A = allocator<_E> >
  243.         class basic_stringstream;
  244. template<class _E, class _Tr = char_traits<_E> >
  245.         class basic_filebuf;
  246. template<class _E, class _Tr = char_traits<_E> >
  247.         class basic_ifstream;
  248. template<class _E, class _Tr = char_traits<_E> >
  249.         class basic_ofstream;
  250. template<class _E, class _Tr = char_traits<_E> >
  251.         class basic_fstream;
  252.  
  253.                 // char TYPEDEFS
  254. typedef basic_ios<char, char_traits<char> > ios;
  255. typedef basic_streambuf<char, char_traits<char> > streambuf;
  256. typedef basic_istream<char, char_traits<char> > istream;
  257. typedef basic_ostream<char, char_traits<char> > ostream;
  258. typedef basic_iostream<char, char_traits<char> > iostream;
  259. typedef basic_stringbuf<char, char_traits<char>,
  260.         allocator<char> > stringbuf;
  261. typedef basic_istringstream<char, char_traits<char>,
  262.         allocator<char> > istringstream;
  263. typedef basic_ostringstream<char, char_traits<char>,
  264.         allocator<char> > ostringstream;
  265. typedef basic_stringstream<char, char_traits<char>,
  266.         allocator<char> > stringstream;
  267. typedef basic_filebuf<char, char_traits<char> > filebuf;
  268. typedef basic_ifstream<char, char_traits<char> > ifstream;
  269. typedef basic_ofstream<char, char_traits<char> > ofstream;
  270. typedef basic_fstream<char, char_traits<char> > fstream;
  271.                 // wchar_t TYPEDEFS
  272. typedef basic_ios<wchar_t, char_traits<wchar_t> > wios;
  273. typedef basic_streambuf<wchar_t, char_traits<wchar_t> >
  274.         wstreambuf;
  275. typedef basic_istream<wchar_t, char_traits<wchar_t> > wistream;
  276. typedef basic_ostream<wchar_t, char_traits<wchar_t> > wostream;
  277. typedef basic_iostream<wchar_t, char_traits<wchar_t> > wiostream;
  278. typedef basic_stringbuf<wchar_t, char_traits<wchar_t>,
  279.         allocator<wchar_t> > wstringbuf;
  280. typedef basic_istringstream<wchar_t, char_traits<wchar_t>,
  281.         allocator<wchar_t> > wistringstream;
  282. typedef basic_ostringstream<wchar_t, char_traits<wchar_t>,
  283.         allocator<wchar_t> > wostringstream;
  284. typedef basic_stringstream<wchar_t, char_traits<wchar_t>,
  285.         allocator<wchar_t> > wstringstream;
  286. typedef basic_filebuf<wchar_t, char_traits<wchar_t> > wfilebuf;
  287. typedef basic_ifstream<wchar_t, char_traits<wchar_t> > wifstream;
  288. typedef basic_ofstream<wchar_t, char_traits<wchar_t> > wofstream;
  289. typedef basic_fstream<wchar_t, char_traits<wchar_t> > wfstream;
  290.  
  291. #ifdef  _DLL
  292. template<class _E, class _II >
  293.     class num_get;
  294. template<class _E, class _OI >
  295.     class num_put;
  296. template<class _E>
  297.     class collate;
  298.  
  299. typedef num_get<char, istreambuf_iterator<char, char_traits<char> > > numget;
  300. typedef num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >
  301.                                                                                                                                           wnumget;
  302. typedef num_put<char, ostreambuf_iterator<char, char_traits<char> > > numput;
  303. typedef num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >
  304.                                                                                                                                           wnumput;
  305. typedef collate<char> ncollate;
  306. typedef collate<wchar_t> wcollate;
  307.  
  308. #endif
  309.  
  310. _STD_END
  311. #ifdef  _MSC_VER
  312. #pragma pack(pop)
  313. #endif  /* _MSC_VER */
  314.  
  315. #endif /* _IOSFWD_ */
  316.  
  317. /*
  318.  * Copyright (c) 1995 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  319.  * Consult your license regarding permissions and restrictions.
  320.  */
  321.