Break out getTrailingInt from MODULE
This is not logic specific to MODULE. Breaking it out to kicad_string.h acheives: * Slimming of the MODULE interface * Enables reuse of the function * Enables testing of the function Also add a test under qa_common for this function.
This commit is contained in:
committed by
Seth Hillbrand
parent
f85f10930a
commit
dc20521cb9
@@ -641,6 +641,29 @@ int SplitString( wxString strToSplit,
|
||||
}
|
||||
|
||||
|
||||
int GetTrailingInt( const wxString& aStr )
|
||||
{
|
||||
int number = 0;
|
||||
int base = 1;
|
||||
|
||||
// Trim and extract the trailing numeric part
|
||||
int index = aStr.Len() - 1;
|
||||
while( index >= 0 )
|
||||
{
|
||||
const char chr = aStr.GetChar( index );
|
||||
|
||||
if( chr < '0' || chr > '9' )
|
||||
break;
|
||||
|
||||
number += ( chr - '0' ) * base;
|
||||
base *= 10;
|
||||
index--;
|
||||
}
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
|
||||
wxString GetIllegalFileNameWxChars()
|
||||
{
|
||||
return FROM_UTF8( illegalFileNameChars );
|
||||
|
||||
Reference in New Issue
Block a user