QBaseCmdParser Class Reference
[ApolloNetworking]

Inherited by QDaqCmdParser, QMsgCmdParser, and QSlowCmdParser.

List of all members.


Detailed Description

base class for server side network command parsing

Author:
Marco Pallavicini
This class (and possibly the classes that inherit from it) defines the syntax of the network communication protocol.
It parses the network command received by the client, splits it into command name, possible modifier and a list of par=val items, selects the appropriate QCommand based on command name, and associates the modifier and the parameters to it.

Public Member Functions

 QBaseCmdParser ()
 ctor
virtual ~QBaseCmdParser ()
 dtor
QCommandParse (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

Member Function Documentation

QCommand & QBaseCmdParser::Parse ( const char *  cmdString  ) 

parse network command string and return corresponding command object

Parameters:
cmdString network command string
This method performs all preliminary checks of cmdString commands before returning the correct QCommand object. If any of the check fails, a QNullCommand is returned, containing error informations.
The checks performed berore returning the appropriate QCommand are:
  • check command syntax
  • check that all the parameters for the appropriate command are set

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

Parameters:
name command name
handler object inheriting from QCommand that will be used to execute the command
This methods allows to specify the QCommand object to be returned by the Parse() method based on the command name contained in the argument of that method.
If a command named name is already present in the name/command map when a new command with the same name is added, the old command is overwritten.

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

Parameters:
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().


Member Data Documentation

std::map<std::string, QCommand*> QBaseCmdParser::commands [private]

key: command name, value: ptr to command handler object

Referenced by AddCommand(), Parse(), and QBaseCmdParser().


The documentation for this class was generated from the following files:

Generated on Tue Nov 16 10:50:04 2010 for CUORE Software by  doxygen 1.5.6