EgtGeneral : aggiunto interprete di comandi Tsc.
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CmdScanner.cpp Data : 25.11.13 Versione : 1.3a1
|
||||
// Contenuto : Implementazione della classe CmdScanner.
|
||||
// Scansione di file di testo con codifica UTF-8 (anche con BOM)
|
||||
// e quindi anche ASCII.
|
||||
//
|
||||
//
|
||||
// Modifiche : 19.01.13 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgnStringConverter.h"
|
||||
#include "CmdScanner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
CmdScanner::CmdScanner( void)
|
||||
{
|
||||
m_nLineNbr = 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
CmdScanner::~CmdScanner( void)
|
||||
{
|
||||
Terminate() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CmdScanner::Initialize( wstring sCmdFile)
|
||||
{
|
||||
// se già aperto, lo chiudo
|
||||
Terminate() ;
|
||||
|
||||
// apertura del file di ingresso
|
||||
m_CmdFile.open( sCmdFile, ios::in) ;
|
||||
|
||||
// reset numero linea corrente
|
||||
m_nLineNbr = 0 ;
|
||||
|
||||
// salvo path file
|
||||
m_sFName = wstringtoA( sCmdFile) ;
|
||||
|
||||
return ( ! m_CmdFile.fail()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CmdScanner::Terminate( void)
|
||||
{
|
||||
if ( m_CmdFile.is_open())
|
||||
m_CmdFile.close() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CmdScanner::GetLine( string& sLine)
|
||||
{
|
||||
if ( ! m_CmdFile.is_open())
|
||||
return false ;
|
||||
|
||||
do {
|
||||
if ( ! getline( m_CmdFile, sLine))
|
||||
return false ;
|
||||
if ( m_nLineNbr == 0)
|
||||
TrimUtf8Bom( sLine) ;
|
||||
TrimLeft( sLine) ;
|
||||
m_nLineNbr ++ ;
|
||||
} while ( sLine.empty() || sLine.find( "//") == 0) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
Reference in New Issue
Block a user