EgtGeneral 1.4a5 : Aggiunto confronto tra file di testo. CScan -> Scanner.
This commit is contained in:
@@ -22,49 +22,66 @@ using namespace std ;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
CScan::CScan( void)
|
||||
Scanner::Scanner( void)
|
||||
{
|
||||
m_nLineNbr = 0 ;
|
||||
m_pInFile = NULL ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
CScan::~CScan( void)
|
||||
Scanner::~Scanner( void)
|
||||
{
|
||||
Terminate() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CScan::Init( ifstream& InFile)
|
||||
Scanner::Init( const std::string& sFile, const char* szRemInit)
|
||||
{
|
||||
// verifico che il file passato sia regolarmente aperto per lettura
|
||||
if ( ! InFile.is_open())
|
||||
return false ;
|
||||
|
||||
// assegno il file
|
||||
m_pInFile = &InFile ;
|
||||
// apertura del file di ingresso
|
||||
m_InFile.open( stringtoW( sFile), ios::in) ;
|
||||
|
||||
// reset numero linea corrente
|
||||
m_nLineNbr = 0 ;
|
||||
|
||||
return ( ! m_pInFile->fail()) ;
|
||||
// salvo path file
|
||||
m_sFName = sFile ;
|
||||
|
||||
// assegno i caratteri di inizio commento
|
||||
if ( szRemInit != NULL)
|
||||
m_sRemInit = szRemInit ;
|
||||
else
|
||||
m_sRemInit = "//" ;
|
||||
|
||||
return ( ! m_InFile.fail()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CScan::GetLine( string& sLine)
|
||||
Scanner::Terminate( void)
|
||||
{
|
||||
if ( m_pInFile == nullptr || ! m_pInFile->is_open())
|
||||
if ( m_InFile.is_open())
|
||||
m_InFile.close() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scanner::GetLine( string& sLine)
|
||||
{
|
||||
if ( ! m_InFile.is_open())
|
||||
return false ;
|
||||
|
||||
do {
|
||||
if ( ! getline( *m_pInFile, sLine))
|
||||
if ( ! getline( m_InFile, sLine)) {
|
||||
sLine = "" ;
|
||||
return false ;
|
||||
}
|
||||
if ( m_nLineNbr == 0)
|
||||
TrimUtf8Bom( sLine) ;
|
||||
Trim( sLine) ;
|
||||
m_nLineNbr ++ ;
|
||||
} while ( sLine.empty() || sLine.find( "//") == 0) ;
|
||||
} while ( sLine.empty() || sLine.find( m_sRemInit) == 0) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user