Include :

- chiave ora non accetta carattere '='
- eliminate IsValidName e ValidateName e sostituite con funzioni specializzate per DXF e File.
This commit is contained in:
Dario Sassi
2017-03-02 18:09:47 +00:00
parent f1dc3c6651
commit 186acf919a
2 changed files with 51 additions and 25 deletions
+19 -16
View File
@@ -18,24 +18,27 @@
//----------------------------------------------------------------------------
static const char EQUAL = '=' ;
//----------------------------------------------------------------------------
inline bool
FindKey( const std::string& sString, const std::string& sKey)
{
return ( sString.compare( 0, sKey.length(), sKey) == 0 &&
sString.length() > sKey.length() &&
sString[sKey.length()] == EQUAL) ;
}
//----------------------------------------------------------------------------
inline bool
IsValidKey( const std::string& sString)
{
return ( ! sString.empty() &&
sString.find( '\n') == std::string::npos &&
sString.find( EQUAL) == std::string::npos &&
sString.find_first_not_of( " \t\r\n") != std::string::npos) ;
}
//----------------------------------------------------------------------------
inline bool
FindKey( const std::string& sString, const std::string& sKey)
{
if ( ! IsValidKey( sKey))
return false ;
return ( sString.compare( 0, sKey.length(), sKey) == 0 &&
sString.length() > sKey.length() &&
sString[sKey.length()] == EQUAL) ;
}
//----------------------------------------------------------------------------
inline bool
IsValidVal( const std::string& sString)
@@ -47,11 +50,13 @@ IsValidVal( const std::string& sString)
//----------------------------------------------------------------------------
inline bool
ValidateKeyVal( std::string& sString)
{ std::string::size_type i ;
while ( ( i = sString.find_first_of( "\t\r\n")) != std::string::npos)
sString[i] = '_' ;
return true ; }
ValidateVal( std::string& sString)
{
std::string::size_type i ;
while ( ( i = sString.find_first_of( "\t\r\n")) != std::string::npos)
sString[i] = '_' ;
return true ;
}
//----------------------------------------------------------------------------
inline bool
@@ -75,8 +80,6 @@ SetVal( const std::string& sKey, T& Val, std::string& sString)
inline bool
GetVal( const std::string& sString, const std::string& sKey, std::string& sVal)
{
if ( ! IsValidKey( sKey))
return false ;
if ( ! FindKey( sString, sKey))
return false ;
sVal = sString.substr( sKey.length() + 1) ;