Logo
~Sockets~
~Examples~
~Contact~

Command.h

Go to the documentation of this file.
00001 // Command.h
00002 // released 2006-09-25
00003 /*
00004 Copyright (C) 2006  Anders Hedstrom (grymse@alhem.net)
00005 
00006 This program is free software; you can redistribute it and/or
00007 modify it under the terms of the GNU General Public License
00008 as published by the Free Software Foundation; either version 2
00009 of the License, or (at your option) any later version.
00010 
00011 This program is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with this program; if not, write to the Free Software
00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4