26 Commits

Author SHA1 Message Date
Dario Sassi cd6160b319 EgtGeneral 3.1c2 :
- ricompilazione con cambio versione.
2026-03-23 17:45:40 +01:00
Dario Sassi f58045441d EgtGeneral 3.1c1 :
- ricompilazione con cambio versione.
2026-03-05 14:43:32 +01:00
Dario Sassi b842032948 EgtGeneral :
- aggiunta funzione EraseNonEmptyDirectory.
2026-01-09 19:00:13 +01:00
Dario Sassi 8ce22a9b4c EgtGeneral :
- le funzioni ToStringAdv spostate negli include in cui erano dichiarate.
2026-01-09 15:57:20 +01:00
Dario Sassi 4436a88b9d EgtGeneral 3.1a1 :
- ricompilazione con cambio major versione.
2026-01-02 12:32:50 +01:00
Dario Sassi 0e650a034d EgtGeneral 2.7l6 :
- piccola miglioria nello Scanner per il riconoscimento  delle linee di commento.
2025-12-29 08:43:45 +01:00
Dario Sassi e07e0e553f EgtGeneral 2.7k1 :
- ricompilazione per passaggio a C++ 20
2025-11-01 17:18:29 +01:00
Dario Sassi df77db20d2 EgtGeneral 2.7i1 :
- aggiunta ToStringAdv per long long.
2025-09-18 10:37:40 +02:00
Dario Sassi a94693ba8d EgtGeneral 2.7h1 :
- ricompilazione con cambio versione.
2025-08-22 11:37:55 +02:00
Dario Sassi 37e5a2b802 EgtGeneral 2.7g1 :
- ricompilazione con cambio versione.
2025-07-03 10:13:16 +02:00
Dario Sassi 9415a0ff92 EgtGeneral 2.7e1 :
- ricompilazione con cambio versione.
2025-05-16 18:56:09 +02:00
Dario Sassi 9ef479bed3 EgtGeneral 2.7b1 :
- ricompilazione con cambio versione.
2025-03-02 19:41:05 +01:00
Dario Sassi 5a7a4c2b6d EgtGeneral :
- aggiunte funzioni ToStringAdv per interi.
2025-01-10 16:25:49 +01:00
Dario Sassi 70a503c15a EgtGeneral 2.7a1 :
- cambio annuale di versione
- compilazione 32bit senza più limiti per Windows XP
- modifiche a ToString per uso di std::to_chars.
2025-01-09 17:55:56 +01:00
Dario Sassi 7d59b48f1a EgtGeneral :
- modifiche a FromString con integer per uso libreria fast_float.
2025-01-06 18:14:22 +01:00
Dario Sassi d9433601ef EgtGeneral :
- modifiche a FromString con double per uso libreria fast_float
2025-01-03 12:17:34 +01:00
Dario Sassi 093706532e EgtGeneral 2.6l2 :
- ricompilazione con cambio versione.
2024-12-05 17:39:09 +01:00
Dario Sassi 080e12a7be EgtGeneral 2.6h2 :
- ricompilazione con cambio versione.
2024-08-30 10:11:24 +02:00
Dario Sassi 606142c0c9 EgtGeneral 2.6g5 :
- ricompilazione con cambio versione.
2024-07-18 20:35:42 +02:00
Dario Sassi 295d312b29 EgtGeneral 2.6g1 :
- ricompilazione per aggiornamento lua.
2024-07-01 18:00:04 +02:00
Dario Sassi dca079dc25 EgtGeneral 2.6e1 :
- ricompilazione per modifiche a gestione chiave di rete.
2024-04-30 16:53:22 +02:00
Dario Sassi 59c8c9f589 EgtGeneral :
- corretta versione.
2024-04-09 14:45:35 +02:00
Dario Sassi 22872023b7 EgtGeneral 2.6d2 :
- ricompilazione per modifiche a EgtLock.
2024-04-09 14:43:41 +02:00
Dario Sassi 1707f324ef EgtGeneral 2.6a3 :
- la funzione ToString per i double ora ha un parametro opzionale in più (numero di errore).
2024-01-31 09:41:26 +01:00
Dario Sassi 49cbf8b5f1 EgtGeneral 2.6a2 :
- ricompilazione con cambio versione.
2024-01-25 18:22:44 +01:00
Dario Sassi 85e6a8b561 EgtGeneral 2.6a1 :
- ricompilazione con cambio versione.
2024-01-16 11:06:16 +01:00
6 changed files with 88 additions and 148 deletions
BIN
View File
Binary file not shown.
+7 -7
View File
@@ -22,14 +22,14 @@
<ProjectGuid>{D216A77C-ACE6-4012-B4E1-61E5C9102E9A}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>EgtGeneral</RootNamespace>
<WindowsTargetPlatformVersion>10.0.20348.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -42,7 +42,7 @@
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -103,7 +103,7 @@
<PreprocessorDefinitions>WIN32;I_AM_EGN;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<OpenMPSupport>false</OpenMPSupport>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -125,7 +125,7 @@ copy $(TargetPath) \EgtProg\DllD32</Command>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;I_AM_EGN;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
</ClCompile>
<Link>
@@ -157,7 +157,7 @@ copy $(TargetPath) \EgtProg\DllD64</Command>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<OpenMPSupport>false</OpenMPSupport>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -190,7 +190,7 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<OpenMPSupport>false</OpenMPSupport>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>-Wno-tautological-undefined-compare</AdditionalOptions>
</ClCompile>
<Link>
+11
View File
@@ -17,6 +17,7 @@
#include "\EgtDev\Include\EGnStringUtils.h"
#include "\EgtDev\Include\EgtStringConverter.h"
#include <io.h>
#include <filesystem>
using namespace std ;
@@ -297,6 +298,16 @@ EraseDirectory( const string& sDir)
return( ::RemoveDirectoryW( sDirW.c_str()) != FALSE) ;
}
//-----------------------------------------------------------------------------
bool
EraseNonEmptyDirectory( const string& sDir)
{
wstring sDirW = stringtoW( sDir) ;
error_code Ec ;
uintmax_t nRes = filesystem::remove_all( sDirW, Ec) ;
return ( nRes > 0) ;
}
//-----------------------------------------------------------------------------
bool
FindAllDirectories( const string& sDirSpec, STRVECTOR& vsDirNames)
+1 -1
View File
@@ -107,7 +107,7 @@ GetOsInfo( string& sOsInfo)
else
GetSystemInfo( &si) ;
// Assegnazione dati ( solo NT, 2000, XP, Vista, 7, 8, 8.1, 10)
// Assegnazione dati ( solo NT, 2000, XP, Vista, 7, 8, 8.1, 10, 11)
if ( osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
// Nome del prodotto
if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 2) {
+1 -1
View File
@@ -109,7 +109,7 @@ Scanner::GetLine( string& sLine)
// incremento contatore di linee
m_nLineNbr ++ ;
} while ( ( m_bSkipEmptyLine && sLine.empty()) ||
( m_bFindRem && sLine.find( m_sRemInit) == 0)) ;
( m_bFindRem && sLine.rfind( m_sRemInit, 0) == 0)) ;
m_nDeltaLineUnget = m_nLineNbr - nOldLineNbr ;
}
return true ;
+68 -139
View File
@@ -2,13 +2,13 @@
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : StringUtils.cpp Data : 13.01.15 Versione : 1.6a2
// Contenuto : Implementazione delle funzioni di utilità per le stringhe.
// Contenuto : Implementazione delle funzioni di utilità per le stringhe.
//
//
//
// Modifiche : 20.01.13 DS Creazione modulo.
// 02.12.13 DS Agg. FromString per Vector3d, Point3d e Point3d+W.
// 19.01.14 DS Tokenize con Atom ora funziona su più livelli.
// 19.01.14 DS Tokenize con Atom ora funziona su più livelli.
// 17.03.14 DS Agg. CurrDateTime.
// 13.01.15 DS Agg. CurrDateTime.
//
@@ -17,7 +17,7 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "DllMain.h"
#include "/EgtDEv/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EgtILogger.h"
#include <time.h>
@@ -31,38 +31,35 @@ SkipSpaces( const char*& pC)
++ pC ;
}
//----------------------------------------------------------------------------
static inline void
SkipSpaces( char*& pC)
{
while ( *pC == ' ' || *pC == '\t')
++ pC ;
}
//----------------------------------------------------------------------------
bool
FromString( const string& sVal, INTVECTOR& vnVal)
{
// pulisco il vettore dei risultati
vnVal.clear() ;
// reset errori di conversione
errno = 0 ;
// ciclo sui caratteri della stringa
const char* pStart = sVal.c_str() ;
SkipSpaces( pStart) ;
while ( ( *pStart >= '0' && *pStart <= '9') || *pStart == '+' || *pStart == '-') {
char* pStop ;
int nVal = strtol( pStart, &pStop, 10) ;
vnVal.push_back( nVal) ;
SkipSpaces( pStop) ;
if ( *pStop == '\0' && errno == 0)
return true ;
if ( *pStop != ',' || errno != 0)
// se stringa vuota, esco con successo (per compatibilità con versione precedente)
if ( IsEmptyOrSpaces( sVal))
return true ;
// ciclo sulla stringa
const char* pFirst = sVal.data() ;
while ( true) {
int nVal ;
auto answer = fast_float::from_chars_advanced( pFirst, sVal.data() + sVal.size(), nVal, FAST_FLOAT_OPTS) ;
if ( answer.ec != std::errc())
return false ;
pStart = pStop + 1 ;
SkipSpaces( pStart) ;
vnVal.push_back( nVal) ;
const char* pLast = answer.ptr ;
SkipSpaces( pLast) ;
if ( pLast[0] == '\0')
return true ;
if ( pLast[0] != ',')
return false ;
pFirst = pLast + 1 ;
SkipSpaces( pFirst) ;
if ( pFirst[0] == '\0')
return true ;
}
return ( *pStart == '\0' && errno == 0) ;
// posizione non raggiungibile (return inutile)
}
//----------------------------------------------------------------------------
@@ -71,25 +68,29 @@ FromString( const string& sVal, DBLVECTOR& vdVal)
{
// pulisco il vettore dei risultati
vdVal.clear() ;
// reset errori di conversione
errno = 0 ;
// ciclo sui caratteri della stringa
const char* pStart = sVal.c_str() ;
SkipSpaces( pStart) ;
while ( ( *pStart >= '0' && *pStart <= '9') ||
*pStart == '+' || *pStart == '-' || *pStart == '.') {
char* pStop ;
double dVal = strtod( pStart, &pStop) ;
vdVal.push_back( dVal) ;
SkipSpaces( pStop) ;
if ( *pStop == '\0' && errno == 0)
return true ;
if ( *pStop != ',' || errno != 0)
// se stringa vuota, esco con successo (per compatibilità con versione precedente)
if ( IsEmptyOrSpaces( sVal))
return true ;
// ciclo sulla stringa
const char* pFirst = sVal.data() ;
while ( true) {
double dVal ;
auto answer = fast_float::from_chars( pFirst, sVal.data() + sVal.size(), dVal, FAST_FLOAT_FMT) ;
if ( answer.ec != std::errc())
return false ;
pStart = pStop + 1 ;
SkipSpaces( pStart) ;
vdVal.push_back( dVal) ;
const char* pLast = answer.ptr ;
SkipSpaces( pLast) ;
if ( pLast[0] == '\0')
return true ;
if ( pLast[0] != ',')
return false ;
pFirst = pLast + 1 ;
SkipSpaces( pFirst) ;
if ( pFirst[0] == '\0')
return true ;
}
return ( *pStart == '\0' && errno == 0) ;
// posizione non raggiungibile (return inutile)
}
//----------------------------------------------------------------------------
@@ -101,85 +102,31 @@ FromString( const string& sVal, STRVECTOR& vsVal)
//----------------------------------------------------------------------------
const string
ToString( double dVal, int nPrec)
ToString( double dVal, int nPrec, int* pnErr)
{
const double BIG_NUMBER = 1e10 ;
const int BIG_DIGITNBR = 10 ;
const int MAX_PREC = 12 ;
// verifico la precisione
bool bCutTrailingZero = ( nPrec >= 0) ;
// verifiche (precisione e grande numero)
bool bCutTrailingZero = ( nPrec > 0) ;
nPrec = min( abs( nPrec), MAX_PREC) ;
bool bStdNbr = ( abs( dVal) < BIG_NUMBER) ;
// converto la mantissa
char szBuff[24] ;
int nErr, nDecimal, nSign ;
if ( abs( dVal) < BIG_NUMBER)
nErr = _fcvt_s( szBuff, dVal, nPrec, &nDecimal, &nSign) ;
else
nErr = _ecvt_s( szBuff, dVal, BIG_DIGITNBR + nPrec, &nDecimal, &nSign) ;
// se errore, ritorno stringa opportuna
if ( nErr != 0) {
_ASSERT( 0) ;
string sErr = "ToString Error : " + ToString( nErr) ;
LOG_ERROR( GetEGnLogger(), sErr.c_str())
// converto in stringa
const int nBuffSize = 32 ;
char szBuff[nBuffSize]{} ;
auto Res = ( bStdNbr ? to_chars( szBuff, szBuff + nBuffSize - 1, dVal, chars_format::fixed, nPrec) :
to_chars( szBuff, szBuff + nBuffSize - 1, dVal, chars_format::scientific)) ;
if ( Res.ec != std::errc()) {
string sOut = make_error_code( Res.ec).message() ;
LOG_ERROR( GetEGnLogger(), sOut.c_str())
if ( pnErr != nullptr)
*pnErr = int( Res.ec) ;
return "#Error" ;
}
// se buffer vuoto, risultato è numero 0
if ( szBuff[0] == '\0')
return "0" ;
// verifica per forma esponenziale
int nExp ;
if ( nDecimal > BIG_DIGITNBR) {
nExp = nDecimal - 1 ;
nDecimal = 1 ;
}
else
nExp = 0 ;
// puntatori a inizio stringhe
char szDest[32] ;
char* pBuff = szBuff ;
char* pDest = szDest ;
// eventuale inserimento segno '-'
if ( nSign != 0) {
*pDest = '-' ;
pDest ++ ;
} ;
// gestione decimali dopo 0
if ( nDecimal <= 0) {
*pDest = '0' ;
pDest ++ ;
*pDest = '.' ;
pDest ++ ;
for ( ; nDecimal < 0 ; nDecimal ++) {
*pDest = '0' ;
pDest ++ ;
}
nDecimal -- ;
}
// gestione cifre e .
while ( *pBuff != '\0') {
if ( *pBuff == '#') { // NAN, INFINITY, INDEFINITE
_ASSERT( 0) ;
string sErr = "ToString Error : " + string( szBuff) ;
LOG_ERROR( GetEGnLogger(), sErr.c_str())
}
if ( nDecimal == 0) {
*pDest = '.' ;
pDest ++ ;
}
nDecimal -- ;
*pDest = *pBuff ;
pDest ++ ;
pBuff ++ ;
}
*pDest = '\0' ;
// se abilitato e inserito un punto decimale tolgo i trailing zero
if ( bCutTrailingZero && nDecimal < 0) {
if ( bCutTrailingZero && bStdNbr) {
char* pDest = Res.ptr ;
pDest -- ;
while ( *pDest == '0') {
*pDest = '\0' ;
@@ -187,33 +134,15 @@ ToString( double dVal, int nPrec)
}
if ( *pDest == '.')
*pDest = '\0' ;
else
pDest ++ ;
}
// aggiungo eventuale esponente (sempre compreso tra 9 e 308)
if ( nExp > 0) {
*pDest = 'e' ;
pDest ++ ;
int nTmp = nExp ;
if ( nTmp >= 100) {
*pDest = '0' + ( nTmp / 100) ;
pDest ++ ;
nTmp = nTmp % 100 ;
}
if ( nTmp >= 10 || nExp >= 100) {
*pDest = '0' + ( nTmp / 10) ;
pDest ++ ;
nTmp = nTmp % 10 ;
}
*pDest = '0' + nTmp ;
pDest ++ ;
*pDest = '\0' ;
}
if ( szDest[0] == '-' && szDest[1] == '0' && szDest[2] == '\0')
if ( pnErr != nullptr)
*pnErr = 0 ;
if ( szBuff[0] == '-' && szBuff[1] == '0' && szBuff[2] == '\0')
return "0" ;
else
return szDest ;
return szBuff ;
}
//----------------------------------------------------------------------------
@@ -354,7 +283,7 @@ Tokenize( const string& sString, const string& sSeparators,
return false ;
// pulisco il risultato
vsTokens.clear() ;
// se la stringa è vuota non c'è niente da cercare
// se la stringa è vuota non c'è niente da cercare
if ( sString.empty())
return true ;
// parto dall'inizio
@@ -388,7 +317,7 @@ Tokenize( const string& sString, const string& sSeparators,
else
++ iPosEnd ;
}
// se è rimasto un ultimo token
// se è rimasto un ultimo token
if ( iPosStart != string::npos)
vsTokens.push_back( sString.substr( iPosStart)) ;
return true ;