Pcbnew: Add a minimal test for illegal chars in footprints libname (like space and dir separtor)

Also a minor cosmetic enhancement
This commit is contained in:
jean-pierre charras
2012-12-10 12:18:42 +01:00
parent 926dec84a5
commit 4a26d543d5
10 changed files with 1279 additions and 110 deletions
+37 -2
View File
@@ -139,7 +139,7 @@ MODULE::MODULE( const MODULE& aModule ) :
break;
default:
wxMessageBox( wxT( "MODULE::Copy() Internal Err: unknown type" ) );
wxLogMessage( wxT( "MODULE::Copy() Internal Err: unknown type" ) );
break;
}
}
@@ -262,7 +262,7 @@ void MODULE::Copy( MODULE* aModule )
break;
default:
wxMessageBox( wxT( "MODULE::Copy() Internal Err: unknown type" ) );
wxLogMessage( wxT( "MODULE::Copy() Internal Err: unknown type" ) );
break;
}
}
@@ -698,6 +698,41 @@ EDA_ITEM* MODULE::Clone() const
return new MODULE( *this );
}
/* Test for validity of the name in a library of the footprint
* ( no spaces, dir separators ... )
* return true if the given name is valid
* static function
*/
bool MODULE::IsLibNameValid( const wxString & aName )
{
const wxChar * invalids = ReturnStringLibNameInvalidChars( false );
if( aName.find_first_of( invalids ) != std::string::npos )
return false;
return true;
}
/* Test for validity of the name of a footprint to be used in a footprint library
* ( no spaces, dir separators ... )
* param bool aUserReadable = false to get the list of invalid chars
* true to get a readable form (i.e ' ' = 'space' '\t'= 'tab')
* return a constant string giving the list of invalid chars in lib name
* static function
*/
const wxChar* MODULE::ReturnStringLibNameInvalidChars( bool aUserReadable )
{
static const wxChar invalidChars[] = wxT("\t \"\\/");
static const wxChar invalidCharsReadable[] = wxT("'tab' 'space' \\ \" /");
if( aUserReadable )
return invalidCharsReadable;
else
return invalidChars;
}
#if defined(DEBUG)