This class (and possibly the classes that inherit from it) defines the syntax of the network communication protocol.
Public Member Functions | |
QBaseCmdParser () | |
ctor | |
virtual | ~QBaseCmdParser () |
dtor | |
QCommand & | Parse (const char *cmdString) |
parse network command string and return corresponding command object | |
Protected Member Functions | |
virtual void | AddCommand (const std::string &name, QCommand *handler) |
associate command name to a specific QCommand object | |
Private Member Functions | |
bool | ParseParameters (std::string parString, std::map< std::string, std::list< std::string > > &parMap) const |
parse parameters in source string pars and fill a map where parameter names and values are splitted | |
Private Attributes | |
std::map< std::string, QCommand * > | commands |
QCommand & QBaseCmdParser::Parse | ( | const char * | cmdString | ) |
parse network command string and return corresponding command object
cmdString | network command string |
References commands, ParseParameters(), QStringHandler::Split(), and QNetworkString::SplitCommandAndParams().
Referenced by QCommandHandler::HandleCommand().
void QBaseCmdParser::AddCommand | ( | const std::string & | name, | |
QCommand * | handler | |||
) | [protected, virtual] |
associate command name to a specific QCommand object
name | command name | |
handler | object inheriting from QCommand that will be used to execute the command |
References commands.
bool QBaseCmdParser::ParseParameters | ( | std::string | parString, | |
std::map< std::string, std::list< std::string > > & | parMap | |||
) | const [private] |
parse parameters in source string pars and fill a map where parameter names and values are splitted
parString | source string containing pars whose format must be par1=val1;par2=val2_1,val2_2;par3=val3... | |
parMap | map filled with multiple value parameters (key is parameter name, value is a list of parameter values formatted as strings) |
References QStringHandler::DoubleSwallowSpaces(), QNetworkString::RestoreNewLines(), QStringHandler::Split(), and QStringHandler::UnEscape().
Referenced by Parse().
std::map<std::string, QCommand*> QBaseCmdParser::commands [private] |
key: command name, value: ptr to command handler object
Referenced by AddCommand(), Parse(), and QBaseCmdParser().