EgtGeneral 1.6e2 :
- aggiornamenti per cambio nome include di base - modifiche a LuaManager per direttorio librerie lua e ultima Require - FromString e ToString per STRVECTOR - corrette FromString per INTVECTOR e DBLVECTOR
This commit is contained in:
+30
-3
@@ -16,7 +16,7 @@
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "/EgtDEv/Include/EgnStringUtils.h"
|
||||
#include "/EgtDEv/Include/EGnStringUtils.h"
|
||||
#include <time.h>
|
||||
|
||||
using namespace std ;
|
||||
@@ -48,7 +48,7 @@ FromString( const string& sVal, INTVECTOR& vnVal)
|
||||
// ciclo sui caratteri della stringa
|
||||
const char* pStart = sVal.c_str() ;
|
||||
SkipSpaces( pStart) ;
|
||||
while ( *pStart >= '0' && *pStart <= '9') {
|
||||
while ( ( *pStart >= '0' && *pStart <= '9') || *pStart == '+' || *pStart == '-') {
|
||||
char* pStop ;
|
||||
int nVal = strtol( pStart, &pStop, 10) ;
|
||||
vnVal.push_back( nVal) ;
|
||||
@@ -74,7 +74,8 @@ FromString( const string& sVal, DBLVECTOR& vdVal)
|
||||
// ciclo sui caratteri della stringa
|
||||
const char* pStart = sVal.c_str() ;
|
||||
SkipSpaces( pStart) ;
|
||||
while ( *pStart >= '0' && *pStart <= '9') {
|
||||
while ( ( *pStart >= '0' && *pStart <= '9') ||
|
||||
*pStart == '+' || *pStart == '-' || *pStart == '.') {
|
||||
char* pStop ;
|
||||
double dVal = strtod( pStart, &pStop) ;
|
||||
vdVal.push_back( dVal) ;
|
||||
@@ -89,6 +90,13 @@ FromString( const string& sVal, DBLVECTOR& vdVal)
|
||||
return ( *pStart == '\0' && errno == 0) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
FromString( const std::string& sVal, STRVECTOR& vsVal)
|
||||
{
|
||||
return Tokenize( sVal, ",", vsVal) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const string
|
||||
ToString( double dVal, int nPrec)
|
||||
@@ -232,6 +240,25 @@ ToString( const DBLVECTOR& vdVal, int nPrec)
|
||||
return sDest ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const string
|
||||
ToString( const STRVECTOR& vsVal)
|
||||
{
|
||||
// se vettore vuoto, stringa vuota
|
||||
if ( vsVal.empty())
|
||||
return "" ;
|
||||
// costruisco la stringa
|
||||
int nLen = 0 ;
|
||||
for ( size_t i = 0 ; i < vsVal.size() ; ++ i)
|
||||
nLen += int( vsVal[i].length()) + 1 ;
|
||||
string sDest ;
|
||||
sDest.reserve( nLen) ;
|
||||
for ( size_t i = 0 ; i < vsVal.size() ; ++ i)
|
||||
sDest += vsVal[i] + "," ;
|
||||
sDest.pop_back() ;
|
||||
return sDest ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Split( const string& sString, const string& sSeparator, bool bFirstVsLast,
|
||||
|
||||
Reference in New Issue
Block a user