EgtInterface 1.6e2 :
- esecutore e lua scorporato in EgtExecutor.
This commit is contained in:
+5
-59
@@ -15,81 +15,27 @@
|
||||
#include "stdafx.h"
|
||||
#include "API.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDEv/Include/EGnScan.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDEv/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EGnStringConverter.h"
|
||||
#include "/EgtDev/Include/EgtLogger.h"
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
typedef unordered_map< int, string> INTSTR_UMAP ;
|
||||
INTSTR_UMAP s_IdStringMap ;
|
||||
wstring s_wsMsg ;
|
||||
static wstring s_wsMsg ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtLoadMessages( const wchar_t* wsMsgFilePath)
|
||||
{
|
||||
// inizializzo lo scanner
|
||||
string sMsgFilePath = wstrztoA( wsMsgFilePath) ;
|
||||
Scanner scan ;
|
||||
if ( ! scan.Init( sMsgFilePath))
|
||||
return FALSE ;
|
||||
// pulisco la memoria
|
||||
s_IdStringMap.clear() ;
|
||||
s_wsMsg.clear() ;
|
||||
// riservo spazio
|
||||
s_IdStringMap.rehash( 1000) ;
|
||||
s_wsMsg.reserve( 128) ;
|
||||
// leggo le linee
|
||||
string sLine ;
|
||||
sLine.reserve( 128) ;
|
||||
string sNum ;
|
||||
sNum.reserve( 16) ;
|
||||
string sMsg ;
|
||||
sMsg.reserve( 128) ;
|
||||
int nNum ;
|
||||
int nCurrNum = - 1 ;
|
||||
while ( scan.GetLine( sLine)) {
|
||||
// divido la linea in due parti sul token '='
|
||||
Split( sLine, "=", true, sNum, sMsg) ;
|
||||
// la prima parte deve essere numerica
|
||||
if ( sNum.empty() || ! FromString( sNum, nNum)) {
|
||||
string sOut ;
|
||||
sOut = "Problem in " + sMsgFilePath + " at line " + ToString( scan.GetCurrLineNbr()) + " : " + sLine ;
|
||||
LOG_WARN( GetLogger(), sOut.c_str())
|
||||
continue ;
|
||||
}
|
||||
// la numerazione deve essere crescente
|
||||
if ( nNum <= nCurrNum) {
|
||||
string sOut ;
|
||||
sOut = "Error in " + sMsgFilePath + " at message " + sNum + " : " + sLine ;
|
||||
LOG_ERROR( GetLogger(), sOut.c_str())
|
||||
return FALSE ;
|
||||
}
|
||||
nCurrNum = nNum ;
|
||||
// converto i caratteri speciali
|
||||
ReplaceString( sMsg, "<br/>", "\n") ;
|
||||
// inserisco il messaggio in tabella
|
||||
if ( ! s_IdStringMap.emplace( nNum, sMsg).second)
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
// termino lo scanner
|
||||
return ( scan.Terminate() ? TRUE :FALSE) ;
|
||||
return ( ExeLoadMessages( wstrztoA( wsMsgFilePath)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const wchar_t*
|
||||
__stdcall EgtGetMsg( int nMsg)
|
||||
{
|
||||
// recupero il messaggio
|
||||
INTSTR_UMAP::iterator Iter = s_IdStringMap.find( nMsg) ;
|
||||
if ( Iter != s_IdStringMap.end())
|
||||
s_wsMsg = stringtoW( Iter->second) ;
|
||||
else
|
||||
s_wsMsg = stringtoW( ( "Msg" + ToString( nMsg))) ;
|
||||
s_wsMsg = stringtoW( ExeGetMsg( nMsg)) ;
|
||||
return s_wsMsg.c_str() ;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user