void LEGACY_NETLIST_READER::loadFootprintFilters() throw( IO_ERROR, PARSE_ERROR ) { wxArrayString filters; wxString cmpRef; char* line; COMPONENT* component = NULL; // Suppress compil warning while( ( line = m_lineReader->ReadLine() ) != NULL ) { if( strnicmp( line, "$endlist", 8 ) == 0 ) // end of list for the current component { wxASSERT( component != NULL ); component->SetFootprintFilters( filters ); component = NULL; filters.Clear(); continue; } if( strnicmp( line, "$endfootprintlist", 4 ) == 0 ) // End of this section return; if( strnicmp( line, "$component", 10 ) == 0 ) // New component reference found { cmpRef = FROM_UTF8( line + 11 ); cmpRef.Trim( true ); cmpRef.Trim( false ); component = m_netlist->GetComponentByReference( cmpRef ); // Cannot happen if the netlist is valid. if( component == NULL ) { wxString msg; msg.Printf( _( "Cannot find component \'%s\' in footprint filter section " "of netlist." ), GetChars( cmpRef ) ); THROW_PARSE_ERROR( msg, m_lineReader->GetSource(), line, m_lineReader->LineNumber(), m_lineReader->Length() ); } } else { // Add new filter to list wxString fp = FROM_UTF8( line + 1 ); fp.Trim( false ); fp.Trim( true ); filters.Add( fp ); } } }
void KICAD_NETLIST_PARSER::parseLibPartList() throw( IO_ERROR, PARSE_ERROR ) { /* Parses a section like * (libpart (lib device) (part C) * (aliases * (alias Cxx) * (alias Cyy)) * (description "Condensateur non polarise") * (footprints * (fp SM*) * (fp C?) * (fp C1-1)) * (fields * (field (name Reference) C) * (field (name Value) C)) * (pins * (pin (num 1) (name ~) (type passive)) * (pin (num 2) (name ~) (type passive)))) * * Currently footprints section/fp are read and data stored * other fields (unused) are skipped */ COMPONENT* component = NULL; wxString libName; wxString libPartName; wxArrayString footprintFilters; wxArrayString aliases; // The last token read was libpart, so read the next token while( (token = NextTok()) != T_RIGHT ) { if( token == T_LEFT ) token = NextTok(); switch( token ) { case T_lib: NeedSYMBOLorNUMBER(); libName = FROM_UTF8( CurText() ); NeedRIGHT(); break; case T_part: NeedSYMBOLorNUMBER(); libPartName = FROM_UTF8( CurText() ); NeedRIGHT(); break; case T_footprints: // Read all fp elements (footprint filter item) while( (token = NextTok()) != T_RIGHT ) { if( token == T_LEFT ) token = NextTok(); if( token != T_fp ) Expecting( T_fp ); NeedSYMBOLorNUMBER(); footprintFilters.Add( FROM_UTF8( CurText() ) ); NeedRIGHT(); } break; case T_aliases: while( (token = NextTok()) != T_RIGHT ) { if( token == T_LEFT ) token = NextTok(); if( token != T_alias ) Expecting( T_alias ); NeedSYMBOLorNUMBER(); aliases.Add( FROM_UTF8( CurText() ) ); NeedRIGHT(); } break; default: // Skip not used data (i.e all other tokens) skipCurrent(); break; } } // Find all of the components that reference this component library part definition. for( unsigned i = 0; i < m_netlist->GetCount(); i++ ) { component = m_netlist->GetComponent( i ); if( component->IsLibSource( libName, libPartName ) ) component->SetFootprintFilters( footprintFilters ); for( unsigned jj = 0; jj < aliases.GetCount(); jj++ ) { if( component->IsLibSource( libName, aliases[jj] ) ) component->SetFootprintFilters( footprintFilters ); } } }