windows-nt/Source/XPSP1/NT/base/crts/libw32/include/iosfwd
2020-09-26 16:20:57 +08:00

523 lines
14 KiB
Plaintext

// iosfwd standard header
#pragma once
#ifndef _IOSFWD_
#define _IOSFWD_
#include <cstdio>
#include <cstring>
#include <cwchar>
#include <xstddef>
#pragma pack(push,8)
#pragma warning(push,3)
_STD_BEGIN
// STREAM POSITIONING TYPES (from <streambuf>)
#ifdef _WIN64
typedef __int64 streamoff;
typedef __int64 streamsize;
#else
typedef long streamoff;
typedef int streamsize;
#endif
extern _CRTIMP2 fpos_t _Fpz;
extern _CRTIMP2 const streamoff _BADOFF;
// TEMPLATE CLASS fpos (from <streambuf>)
template<class _Statetype>
class fpos
{ // store arbitrary file position
typedef fpos<_Statetype> _Myt;
public:
fpos(streamoff _Off = 0)
: _Myoff(_Off), _Fpos(_Fpz), _Mystate(_Stz)
{ // construct with stream offset
}
fpos(_Statetype _State, fpos_t _Fileposition)
: _Myoff(0), _Fpos(_Fileposition), _Mystate(_State)
{ // construct with conversion state and C file position
}
_Statetype state() const
{ // return conversion state
return (_Mystate);
}
void state(_Statetype _State)
{ // set conversion state
_Mystate = _State;
}
fpos_t seekpos() const
{ // return C file position
return (_Fpos);
}
operator streamoff() const
{ // return offset
return (_Myoff + _FPOSOFF(_Fpos));
}
streamoff operator-(const _Myt& _Right) const
{ // return difference of file positions as an offset
return ((streamoff)*this - (streamoff)_Right);
}
_Myt& operator+=(streamoff _Off)
{ // add offset
_Myoff += _Off;
return (*this);
}
_Myt& operator-=(streamoff _Off)
{ // subtract offset
_Myoff -= _Off;
return (*this);
}
_Myt operator+(streamoff _Off) const
{ // return this + offset
_Myt _Tmp = *this;
return (_Tmp += _Off);
}
_Myt operator-(streamoff _Off) const
{ // return this - offset
_Myt _Tmp = *this;
return (_Tmp -= _Off);
}
bool operator==(const _Myt& _Right) const
{ // test for file position equality
return ((streamoff)*this == (streamoff)_Right);
}
bool operator!=(const _Myt& _Right) const
{ // test for file position inequality
return (!(*this == _Right));
}
private:
static _Statetype _Stz; // initial conversion state
streamoff _Myoff; // stream offset
fpos_t _Fpos; // C file position
_Statetype _Mystate; // current conversion state
};
// STATIC fpos::_Stz OBJECT
template<class _Statetype>
_Statetype fpos<_Statetype>::_Stz;
typedef fpos<mbstate_t> streampos;
typedef streampos wstreampos;
// TEMPLATE STRUCT char_traits (FROM <string>)
template<class _Elem>
struct char_traits
{ // properties of a string or stream element
typedef _Elem char_type;
typedef _Elem int_type;
typedef streampos pos_type;
typedef streamoff off_type;
typedef mbstate_t state_type;
static void __cdecl assign(_Elem& _Left, const _Elem& _Right)
{ // assign an element
_Left = _Right;
}
static bool __cdecl eq(const _Elem& _Left, const _Elem& _Right)
{ // test for element equality
return (_Left == _Right);
}
static bool __cdecl lt(const _Elem& _Left, const _Elem& _Right)
{ // test if _Left precedes _Right
return (_Left < _Right);
}
static int __cdecl compare(const _Elem *_First1, const _Elem *_First2,
size_t _Count)
{ // compare [_First1, _First1 + _Count) with [_First2, ...)
for (; 0 < _Count; --_Count, ++_First1, ++_First2)
if (!eq(*_First1, *_First2))
return (lt(*_First1, *_First2) ? -1 : +1);
return (0);
}
static size_t __cdecl length(const _Elem *_First)
{ // find length of null-terminated sequence
size_t _Count;
for (_Count = 0; !eq(*_First, _Elem()); ++_First)
++_Count;
return (_Count);
}
static _Elem *__cdecl copy(_Elem *_First1, const _Elem *_First2,
size_t _Count)
{ // copy [_First1, _First1 + _Count) to [_First2, ...)
_Elem *_Next = _First1;
for (; 0 < _Count; --_Count, ++_Next, ++_First2)
assign(*_Next, *_First2);
return (_First1);
}
static const _Elem *__cdecl find(const _Elem *_First, size_t _Count,
const _Elem& _Ch)
{ // look for _Ch in [_First, _First + _Count)
for (; 0 < _Count; --_Count, ++_First)
if (eq(*_First, _Ch))
return (_First);
return (0);
}
static _Elem *__cdecl move(_Elem *_First1, const _Elem *_First2,
size_t _Count)
{ // copy [_First1, _First1 + _Count) to [_First2, ...)
_Elem *_Next = _First1;
if (_First2 < _Next && _Next < _First2 + _Count)
for (_Next += _Count, _First2 += _Count; 0 < _Count; --_Count)
assign(*--_Next, *--_First2);
else
for (; 0 < _Count; --_Count, ++_Next, ++_First2)
assign(*_Next, *_First2);
return (_First1);
}
static _Elem *__cdecl assign(_Elem *_First, size_t _Count, _Elem _Ch)
{ // assign _Count * _Ch to [_First, ...)
_Elem *_Next = _First;
for (; 0 < _Count; --_Count, ++_Next)
assign(*_Next, _Ch);
return (_First);
}
static _Elem __cdecl to_char_type(const int_type& _Meta)
{ // convert metacharacter to character
return (_Meta);
}
static int_type __cdecl to_int_type(const _Elem& _Ch)
{ // convert character to metacharacter
return (_Ch);
}
static bool __cdecl eq_int_type(const int_type& _Left,
const int_type& _Right)
{ // test for metacharacter equality
return (_Left == _Right);
}
static int_type __cdecl eof()
{ // return end-of-file metacharacter
return ((int_type)EOF);
}
static int_type __cdecl not_eof(const int_type& _Meta)
{ // return anything but EOF
return (_Meta != eof() ? _Meta : !eof());
}
};
// STRUCT char_traits<wchar_t>
template<> struct _CRTIMP2 char_traits<wchar_t>
{ // properties of a string or stream wchar_t element
typedef wchar_t _Elem;
typedef _Elem char_type; // for overloads
typedef wint_t int_type;
typedef streampos pos_type;
typedef streamoff off_type;
typedef mbstate_t state_type;
static void __cdecl assign(_Elem& _Left, const _Elem& _Right)
{ // assign an element
_Left = _Right;
}
static bool __cdecl eq(const _Elem& _Left, const _Elem& _Right)
{ // test for element equality
return (_Left == _Right);
}
static bool __cdecl lt(const _Elem& _Left, const _Elem& _Right)
{ // test if _Left precedes _Right
return (_Left < _Right);
}
static int __cdecl compare(const _Elem *_First1, const _Elem *_First2,
size_t _Count)
{ // compare [_First1, _First1 + _Count) with [_First2, ...)
return (::wmemcmp(_First1, _First2, _Count));
}
static size_t __cdecl length(const _Elem *_First)
{ // find length of null-terminated sequence
return (::wcslen(_First));
}
static _Elem *__cdecl copy(_Elem *_First1, const _Elem *_First2,
size_t _Count)
{ // copy [_First1, _First1 + _Count) to [_First2, ...)
return (::wmemcpy(_First1, _First2, _Count));
}
static const _Elem *__cdecl find(const _Elem *_First, size_t _Count,
const _Elem& _Ch)
{ // look for _Ch in [_First, _First + _Count)
return ((const _Elem *)::wmemchr(_First, _Ch, _Count));
}
static _Elem *__cdecl move(_Elem *_First1, const _Elem *_First2,
size_t _Count)
{ // copy [_First1, _First1 + _Count) to [_First2, ...)
return (::wmemmove(_First1, _First2, _Count));
}
static _Elem *__cdecl assign(_Elem *_First, size_t _Count, _Elem _Ch)
{ // assign _Count * _Ch to [_First, ...)
return (::wmemset(_First, _Ch, _Count));
}
static _Elem __cdecl to_char_type(const int_type& _Meta)
{ // convert metacharacter to character
return (_Meta);
}
static int_type __cdecl to_int_type(const _Elem& _Ch)
{ // convert character to metacharacter
return (_Ch);
}
static bool __cdecl eq_int_type(const int_type& _Left,
const int_type& _Right)
{ // test for metacharacter equality
return (_Left == _Right);
}
static int_type __cdecl eof()
{ // return end-of-file metacharacter
return (WEOF);
}
static int_type __cdecl not_eof(const int_type& _Meta)
{ // return anything but EOF
return (_Meta != eof() ? _Meta : !eof());
}
};
// STRUCT char_traits<char> (FROM <string>)
template<> struct _CRTIMP2 char_traits<char>
{ // properties of a string or stream char element
typedef char _Elem;
typedef _Elem char_type;
typedef int int_type;
typedef streampos pos_type;
typedef streamoff off_type;
typedef mbstate_t state_type;
static void __cdecl assign(_Elem& _Left, const _Elem& _Right)
{ // assign an element
_Left = _Right;
}
static bool __cdecl eq(const _Elem& _Left, const _Elem& _Right)
{ // test for element equality
return (_Left == _Right);
}
static bool __cdecl lt(const _Elem& _Left, const _Elem& _Right)
{ // test if _Left precedes _Right
return (_Left < _Right);
}
static int __cdecl compare(const _Elem *_First1, const _Elem *_First2,
size_t _Count)
{ // compare [_First1, _First1 + _Count) with [_First2, ...)
return (::memcmp(_First1, _First2, _Count));
}
static size_t __cdecl length(const _Elem *_First)
{ // find length of null-terminated string
return (::strlen(_First));
}
static _Elem *__cdecl copy(_Elem *_First1, const _Elem *_First2,
size_t _Count)
{ // copy [_First1, _First1 + _Count) to [_First2, ...)
return ((_Elem *)::memcpy(_First1, _First2, _Count));
}
static const _Elem *__cdecl find(const _Elem *_First, size_t _Count,
const _Elem& _Ch)
{ // look for _Ch in [_First, _First + _Count)
return ((const _Elem *)::memchr(_First, _Ch, _Count));
}
static _Elem *__cdecl move(_Elem *_First1, const _Elem *_First2,
size_t _Count)
{ // copy [_First1, _First1 + _Count) to [_First2, ...)
return ((_Elem *)::memmove(_First1, _First2, _Count));
}
static _Elem *__cdecl assign(_Elem *_First, size_t _Count, _Elem _Ch)
{ // assign _Count * _Ch to [_First, ...)
return ((_Elem *)::memset(_First, _Ch, _Count));
}
static _Elem __cdecl to_char_type(const int_type& _Meta)
{ // convert metacharacter to character
return ((_Elem)_Meta);
}
static int_type __cdecl to_int_type(const _Elem& _Ch)
{ // convert character to metacharacter
return ((unsigned char)_Ch);
}
static bool __cdecl eq_int_type(const int_type& _Left,
const int_type& _Right)
{ // test for metacharacter equality
return (_Left == _Right);
}
static int_type __cdecl eof()
{ // return end-of-file metacharacter
return (EOF);
}
static int_type __cdecl not_eof(const int_type& _Meta)
{ // return anything but EOF
return (_Meta != eof() ? _Meta : !eof());
}
};
// FORWARD REFERENCES
template<class _Ty>
class allocator;
class ios_base;
template<class _Elem,
class _Traits = char_traits<_Elem> >
class basic_ios;
template<class _Elem,
class _Traits = char_traits<_Elem> >
class istreambuf_iterator;
template<class _Elem,
class _Traits = char_traits<_Elem> >
class ostreambuf_iterator;
template<class _Elem,
class _Traits = char_traits<_Elem> >
class basic_streambuf;
template<class _Elem,
class _Traits = char_traits<_Elem> >
class basic_istream;
template<class _Elem,
class _Traits = char_traits<_Elem> >
class basic_ostream;
template<class _Elem,
class _Traits = char_traits<_Elem> >
class basic_iostream;
template<class _Elem,
class _Traits = char_traits<_Elem>,
class _Alloc = allocator<_Elem> >
class basic_stringbuf;
template<class _Elem,
class _Traits = char_traits<_Elem>,
class _Alloc = allocator<_Elem> >
class basic_istringstream;
template<class _Elem,
class _Traits = char_traits<_Elem>,
class _Alloc = allocator<_Elem> >
class basic_ostringstream;
template<class _Elem,
class _Traits = char_traits<_Elem>,
class _Alloc = allocator<_Elem> >
class basic_stringstream;
template<class _Elem,
class _Traits = char_traits<_Elem> >
class basic_filebuf;
template<class _Elem,
class _Traits = char_traits<_Elem> >
class basic_ifstream;
template<class _Elem,
class _Traits = char_traits<_Elem> >
class basic_ofstream;
template<class _Elem,
class _Traits = char_traits<_Elem> >
class basic_fstream;
#ifdef _DLL_CPPLIB
template<class _Elem,
class _InIt >
class num_get;
template<class _Elem,
class _OutIt >
class num_put;
template<class _Elem>
class collate;
#endif // _DLL_CPPLIB
// char TYPEDEFS
typedef basic_ios<char, char_traits<char> > ios;
typedef basic_streambuf<char, char_traits<char> > streambuf;
typedef basic_istream<char, char_traits<char> > istream;
typedef basic_ostream<char, char_traits<char> > ostream;
typedef basic_iostream<char, char_traits<char> > iostream;
typedef basic_stringbuf<char, char_traits<char>,
allocator<char> > stringbuf;
typedef basic_istringstream<char, char_traits<char>,
allocator<char> > istringstream;
typedef basic_ostringstream<char, char_traits<char>,
allocator<char> > ostringstream;
typedef basic_stringstream<char, char_traits<char>,
allocator<char> > stringstream;
typedef basic_filebuf<char, char_traits<char> > filebuf;
typedef basic_ifstream<char, char_traits<char> > ifstream;
typedef basic_ofstream<char, char_traits<char> > ofstream;
typedef basic_fstream<char, char_traits<char> > fstream;
// wchat_t TYPEDEFS
typedef basic_ios<wchar_t, char_traits<wchar_t> > wios;
typedef basic_streambuf<wchar_t, char_traits<wchar_t> >
wstreambuf;
typedef basic_istream<wchar_t, char_traits<wchar_t> > wistream;
typedef basic_ostream<wchar_t, char_traits<wchar_t> > wostream;
typedef basic_iostream<wchar_t, char_traits<wchar_t> > wiostream;
typedef basic_stringbuf<wchar_t, char_traits<wchar_t>,
allocator<wchar_t> > wstringbuf;
typedef basic_istringstream<wchar_t, char_traits<wchar_t>,
allocator<wchar_t> > wistringstream;
typedef basic_ostringstream<wchar_t, char_traits<wchar_t>,
allocator<wchar_t> > wostringstream;
typedef basic_stringstream<wchar_t, char_traits<wchar_t>,
allocator<wchar_t> > wstringstream;
typedef basic_filebuf<wchar_t, char_traits<wchar_t> > wfilebuf;
typedef basic_ifstream<wchar_t, char_traits<wchar_t> > wifstream;
typedef basic_ofstream<wchar_t, char_traits<wchar_t> > wofstream;
typedef basic_fstream<wchar_t, char_traits<wchar_t> > wfstream;
#ifdef _DLL_CPPLIB
typedef num_get<char, istreambuf_iterator<char, char_traits<char> > >
numget;
typedef num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >
wnumget;
typedef num_put<char, ostreambuf_iterator<char, char_traits<char> > >
numput;
typedef num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >
wnumput;
typedef collate<char> ncollate;
typedef collate<wchar_t> wcollate;
#endif // _DLL_CPPLIB
_STD_END
#pragma warning(pop)
#pragma pack(pop)
#endif /* _IOSFWD_ */
/*
* Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
V3.10:0009 */