#ifndef COMMAND_H #define COMMAND_H #include #include //#include "shell.h" #include "option.h" #include "commandexecutor.h" using std::string; using std::vector; namespace mshconsole{ class Command { class OptionNotParsedCorrectlyException { string optarg; public: OptionNotParsedCorrectlyException(const string& s) : optarg(s) {} string getOptarg(){ return optarg; } }; class CommandNameNotValidException {}; class NotRightArgException {}; const string name; void checkObj(); vector longOpts; vector shortOpts; public: class Data{ public: enum States{ STRING=4, TRUE=2, FALSE=1 }; class MultipleDefinitionException{}; private: string sData; const Option* of; enum States state; static const string EMPTY; bool isSDataValorized; Data(const Option* o) : sData(), state(Data::FALSE), isSDataValorized(false), of(o) {} public: void set(bool b); void set(const string& s); enum States getState() const; const string& getData() const; bool getBoolState() const; friend class Command; friend class Datas; }; class Datas : public vector{ public: Data* getOptData(const string& optionName) const; }; Command(const string& n, int (*funcptr)(CommandExecutor* whoExecuted,const Datas& data, const vector argv)); Command(const Command&); ~Command(); string getName(); int execute(const vector*, CommandExecutor*); void addOption(Option* a); private: int (*funcCommand)(CommandExecutor* whoExecuted,const Datas& data, const vector argv); }; } #endif // COMMAND_H