Files
EgtGeomKernel/NgeReader.h
Dario Sassi 5d09d963e7 EgtGeomKernel :
- modifiche per lettura/scrittura Zmap con tridexel.
2016-12-19 18:26:25 +00:00

75 lines
2.9 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : NgeReader.h Data : 14.04.14 Versione : 1.5d5
// Contenuto : Dichiarazione della classe NgeReader.
//
//
//
// Modifiche : 14.04.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "NgeConst.h"
#include "/EgtDev/Include/EGkPoint3d.h"
#include "/EgtDev/Include/EGkColor.h"
#include "/EgtDev/Include/EGnScanner.h"
#include "/EgtDev/Include/EgtStringBase.h"
#include <fstream>
//----------------------------------------------------------------------------
class NgeReader
{
public :
NgeReader( void)
: m_iPosStart( std::string::npos), m_bUngetKey( false), m_nFileVer() {}
~NgeReader( void)
{ Close() ; }
bool Init( const std::string& sFileIn) ;
bool Close( void) ;
int GetCurrPos( void) ;
bool ReadUchar( unsigned char& ucVal, const char* szSep, bool bEndL = false) ;
bool ReadBool( bool& bVal, const char* szSep, bool bEndL = false) ;
bool ReadInt( int& nVal, const char* szSep, bool bEndL = false) ;
bool ReadInt( unsigned int& nVal, const char* szSep, bool bEndL = false) ;
bool ReadDouble( double& dVal, const char* szSep, bool bEndL = false) ;
bool ReadVector( Vector3d& vtV, const char* szSep, bool bEndL = false) ;
bool ReadPoint( Point3d& ptP, const char* szSep, bool bEndL = false) ;
bool ReadPointW( Point3d& ptP, double& dW, const char* szSep, bool bEndL = false) ;
bool ReadFrame( Frame3d& frF, const char* szSep, bool bEndL = false) ;
bool ReadCol( Color& cCol, const char* szSep, bool bEndL = false) ;
bool ReadString( std::string& sVal, const char* szSep, bool bEndL = false) ;
bool ReadKey( int& nKey /* bEndL = true*/) ;
void UngetKey( void)
{ m_bUngetKey = true ; }
bool SetFileVersion( int nFileVer)
{ m_nFileVer = nFileVer ; return true ; }
int GetFileVersion( void)
{ return m_nFileVer ; }
private :
enum { NGE_ERROR = 0, NGE_ASCII = 1, NGE_BINARY = 2 } ;
private :
int NgeType( const std::string& sFile) ;
bool GetToken( std::string& sToken, const char* szSep, bool bEndL) ;
private :
bool m_bBinary ;
// per file binari
std::ifstream m_InFile ;
// per file ASCII
Scanner m_Scan ;
std::string::size_type m_iPosStart ;
std::string m_sLine ;
std::string m_sToken ;
// unget Key
bool m_bUngetKey ;
int m_nLastKey ;
// file version
int m_nFileVer ;
} ;