Include : spostamento conversioni std::string da/a Point3d e Vector3d.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EgkStringUtils3d.h Data : 31.01.14 Versione : 1.5a9
|
||||
// Contenuto : Dichiarazione delle funzioni di utilità 3d per le stringhe.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 31.01.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGkPoint3d.h"
|
||||
|
||||
//----------------------- Macro per import/export -----------------------------
|
||||
#undef EGK_EXPORT
|
||||
#if defined( I_AM_EGK) // da definirsi solo nella DLL
|
||||
#define EGK_EXPORT __declspec( dllexport)
|
||||
#else
|
||||
#define EGK_EXPORT __declspec( dllimport)
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
EGK_EXPORT bool FromString( const std::string& sVal, Vector3d& vtVal) ;
|
||||
EGK_EXPORT bool FromString( const std::string& sVal, Point3d& ptVal) ;
|
||||
EGK_EXPORT bool FromString( const std::string& sVal, Point3d& ptVal, double& dW) ;
|
||||
inline const std::string
|
||||
ToString( Vector3d vtVal, int nPrec = 9)
|
||||
{ std::string sBuff ;
|
||||
sBuff.reserve( 3 * 32 + 2) ;
|
||||
sBuff = ToString( vtVal.x, nPrec) + ',' + ToString( vtVal.y, nPrec) + ',' + ToString( vtVal.z, nPrec) ;
|
||||
return sBuff ; }
|
||||
inline const std::string
|
||||
ToString( Point3d ptVal, int nPrec = 6)
|
||||
{ std::string sBuff ;
|
||||
sBuff.reserve( 3 * 32 + 2) ;
|
||||
sBuff = ToString( ptVal.x, nPrec) + ',' + ToString( ptVal.y, nPrec) + ',' + ToString( ptVal.z, nPrec) ;
|
||||
return sBuff ; }
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include "/EgtDev/Include/EgnStringBase.h"
|
||||
#include "/EgtDEv/Include/EGkPoint3d.h"
|
||||
|
||||
//----------------------- Macro per import/export -----------------------------
|
||||
#undef EGN_EXPORT
|
||||
@@ -88,26 +87,11 @@ FromString( const std::string& sVal, double& dVal)
|
||||
pStart = sVal.c_str() ;
|
||||
dVal = strtod( pStart, &pStop) ;
|
||||
return ( pStop != pStart && *pStop == '\0' && errno == 0) ; }
|
||||
EGN_EXPORT bool FromString( const std::string& sVal, Vector3d& vtVal) ;
|
||||
EGN_EXPORT bool FromString( const std::string& sVal, Point3d& ptVal) ;
|
||||
EGN_EXPORT bool FromString( const std::string& sVal, Point3d& ptVal, double& dW) ;
|
||||
EGN_EXPORT const std::string ToString( int nVal, int nPrec = 1) ;
|
||||
inline const std::string
|
||||
ToString( bool bVal)
|
||||
{ return std::string( ( bVal ? "1" : "0")) ; }
|
||||
EGN_EXPORT const std::string ToString( double dVal, int nPrec = 6) ;
|
||||
inline const std::string
|
||||
ToString( Vector3d vtVal, int nPrec = 9)
|
||||
{ std::string sBuff ;
|
||||
sBuff.reserve( 3 * 32 + 2) ;
|
||||
sBuff = ToString( vtVal.x, nPrec) + ',' + ToString( vtVal.y, nPrec) + ',' + ToString( vtVal.z, nPrec) ;
|
||||
return sBuff ; }
|
||||
inline const std::string
|
||||
ToString( Point3d ptVal, int nPrec = 6)
|
||||
{ std::string sBuff ;
|
||||
sBuff.reserve( 3 * 32 + 2) ;
|
||||
sBuff = ToString( ptVal.x, nPrec) + ',' + ToString( ptVal.y, nPrec) + ',' + ToString( ptVal.z, nPrec) ;
|
||||
return sBuff ; }
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
EGN_EXPORT void Split( const std::string& sString, const std::string& sSeparator, bool bFirstVsLast,
|
||||
|
||||
@@ -35,6 +35,24 @@ GetPrivateProfileStringUtf8( const char* szSection, const char* szKey, const cha
|
||||
return szDefault ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline std::string
|
||||
GetPrivateProfileStringUtf8( const char* szSection, const char* szKey, const char* szDefault, const wchar_t* szIniFile)
|
||||
{
|
||||
int nChar ;
|
||||
wchar_t szBuffW[_MAX_PATH] ;
|
||||
|
||||
|
||||
// leggo la stringa dal file INI come ANSI/UTF-8 in WChar e metto in Char
|
||||
nChar = GetPrivateProfileStringW( AtoW( szSection), AtoW( szKey), NULL, szBuffW, _MAX_PATH, szIniFile) ;
|
||||
|
||||
if ( nChar > 0) {
|
||||
return LPSTR( WtoAEX<>( szBuffW, CP_ACP)) ;
|
||||
}
|
||||
else
|
||||
return szDefault ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool
|
||||
WritePrivateProfileStringUtf8( const char* szSection, const char* szKey, const char* szVal, const char* szIniFile)
|
||||
@@ -43,6 +61,14 @@ WritePrivateProfileStringUtf8( const char* szSection, const char* szKey, const c
|
||||
return WritePrivateProfileStringW( AtoW( szSection), AtoW( szKey), AtoWEX<>( szVal, CP_ACP), AtoW( szIniFile)) != 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool
|
||||
WritePrivateProfileStringUtf8( const char* szSection, const char* szKey, const char* szVal, const wchar_t* szIniFile)
|
||||
{
|
||||
// salvo la stringa nel file INI come ANSI/UTF-8 ma scritta in variabile WChar
|
||||
return WritePrivateProfileStringW( AtoW( szSection), AtoW( szKey), AtoWEX<>( szVal, CP_ACP), szIniFile) != 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline int
|
||||
GetPrivateProfileInt( const char* szSection, const char* szKey, int nDefault, const char* szIniFile)
|
||||
@@ -50,9 +76,23 @@ GetPrivateProfileInt( const char* szSection, const char* szKey, int nDefault, co
|
||||
return GetPrivateProfileIntW( AtoW( szSection), AtoW( szKey), nDefault, AtoW( szIniFile)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline int
|
||||
GetPrivateProfileInt( const char* szSection, const char* szKey, int nDefault, const wchar_t* szIniFile)
|
||||
{
|
||||
return GetPrivateProfileIntW( AtoW( szSection), AtoW( szKey), nDefault, szIniFile) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool
|
||||
WritePrivateProfileInt( const char* szSection, const char* szKey, int nVal, const char* szIniFile)
|
||||
{
|
||||
return WritePrivateProfileStringUtf8( szSection, szKey, ToString( nVal).c_str(), szIniFile) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool
|
||||
WritePrivateProfileInt( const char* szSection, const char* szKey, int nVal, const wchar_t* szIniFile)
|
||||
{
|
||||
return WritePrivateProfileStringUtf8( szSection, szKey, ToString( nVal).c_str(), szIniFile) ;
|
||||
}
|
||||
|
||||
@@ -31,3 +31,5 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Direttorio librerie esterne
|
||||
#define EGTEXTDIR "/EgtDev/EXTERN/"
|
||||
|
||||
Reference in New Issue
Block a user