#pragma once


#define Mx_InvalidHandle 0xFFFFFFFFFFFFF0
class ARXDLL McDbHandle
{
public:
	// -------------------------------------------------------------------------
	// Summary:
	// 		构造函数
	// -------------------------------------------------------------------------
	McDbHandle();

	// -------------------------------------------------------------------------
	// Summary:
	// 		构造函数
	// -------------------------------------------------------------------------
	McDbHandle(mxuint64 value);
	
	// -------------------------------------------------------------------------
	// Summary:
	// 		构造函数
	// Parameters:
	// 		pszHandle - 由一个字符串构造函数实体句柄
	// -------------------------------------------------------------------------
#if (MX_TARGET_PLATFORM == MX_PLATFORM_WINDOWS)
	McDbHandle(const wchar_t* pszHandle);
#endif

	McDbHandle(const mxchar*  pszHandle);

	// -------------------------------------------------------------------------
	// Summary:
	// 		等号重载操作符
	// -------------------------------------------------------------------------
	McDbHandle& operator=(const McDbHandle&);

	// -------------------------------------------------------------------------
	// Summary:
	// 		等号重载操作符
	// -------------------------------------------------------------------------
#if (MX_TARGET_PLATFORM == MX_PLATFORM_WINDOWS)
	McDbHandle& operator=(const wchar_t*);
#endif

	McDbHandle& operator=(mxint64 value);

	// -------------------------------------------------------------------------
	// Summary:
	// 		得到实体句柄字符串
	// Parameters:
	// 		pBuf	 -	返回的字符串
	// -------------------------------------------------------------------------
	void getIntoAsciiBuffer(LPTSTR pBuf) const;

	MxString getString() const;
	
	//:Ignore

	bool operator == (const McDbHandle&) const;
	bool operator != (const McDbHandle&) const;

	bool operator > (const McDbHandle&) const;
	bool operator >= (const McDbHandle&) const;
	bool operator < (const McDbHandle&) const;
	bool operator <= (const McDbHandle&) const;

	//:End Ignore

	// -------------------------------------------------------------------------
	// Summary:
	// 		实体名柄是否为空
	// -------------------------------------------------------------------------
	bool           isNull() const;

	// -------------------------------------------------------------------------
	// Summary:
	// 		实体名柄设置为空
	// -------------------------------------------------------------------------
	void           setNull();

	//:Ignore
	inline mxuint64  value() const
	{
		return m_value;
	}

	void           setValue(mxuint64  value);
	
	operator mxuint64() const;
private:
	mxuint64 m_value;
	//:End Ignore
};

inline McDbHandle::McDbHandle(mxuint64 val) : m_value(val)
{

}


inline McDbHandle&
McDbHandle::operator=(const McDbHandle& handle)
{
	m_value = handle.m_value;
	return *this;
}

inline McDbHandle&
McDbHandle::operator=(mxint64 val)
{
	m_value = val; return *this;
}


inline bool
McDbHandle::operator==(const McDbHandle &handle) const
{
	return m_value == handle.m_value;
}

inline bool
McDbHandle::operator!=(const McDbHandle &handle) const
{
	return m_value != handle.m_value;
}

inline bool
McDbHandle::isNull(void) const
{
	return m_value == 0;
}

inline void McDbHandle::setNull(void)
{
	m_value = 0;
}



inline void McDbHandle::setValue(mxuint64  value)
{
	m_value = value;
}

inline McDbHandle::operator mxuint64() const
{
	return m_value;
}



inline bool
McDbHandle::operator > (const McDbHandle& handle) const
{

	return m_value > handle.m_value;
}


inline bool
McDbHandle::operator >= (const McDbHandle& handle) const
{

	return m_value >= handle.m_value;
}


inline bool
McDbHandle::operator < (const McDbHandle& handle) const
{

	return m_value < handle.m_value;
}


inline bool
McDbHandle::operator <= (const McDbHandle& handle) const
{

	return m_value <= handle.m_value;
}

