71 lines
1.9 KiB
C++
71 lines
1.9 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalS
|
|
//----------------------------------------------------------------------------
|
|
// File : Scan.cpp Data : 30.09.13 Versione : 1.2a1
|
|
// Contenuto : Implementazione della classe CCmdScan.
|
|
// Scansione di file di testo con codifica UTF-8 (anche con BOM)
|
|
// e quindi anche ASCII.
|
|
//
|
|
//
|
|
// Modifiche : 30.09.13 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "/EgtDEv/Include/EGnScan.h"
|
|
#include "/EgtDEv/Include/EGnStringUtils.h"
|
|
#include "/EgtDEv/Include/EGnStringConverter.h"
|
|
|
|
using namespace std ;
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
CScan::CScan( void)
|
|
{
|
|
m_nLineNbr = 0 ;
|
|
m_pInFile = NULL ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
CScan::~CScan( void)
|
|
{
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
CScan::Init( ifstream& InFile)
|
|
{
|
|
// verifico che il file passato sia regolarmente aperto per lettura
|
|
if ( ! InFile.is_open())
|
|
return false ;
|
|
|
|
// assegno il file
|
|
m_pInFile = &InFile ;
|
|
|
|
// reset numero linea corrente
|
|
m_nLineNbr = 0 ;
|
|
|
|
return ( ! m_pInFile->fail()) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
CScan::GetLine( string& sLine)
|
|
{
|
|
if ( m_pInFile == nullptr || ! m_pInFile->is_open())
|
|
return false ;
|
|
|
|
do {
|
|
if ( ! getline( *m_pInFile, sLine))
|
|
return false ;
|
|
if ( m_nLineNbr == 0)
|
|
TrimUtf8Bom( sLine) ;
|
|
Trim( sLine) ;
|
|
m_nLineNbr ++ ;
|
|
} while ( sLine.empty() || sLine.find( "//") == 0) ;
|
|
|
|
return true ;
|
|
}
|