From e696017fa8baa109e37c0cfebdafd19aa36a0cfd Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sat, 14 Jun 2014 17:58:02 +0000 Subject: [PATCH] EgtGeneral 1.5f2 : - a CmdParser aggiunta ContinueOnError. --- CmdParser.cpp | 23 ++++++++++++++++++++++- CmdParser.h | 2 ++ EgtGeneral.rc | Bin 11630 -> 11630 bytes 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CmdParser.cpp b/CmdParser.cpp index f371a76..15b9adb 100644 --- a/CmdParser.cpp +++ b/CmdParser.cpp @@ -37,6 +37,7 @@ CmdParser::CmdParser( void) m_nLev = 0 ; // assegno chiavi a funzioni di esecuzione m_ExecMgr.Init( 16) ; + m_ExecMgr.Insert( "CONTINUEONERROR", &CmdParser::ExecuteContinueOnError) ; m_ExecMgr.Insert( "COUNTER", &CmdParser::ExecuteCounter) ; m_ExecMgr.Insert( "DIR", &CmdParser::ExecuteDir) ; m_ExecMgr.Insert( "FILE", &CmdParser::ExecuteFile) ; @@ -133,7 +134,8 @@ CmdParser::Run( const string& sCmdFile, bool bIsolated) // interpretazione dei comandi del file m_nCurrLine = 0 ; m_nExec = DO ; - while ( bOk && m_nExec != STOP && TheScanner.GetLine( sLine)) { + m_bContinueOnError = false ; + while ( ( bOk || m_bContinueOnError) && m_nExec != STOP && TheScanner.GetLine( sLine)) { // assegno numero linea corrente m_nCurrLine = TheScanner.GetCurrLineNbr() ; // elimino gli spazi all'inizio e alla fine @@ -159,6 +161,10 @@ CmdParser::Run( const string& sCmdFile, bool bIsolated) sOut = GetInitSpaces() + "--- End ---" ; LOG_INFO( GetEGnLogger(), sOut.c_str()) } + else if ( m_bContinueOnError) { + sOut = GetInitSpaces() + "--- End : some errors ---" ; + LOG_ERROR( GetEGnLogger(), sOut.c_str()) + } else { sOut = GetInitSpaces() + "--- Stop : error ---" ; LOG_ERROR( GetEGnLogger(), sOut.c_str()) @@ -392,6 +398,21 @@ CmdParser::ExecCommand( const string& sCmd, const string& sParams) return false ; } +//---------------------------------------------------------------------------- +bool +CmdParser::ExecuteContinueOnError( const string& sCmd2, const STRVECTOR& vsParams) +{ + // nessun parametro + if ( vsParams.size() != 0) + return false ; + // imposto il flag di continuazione su errore + m_bContinueOnError = true ; + // emetto log + string sOut = GetInitSpaces() + "Continue on error (" + ToString( m_nCurrLine) + ")" ; + LOG_INFO( GetEGnLogger(), sOut.c_str()) + return true ; +} + //---------------------------------------------------------------------------- bool CmdParser::ExecuteCounter( const string& sCmd2, const STRVECTOR& vsParams) diff --git a/CmdParser.h b/CmdParser.h index c0e1d20..03afbea 100644 --- a/CmdParser.h +++ b/CmdParser.h @@ -46,6 +46,7 @@ class CmdParser : public ICmdParser bool ResetAllVariables( void) ; std::string GetInitSpaces( void) ; bool ExecCommand( const std::string& sCmd, const std::string& sParams) ; + bool ExecuteContinueOnError( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecuteCounter( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecuteDir( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecuteExec( const std::string& sCmd2, const STRVECTOR& vsParams) ; @@ -71,6 +72,7 @@ class CmdParser : public ICmdParser ExecManager m_ExecMgr ; int m_nLev ; Exec m_nExec ; + bool m_bContinueOnError ; int m_nCurrLine ; PerformanceCounter m_Counter ; StrStrVector m_DirReplace ; diff --git a/EgtGeneral.rc b/EgtGeneral.rc index 8a6bbefda7d8408c1ac8b863441b73d1d5a0a9aa..56cf11d9da565d716b08d38ae7f58ff0bb3909f6 100644 GIT binary patch delta 86 zcmaDC^)70|H#SD2&8x*uGfj?D3<5GYDrPcnuH$xL1`At)sEvy0jGI%0-Oz=6q@hAc In)h-806DN6?f?J) delta 86 zcmaDC^)70|H#SDY&8x*uGfj?D3<5GYDrPcnuH$xL1`At)sEvy0jGI%0-Oz=6q@hAc In)h-8061VA<^TWy