EgtGeneral :
- aggiunta a CmdParser GetIdParam.
This commit is contained in:
@@ -254,6 +254,32 @@ CmdParser::ResetAllVariables( void)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
CmdParser::GetIdParam( const std::string& sParam, bool bNewAllowed)
|
||||
{
|
||||
int nVal ;
|
||||
// se nome di identificatore numerico
|
||||
if ( sParam[0] == '$') {
|
||||
// se variabile già definita, ne restituisco il valore
|
||||
if ( GetVariable( sParam, nVal))
|
||||
return nVal ;
|
||||
// se ammessa nuova definizione, provo ad inserirlo
|
||||
else if ( bNewAllowed &&
|
||||
AddVariable( sParam, CMD_ID_NULL))
|
||||
return CMD_ID_NULL ;
|
||||
// altrimenti errore
|
||||
else
|
||||
return CMD_ID_ERROR ;
|
||||
}
|
||||
// se identificatore numerico
|
||||
else if ( FromString( sParam, nVal))
|
||||
return nVal ;
|
||||
// altrimenti errore
|
||||
else
|
||||
return CMD_ID_ERROR ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const string
|
||||
CmdParser::GetInitSpaces( void)
|
||||
|
||||
@@ -31,6 +31,7 @@ class CmdParser : public ICmdParser
|
||||
virtual bool SetVariable( const std::string& sName, int nVal) ;
|
||||
virtual bool GetVariable( const std::string& sName, int& nVal) ;
|
||||
virtual bool RemoveVariable( const std::string& sName) ;
|
||||
virtual int GetIdParam( const std::string& sParam, bool bNewAllowed = false) ;
|
||||
virtual bool Run( const std::string& sCmdFile, bool bIsolated = true) ;
|
||||
virtual bool ExecLine( const std::string& sCmdLine, bool bIsolated = false) ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user