More elegant way for checking Spice_Netlist_Enabled value

This commit is contained in:
Maciej Suminski 2016-08-11 14:41:37 +02:00
parent 1c74e27366
commit 01f40e258c
2 changed files with 13 additions and 13 deletions

View File

@ -249,19 +249,8 @@ void NETLIST_EXPORTER_PSPICE::ProcessNetlist( unsigned aCtl )
spiceItem.m_refName = comp->GetRef( &sheetList[sheet_idx] );
// Check to see if component should be removed from Spice Netlist:
spiceItem.m_enabled = true; // assume yes and then verify
if( fieldEnabled )
{
wxString netlistEnabled = fieldEnabled->GetText();
// Different ways of saying 'disabled' (no/false/0)
if( netlistEnabled.CmpNoCase( "N" ) == 0
|| netlistEnabled.CmpNoCase( "F" ) == 0
|| netlistEnabled == "0" )
spiceItem.m_enabled = false;
}
// Check to see if component should be removed from Spice netlist
spiceItem.m_enabled = fieldEnabled ? StringToBool( fieldEnabled->GetText() ) : true;
wxArrayString pinNames;

View File

@ -113,6 +113,17 @@ public:
return m_directives;
}
static bool StringToBool( const wxString& aStr )
{
if( aStr.IsEmpty() )
return false;
char c = tolower( aStr[0] );
// Different ways of saying false (no/false/0)
return !( c == 'n' || c == 'f' || c == '0' );
}
protected:
virtual void writeDirectives( OUTPUTFORMATTER* aFormatter, unsigned aCtl ) const;