Include :
- chiave ora non accetta carattere '=' - eliminate IsValidName e ValidateName e sostituite con funzioni specializzate per DXF e File.
This commit is contained in:
+19
-16
@@ -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) ;
|
||||
|
||||
+32
-9
@@ -80,18 +80,41 @@ IsNullOrSpace( char cChar)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool
|
||||
IsValidName( const std::string& sName)
|
||||
{ if ( &sName == nullptr || sName.empty())
|
||||
return false ;
|
||||
return ( sName.find_first_of( "\\/:*?\"<>|", 0) == std::string::npos) ; }
|
||||
IsValidFileName( const std::string& sName)
|
||||
{
|
||||
if ( &sName == nullptr || sName.empty())
|
||||
return false ;
|
||||
return ( sName.find_first_of( "<>/\\\":?*|", 0) == std::string::npos) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool
|
||||
ValidateName( std::string& sName)
|
||||
{ std::string::size_type i ;
|
||||
while ( ( i = sName.find_first_of( "\\/:*?\"<>|")) != std::string::npos)
|
||||
sName[i] = '_' ;
|
||||
return true ; }
|
||||
ValidateFileName( std::string& sName)
|
||||
{
|
||||
std::string::size_type i ;
|
||||
while ( ( i = sName.find_first_of( "<>/\\\":?*|")) != std::string::npos)
|
||||
sName[i] = '_' ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool
|
||||
IsValidDxfName( const std::string& sName)
|
||||
{
|
||||
if ( &sName == nullptr || sName.empty())
|
||||
return false ;
|
||||
return ( sName.find_first_of( "<>/\\\":;?*|='", 0) == std::string::npos) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool
|
||||
ValidateDxfName( std::string& sName)
|
||||
{
|
||||
std::string::size_type i ;
|
||||
while ( ( i = sName.find_first_of( "<>/\\\":;?*|='")) != std::string::npos)
|
||||
sName[i] = '_' ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool
|
||||
|
||||
Reference in New Issue
Block a user