00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _COMMAND_H
00021 #define _COMMAND_H
00022
00023 #include <string>
00024 #include <map>
00025
00026
00027 class InSocket;
00028 class Parse;
00029
00030 typedef std::map<std::string,bool> strbool_m;
00031
00035 class Command
00036 {
00037 public:
00038 Command();
00039 Command(const std::string& cmd,bool need_wiz = false);
00040 Command(const std::string& cmd,char cc,bool need_wiz = false);
00041 virtual ~Command();
00042
00043 void AddArgument(const std::string& ,bool wiz = false);
00044 bool CheckArgument(InSocket *,const std::string&,std::string& );
00045 strbool_m& GetArguments() { return m_args; }
00046
00048 int Match(InSocket *,const std::string& cmd,const std::string& params);
00050 virtual void Execute(InSocket *,const std::string& arg,Parse& ) = 0;
00053 virtual void OnLine(InSocket *,const std::string& line,int state);
00055 virtual std::string Category() = 0;
00057 virtual std::string Description() { return ""; }
00058
00059 const std::string& GetCommand() { return m_cmd; }
00060 char GetCommandChar() { return m_cc; }
00061
00062 static Command *GetCommandFromChar(char cc);
00063
00064 bool NeedWiz() { return m_need_wiz; }
00065
00066 private:
00067 std::string m_cmd;
00068 char m_cc;
00069 static std::map<char,Command *> m_ccs;
00070 strbool_m m_args;
00071 bool m_need_wiz;
00072 };
00073
00074
00075
00076
00077 #endif // _COMMAND_H