EgtGeomKernel : Modifiche per Scanner e Load/Save di GeomDB con nome file.

This commit is contained in:
Dario Sassi
2013-12-12 09:11:29 +00:00
parent a3308d8e23
commit fb0ca2906f
23 changed files with 50 additions and 78 deletions
+25 -13
View File
@@ -16,6 +16,7 @@
#include "GeomDB.h"
#include "GdbObj.h"
#include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Include/EgnStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include <new>
@@ -80,15 +81,15 @@ GeomDB::Clear( void)
//----------------------------------------------------------------------------
bool
GeomDB::Load( std::ifstream& osIn)
GeomDB::Load( const std::string& sFileIn)
{
bool bOk ;
bool bEnd ;
CScan TheScanner ;
bool bOk ;
bool bEnd ;
Scanner TheScanner ;
// inizializzo lo scanner
if ( ! TheScanner.Init( osIn)) {
if ( ! TheScanner.Init( sFileIn)) {
LOG_ERROR( m_pLogger, "GeomDbLoad : Error on Init ") ;
return false ;
}
@@ -115,7 +116,7 @@ GeomDB::Load( std::ifstream& osIn)
//----------------------------------------------------------------------------
bool
GeomDB::LoadStart( CScan& TheScanner)
GeomDB::LoadStart( Scanner& TheScanner)
{
string sLine ;
@@ -140,7 +141,7 @@ GeomDB::LoadStart( CScan& TheScanner)
//----------------------------------------------------------------------------
bool
GeomDB::LoadOneNode( CScan& TheScanner, bool& bEnd)
GeomDB::LoadOneNode( Scanner& TheScanner, bool& bEnd)
{
int nParentId ;
string sType ;
@@ -188,21 +189,32 @@ GeomDB::LoadOneNode( CScan& TheScanner, bool& bEnd)
//----------------------------------------------------------------------------
bool
GeomDB::Save( std::ofstream& osOut) const
GeomDB::Save( const std::string& sFileOut) const
{
bool bOk = true ;
ofstream ofSave ;
// apertura file
ofSave.open( stringtoW( sFileOut)) ;
if ( ! ofSave.good())
return false ;
// intestazione
osOut << "START" << endl ;
osOut << "GeomDB,1.4a4" << endl ;
ofSave << "START" << endl ;
ofSave << "GeomDB,1.4a4" << endl ;
// ciclo di scrittura degli oggetti
bool bOk = true ;
const GdbNode* pGdbNode = m_GrpRadix.GetFirstNode() ;
while ( pGdbNode != nullptr) {
// oggetto geometrico
if ( ! pGdbNode->Save( osOut))
if ( ! pGdbNode->Save( ofSave))
bOk = false ;
pGdbNode = pGdbNode->GetNext() ;
}
osOut << "END" << endl ;
ofSave << "END" << endl ;
// chiusura file
ofSave.close() ;
return bOk ;
}