⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iosfwd

📁 C语言库函数的原型,有用的拿去
💻
📖 第 1 页 / 共 2 页
字号:
// iosfwd standard header
#pragma once
#ifndef _IOSFWD_
#define _IOSFWD_
#ifndef RC_INVOKED
#include <cstdio>
#include <cstring>
#include <cwchar>
#include <xstddef>

#include <crtdbg.h>

 #pragma pack(push,_CRT_PACKING)
 #pragma warning(push,3)

_STD_BEGIN
		// STREAM POSITIONING TYPES (from <streambuf>)

typedef _Longlong streamoff;
typedef _Longlong streamsize;

  #define _FSEEK_OFF(str, off, way)	_fseeki64(str, off, way)
  #define _Fpz	0	/* initializer for zero fpos_t */

  #ifdef _M_CEE_PURE
extern const streamoff _BADOFF;
  #else /* _M_CEE_PURE */
extern _CRTDATA2 _PGLOBAL const streamoff _BADOFF;
  #endif /* _M_CEE_PURE */

		// TEMPLATE CLASS fpos (from <streambuf>)
template<class _Statetype>
	class fpos
	{	// store arbitrary file position
	typedef fpos<_Statetype> _Myt;

public:
	__CLR_OR_THIS_CALL fpos(streamoff _Off = 0)
		: _Myoff(_Off), _Fpos(_Fpz), _Mystate(_Stz)
		{	// construct with stream offset
		}

	__CLR_OR_THIS_CALL fpos(_Statetype _State, fpos_t _Fileposition)
		: _Myoff(0), _Fpos(_Fileposition), _Mystate(_State)
		{	// construct with conversion state and C file position
		}

	_Statetype __CLR_OR_THIS_CALL state() const
		{	// return conversion state
		return (_Mystate);
		}

	void __CLR_OR_THIS_CALL state(_Statetype _State)
		{	// set conversion state
		_Mystate = _State;
		}

	fpos_t __CLR_OR_THIS_CALL seekpos() const
		{	// return C file position
		return (_Fpos);
		}

	__CLR_OR_THIS_CALL operator streamoff() const
		{	// return offset
		return ((streamoff)(_Myoff + _FPOSOFF(_Fpos)));
		}

	streamoff __CLR_OR_THIS_CALL operator-(const _Myt& _Right) const
		{	// return difference of file positions as an offset
		return ((streamoff)*this - (streamoff)_Right);
		}

	_Myt& __CLR_OR_THIS_CALL operator+=(streamoff _Off)
		{	// add offset
		_Myoff += _Off;
		return (*this);
		}

	_Myt& __CLR_OR_THIS_CALL operator-=(streamoff _Off)
		{	// subtract offset
		_Myoff -= _Off;
		return (*this);
		}

	_Myt __CLR_OR_THIS_CALL operator+(streamoff _Off) const
		{	// return this + offset
		_Myt _Tmp = *this;
		return (_Tmp += _Off);
		}

	_Myt __CLR_OR_THIS_CALL operator-(streamoff _Off) const
		{	// return this - offset
		_Myt _Tmp = *this;
		return (_Tmp -= _Off);
		}

	bool __CLR_OR_THIS_CALL operator==(const _Myt& _Right) const
		{	// test for file position equality
		return ((streamoff)*this == (streamoff)_Right);
		}

	bool __CLR_OR_THIS_CALL operator==(streamoff _Right) const
		{	// test for file position equality with streamoff
		return ((streamoff)*this == _Right);
		}

	bool __CLR_OR_THIS_CALL operator!=(const _Myt& _Right) const
		{	// test for file position inequality
		return (!(*this == _Right));
		}

private:
	_PGLOBAL static const _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>
	_PGLOBAL const _Statetype fpos<_Statetype>::_Stz = _Statetype();

 #define _POS_TYPE_FROM_STATE(postype, state, position)	\
	postype(state, position)
 #define _POS_TYPE_TO_FPOS_T(pos)	pos.seekpos()
 #define _POS_TYPE_TO_STATE(pos)	pos.state()

typedef fpos<_Mbstatet> streampos;

typedef streampos wstreampos;

		// TEMPLATE STRUCT _Char_traits (FROM <string>)
template<class _Elem,
	class _Int_type>
	struct _Char_traits
	{	// properties of a string or stream element
	typedef _Elem char_type;
	typedef _Int_type int_type;
	typedef streampos pos_type;
	typedef streamoff off_type;
	typedef _Mbstatet state_type;

	static int __CLRCALL_OR_CDECL compare(
		_In_count_(_Count) const _Elem *_First1,
		_In_count_(_Count) 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 __CLRCALL_OR_CDECL length(_In_z_ const _Elem *_First)
		{	// find length of null-terminated sequence
		size_t _Count;
		for (_Count = 0; !eq(*_First, _Elem()); ++_First)
			++_Count;
		return (_Count);
		}

	static _Elem *__CLRCALL_OR_CDECL copy(
		_Out_cap_(_Count) _Elem *_First1,
		_In_count_(_Count) 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 _Elem *__CLRCALL_OR_CDECL _Copy_s(
		_Out_cap_(_Dest_size) _Elem *_First1, size_t _Dest_size,
		_In_count_(_Count) const _Elem *_First2, size_t _Count)
		{	// copy [_First1, _First1 + _Count) to [_First2, ...)
		_SCL_SECURE_CRT_VALIDATE(_Dest_size >= _Count, NULL);
		return (copy(_First1, _First2, _Count));
		}

	static const _Elem *__CLRCALL_OR_CDECL find(
		_In_count_(_Count) 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 *__CLRCALL_OR_CDECL move(
		_Out_cap_(_Count) _Elem *_First1,
		_In_count_(_Count) 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 *__CLRCALL_OR_CDECL assign(
		_Out_cap_(_Count) _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 void __CLRCALL_OR_CDECL assign(_Elem& _Left, const _Elem& _Right)
		{	// assign an element
		_Left = _Right;
		}

	static bool __CLRCALL_OR_CDECL eq(const _Elem& _Left, const _Elem& _Right)
		{	// test for element equality
		return (_Left == _Right);
		}

	static bool __CLRCALL_OR_CDECL lt(const _Elem& _Left, const _Elem& _Right)
		{	// test if _Left precedes _Right
		return (_Left < _Right);
		}

	static _Elem __CLRCALL_OR_CDECL to_char_type(const int_type& _Meta)
		{	// convert metacharacter to character
		return ((_Elem)_Meta);
		}

	static int_type __CLRCALL_OR_CDECL to_int_type(const _Elem& _Ch)
		{	// convert character to metacharacter
		return ((int_type)_Ch);
		}

	static bool __CLRCALL_OR_CDECL eq_int_type(const int_type& _Left,
		const int_type& _Right)
		{	// test for metacharacter equality
		return (_Left == _Right);
		}

	static int_type __CLRCALL_OR_CDECL not_eof(const int_type& _Meta)
		{	// return anything but EOF
		return (_Meta != eof() ? (int_type)_Meta : (int_type)!eof());
		}

	static int_type __CLRCALL_OR_CDECL eof()
		{	// return end-of-file metacharacter
		return ((int_type)EOF);
		}
	};

		// TEMPLATE STRUCT char_traits
template<class _Elem>
	struct char_traits
		: public _Char_traits<_Elem, long>
	{	// properties of a string or stream unknown element
	};

 #if _HAS_CHAR16_T_LANGUAGE_SUPPORT
		// STRUCT char_traits<char16_t>
template<>
	struct char_traits<char16_t>
	: public _Char_traits<char16_t, unsigned short>
	{	// properties of a string or stream char16_t element
	};

		// STRUCT char_traits<char32_t>
template<>
	struct char_traits<char32_t>
	: public _Char_traits<char32_t, unsigned long>
	{	// properties of a string or stream char32_t element
	};
 #endif /* _HAS_CHAR16_T_LANGUAGE_SUPPORT */

		// STRUCT char_traits<wchar_t>
template<>
	struct 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 _Mbstatet state_type;

	static int __CLRCALL_OR_CDECL compare(const _Elem *_First1, const _Elem *_First2,
		size_t _Count)
		{	// compare [_First1, _First1 + _Count) with [_First2, ...)
		return (_CSTD wmemcmp(_First1, _First2, _Count));
		}

	static size_t __CLRCALL_OR_CDECL length(const _Elem *_First)
		{	// find length of null-terminated sequence
		return (_CSTD wcslen(_First));
		}

	static _Elem *__CLRCALL_OR_CDECL copy(_Elem *_First1, const _Elem *_First2,
		size_t _Count)
		{	// copy [_First1, _First1 + _Count) to [_First2, ...)
		return ((_Elem *)_CSTD wmemcpy(_First1, _First2, _Count));
		}

	static _Elem *__CLRCALL_OR_CDECL _Copy_s(
		_Out_cap_(_Size_in_words) _Elem *_First1, size_t _Size_in_words,
		_In_count_(_Count) const _Elem *_First2, size_t _Count)
		{	// copy [_First1, _First1 + _Count) to [_First2, ...)
		_CRT_SECURE_WMEMCPY(_First1, _Size_in_words, _First2, _Count);
		return _First1;
		}

	static const _Elem *__CLRCALL_OR_CDECL find(const _Elem *_First, size_t _Count,
		const _Elem& _Ch)
		{	// look for _Ch in [_First, _First + _Count)
		return ((const _Elem *)_CSTD wmemchr(_First, _Ch, _Count));
		}

	static _Elem *__CLRCALL_OR_CDECL move(_Elem *_First1, const _Elem *_First2,
		size_t _Count)
		{	// copy [_First1, _First1 + _Count) to [_First2, ...)
		return ((_Elem *)_CSTD wmemmove(_First1, _First2, _Count));
		}

	static _Elem *__CLRCALL_OR_CDECL assign(_Elem *_First, size_t _Count, _Elem _Ch)
		{	// assign _Count * _Ch to [_First, ...)
		return ((_Elem *)_CSTD wmemset(_First, _Ch, _Count));
		}

	static void __CLRCALL_OR_CDECL assign(_Elem& _Left, const _Elem& _Right)
		{	// assign an element
		_Left = _Right;
		}

	static bool __CLRCALL_OR_CDECL eq(const _Elem& _Left, const _Elem& _Right)
		{	// test for element equality
		return (_Left == _Right);
		}

	static bool __CLRCALL_OR_CDECL lt(const _Elem& _Left, const _Elem& _Right)
		{	// test if _Left precedes _Right
		return (_Left < _Right);
		}

	static _Elem __CLRCALL_OR_CDECL to_char_type(const int_type& _Meta)
		{	// convert metacharacter to character
		return (_Meta);
		}

	static int_type __CLRCALL_OR_CDECL to_int_type(const _Elem& _Ch)
		{	// convert character to metacharacter
		return (_Ch);
		}

	static bool __CLRCALL_OR_CDECL eq_int_type(const int_type& _Left,
		const int_type& _Right)
		{	// test for metacharacter equality
		return (_Left == _Right);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -