ellong.h

来自「《3D游戏引擎设计》的源码」· C头文件 代码 · 共 79 行

H
79
字号
#ifndef ELLONG_H
#define ELLONG_H

#include "element.h"

class mgcLong : public mgcElement
{
// object information
public:
	mgcLong () : mgcElement(type,&value)
		{ value = 0; }
	mgcLong (const long& _value) : mgcElement(type,&value)
		{ value = _value; }
	mgcLong (const mgcElement& element) : mgcElement(type,&value)
		{ *this = element; }

	operator long () const
		{ return value; }

	mgcLong& operator= (long _value)
		{ value = _value;  return *this; }
	mgcLong& operator= (const mgcLong& derived)
		{ value = derived.value;  return *this; }
	mgcLong& operator= (const mgcElement& element);

	int operator== (const mgcLong& derived) const
		{ return value == derived.value; }
	int operator!= (const mgcLong& derived) const
		{ return value != derived.value; }

	friend istream& operator>> (istream& istr, mgcLong& derived)
		{ return istr >> derived.value; }
	friend ostream& operator<< (ostream& ostr, const mgcLong& derived)
		{ return ostr << derived.value; }

private:
	long value;

// class information
public:
	static const char* description;
	static const int type;
	static const int size;

    static int Register ();
	static void ToChar   (int quantity, void* src, void* trg);
	static void ToUchar  (int quantity, void* src, void* trg);
	static void ToShort  (int quantity, void* src, void* trg);
	static void ToUshort (int quantity, void* src, void* trg);
	static void ToInt    (int quantity, void* src, void* trg);
	static void ToUint   (int quantity, void* src, void* trg);
	static void ToLong   (int quantity, void* src, void* trg);
	static void ToUlong  (int quantity, void* src, void* trg);
	static void ToFloat  (int quantity, void* src, void* trg);
	static void ToDouble (int quantity, void* src, void* trg);

	static void Input (istream& istr, void* trg)
		{ istr >> *(long*)trg; }
	static void Output (ostream& ostr, const void* src)
		{ ostr << *(long*)src; }

// error handling
public:
	static int verbose;
	static unsigned error;
	static void Report (ostream& ostr);
private:
	static const unsigned registration_failed;
	static const char* message[1];
	static int Number (unsigned single_error);
	static void Report (unsigned single_error);
};

static int mgcLong_key = mgcLong::Register();

#endif


⌨️ 快捷键说明

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