/* * CommandParser.h * * Copyright (C) 2008 Matthias Schiffer * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the * Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along * with this program. If not, see . */ #ifndef MAD_CLIENT_COMMANDPARSER_H_ #define MAD_CLIENT_COMMANDPARSER_H_ #include "export.h" #include #include #include #include #include #include namespace Mad { namespace Common { class Connection; } namespace Client { class Application; class SystemCommands; class UserCommands; class UserListCommands; class MAD_CLIENT_EXPORT CommandParser { private: friend class SystemCommands; friend class UserCommands; friend class UserListCommands; struct Command { const char* commands[3]; const char* cmdline; const char* desc; const char* longdesc; boost::function2 > function; }; static const Command commands[]; Application *application; Common::Connection *connection; bool disconnect; static const Command* findCommand(const Core::String& command); static void printUsage(const Core::String& command); std::map parseHostList(const std::vector &args, bool mustBeActive = false); void helpCommand(const std::vector &args); void listHostsCommand(const std::vector &args); void exitCommand(const std::vector &args); public: CommandParser(Application *application0, Common::Connection *connection0); Common::Connection *getConnection() const { return connection; } bool parse(const Core::String &cmd); void requestDisconnect() { exitCommand(std::vector()); } bool willDisconnect() const { return disconnect; } }; } } #endif /* MAD_CLIENT_COMMANDPARSER_H_ */