-
Notifications
You must be signed in to change notification settings - Fork 4
/
Command.h
65 lines (48 loc) · 1.47 KB
/
Command.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Command.h: interface for the CCommand class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_COMMAND_H__2E14804B_6FDE_412F_8676_4FB4647B0926__INCLUDED_)
#define AFX_COMMAND_H__2E14804B_6FDE_412F_8676_4FB4647B0926__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CCommand;
typedef BOOL (CCommand::* TProcessCmd)();
typedef struct _tagCmdMapEntry
{
LPCTSTR lpCmd;
TProcessCmd pf;
}CmdMapEntry;
#define DECLARE_COMMAND_MAP() \
static CmdMapEntry _CmdMapEntry[]; \
static const CmdMapEntry* _GetBaseCommandMap(); \
virtual CmdMapEntry* GetCommandMap();
#define BEGIN_COMMAND_MAP(class, baseclass) \
const CmdMapEntry* class::_GetBaseCommandMap() {return baseclass::_CmdMapEntry;} \
CmdMapEntry* class::GetCommandMap() {return class::_CmdMapEntry;} \
CmdMapEntry class::_CmdMapEntry[] = {
#define COMMAND_MAP_ENTRY(cmd , op) \
{cmd , (TProcessCmd )op} ,
#define END_COMMAND_MAP() \
{NULL , NULL}};
class CCommand
{
public:
CCommand();
virtual ~CCommand();
BOOL Run();
BOOL SetCommandMap(CmdMapEntry* pMap);
virtual CmdMapEntry* GetCommandMap();
int GetParamCount();
LPCTSTR GetCmd();
LPCTSTR GetParam(int nIndex);
BOOL Parse(LPCTSTR lpstr);
protected:
virtual int OutputInfor(LPCTSTR pszFormat, ...);
protected:
char m_szCmd[0xff];
LPCTSTR m_arParam[0x16];
int m_nParamCount;
static CmdMapEntry _CmdMapEntry[];
};
#endif // !defined(AFX_COMMAND_H__2E14804B_6FDE_412F_8676_4FB4647B0926__INCLUDED_)