d92344f2bb
- - modifiche a NgeReader per semplificare e velocizzare lettura file binari.
77 lines
2.9 KiB
C++
77 lines
2.9 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2025
|
|
//----------------------------------------------------------------------------
|
|
// File : NgeReader.h Data : 29.12.25 Versione : 2.7l6
|
|
// 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"
|
|
|
|
struct gzFile_s ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
class NgeReader
|
|
{
|
|
public :
|
|
NgeReader( void)
|
|
: m_bBinary( false), m_InFile( nullptr), m_iPosStart( std::string::npos),
|
|
m_bUngetKey( false), m_nLastKey(), 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
|
|
gzFile_s* 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 ;
|
|
} ;
|