// WVCT.h: CWVCF クラスのインターフェイス
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_WVCT_H__0D981393_AA8B_4BA0_B0A4_C8516E74ED99__INCLUDED_)
#define AFX_WVCT_H__0D981393_AA8B_4BA0_B0A4_C8516E74ED99__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "GDEdDef.h"

class CWVCF
{
public:
	// 
	virtual CString Format(WORD x) = 0;
	// 
	virtual CString FormatDisp(WORD x) = 0;
	// 
	virtual bool Parse(LPCSTR pszText, WORD &x) = 0;
	// 
	virtual int GetWvct() = 0;
	// 
	virtual LPCTSTR GetHintText(int i) = 0;

	// 
	static CWVCF &GetOp(int wvcf);

};

struct CWVCF_Signed : CWVCF
{
	// 
	virtual CString Format(WORD x)
	{
		CString strRet;
		strRet.Format("%d", 0U +(__int16)x);
		return strRet;
	}
	// 
	virtual CString FormatDisp(WORD x) { return Format(x); }
	// 
	virtual bool Parse(LPCSTR pszText, WORD &x)
	{
		LPSTR pszTerm;
		x = (__int16)strtol(pszText, &pszTerm, 0);
		return (*pszTerm == 0);
	}
	// 
	virtual int GetWvct() { return wvctSigned; }
	// 
	virtual LPCTSTR GetHintText(int i) { return NULL; }
};

struct CWVCF_Unsigned : CWVCF
{
	// 
	virtual CString Format(WORD x)
	{
		CString strRet;
		strRet.Format("%u", 0U +x);
		return strRet;
	}
	// 
	virtual CString FormatDisp(WORD x) { return Format(x); }
	// 
	virtual bool Parse(LPCSTR pszText, WORD &x)
	{
		LPSTR pszTerm;
		x = strtol(pszText, &pszTerm, 0);
		return (*pszTerm == 0);
	}
	// 
	virtual int GetWvct() { return wvctUnsigned; }
	// 
	virtual LPCTSTR GetHintText(int i) { return NULL; }
};

struct CWVCF_Hex : CWVCF
{
	// 
	virtual CString Format(WORD x)
	{
		CString strRet;
		strRet.Format("%04X", 0U +x);
		return strRet;
	}
	// 
	virtual CString FormatDisp(WORD x) { return Format(x); }
	// 
	virtual bool Parse(LPCSTR pszText, WORD &x)
	{
		LPSTR pszTerm;
		x = strtol(pszText, &pszTerm, 16);
		return (*pszTerm == 0);
	}
	// 
	virtual int GetWvct() { return wvctHex; }
	// 
	virtual LPCTSTR GetHintText(int i) { return NULL; }
};

struct CWVCF_Flags : CWVCF
{
	// 
	virtual CString Format(WORD x)
	{
		CHAR c[17];
		WORD wTbl[16] = {0x8000,0x4000,0x2000,0x1000,0x0800,0x0400,0x0200,0x0100,0x0080,0x0040,0x0020,0x0010,0x0008,0x0004,0x0002,0x0001};
		for (int i = 0; i < 16; i++) {
			c[i] = ((x & wTbl[i]) != 0) ? '1' : '0';
		}
		c[16] = 0;
		return c;
	}
	// 
	virtual CString FormatDisp(WORD x) { return Format(x); }
	// 
	virtual bool Parse(LPCSTR pszText, WORD &x)
	{
		LPSTR pszTerm;
		x = strtol(pszText, &pszTerm, 2);
		return (*pszTerm == 0);
	}
	// 
	virtual int GetWvct() { return wvctFlags; }
	// 
	virtual LPCTSTR GetHintText(int i) { return NULL; }
};

struct CWVCF_HintFlags : CWVCF
{
	// 
	virtual CString Format(WORD x);
	// 
	virtual CString FormatDisp(WORD x);
	// 
	virtual bool Parse(LPCSTR pszText, WORD &x);
	// 
	virtual int GetWvct() { return wvctHintFlags; }
	// 
	virtual LPCTSTR GetHintText(int i);

	// 
	void SetHintText(LPCTSTR psz);

protected:
	// 
	list<CString> listHint;

};

struct CWVCF_KeyItem : CWVCF_Unsigned
{
	// 
	virtual CString FormatDisp(WORD x);
	// 
	virtual int GetWvct() { return wvctKeyItem; }
};

struct CWVCF_PrizeItem : CWVCF_Unsigned
{
	// 
	virtual CString FormatDisp(WORD x);
	// 
	virtual int GetWvct() { return wvctPrizeItem; }
};

struct CWVCF_MSItemsA : CWVCF_Unsigned
{
	// 
	virtual int GetWvct() { return wvctMSItemsA; }
};

struct CWVCF_MSItemsC : CWVCF_Unsigned
{
	// 
	virtual int GetWvct() { return wvctMSItemsC; }
};

struct CWVCF_B5353 : CWVCF_HintFlags
{
	// 
	virtual CString Format(WORD x);
	// 
	virtual CString FormatDisp(WORD x);
	// 
	virtual bool Parse(LPCSTR pszText, WORD &x);
	// 
	virtual int GetWvct() { return wvctB5353; }

protected:
	// 
	CString FormatB3(int iTextIdx, LPCTSTR pszDefText, UINT x);
};

struct CWVCF_SKText : CWVCF_Unsigned
{
	// 
	virtual int GetWvct() { return wvctSKText; }
};

#endif // !defined(AFX_WVCT_H__0D981393_AA8B_4BA0_B0A4_C8516E74ED99__INCLUDED_)
