7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 23:13:43 +00:00

Unify LIB_IDs now that both are stored in sexpr files.

Fixes https://gitlab.com/kicad/code/kicad/issues/6764
This commit is contained in:
Jeff Young 2020-12-17 23:32:23 +00:00
parent c4117c1ecf
commit bb232e6ac6
42 changed files with 177 additions and 207 deletions

View File

@ -62,7 +62,7 @@ FOOTPRINT_INFO* FOOTPRINT_LIST::GetFootprintInfo( const wxString& aFootprintName
LIB_ID fpid;
wxCHECK_MSG( fpid.Parse( aFootprintName, LIB_ID::ID_PCB ) < 0, NULL,
wxCHECK_MSG( fpid.Parse( aFootprintName ) < 0, NULL,
wxString::Format( wxT( "\"%s\" is not a valid LIB_ID." ), aFootprintName ) );
return GetFootprintInfo( fpid.GetLibNickname(), fpid.GetLibItemName() );

View File

@ -113,13 +113,13 @@ static int okRevision( const UTF8& aField )
void LIB_ID::clear()
{
nickname.clear();
item_name.clear();
revision.clear();
m_libraryName.clear();
m_itemName.clear();
m_revision.clear();
}
int LIB_ID::Parse( const UTF8& aId, LIB_ID_TYPE aType, bool aFix )
int LIB_ID::Parse( const UTF8& aId, bool aFix )
{
clear();
@ -129,14 +129,14 @@ int LIB_ID::Parse( const UTF8& aId, LIB_ID_TYPE aType, bool aFix )
size_t partNdx;
int offset = -1;
//=====<revision>=========================================
//=====<revision>=====================================
// in a LIB_ID like discret:R3/rev4
if( rev )
{
revNdx = rev - buffer;
// no need to check revision, EndsWithRev did that.
revision = aId.substr( revNdx );
m_revision = aId.substr( revNdx );
--revNdx; // back up to omit the '/' which precedes the rev
}
else
@ -144,7 +144,7 @@ int LIB_ID::Parse( const UTF8& aId, LIB_ID_TYPE aType, bool aFix )
revNdx = aId.size();
}
//=====<nickname>==========================================
//=====<name>=========================================
if( ( partNdx = aId.find( ':' ) ) != aId.npos )
{
offset = SetLibNickname( aId.substr( 0, partNdx ) );
@ -168,9 +168,9 @@ int LIB_ID::Parse( const UTF8& aId, LIB_ID_TYPE aType, bool aFix )
// Be sure the item name is valid.
// Some chars can be found in legacy files converted files from other EDA tools.
if( aFix )
fpname = FixIllegalChars( fpname, aType, false );
fpname = FixIllegalChars( fpname, false );
else
offset = HasIllegalChars( fpname, aType );
offset = HasIllegalChars( fpname );
if( offset > -1 )
return offset;
@ -181,11 +181,11 @@ int LIB_ID::Parse( const UTF8& aId, LIB_ID_TYPE aType, bool aFix )
}
LIB_ID::LIB_ID( const wxString& aLibName, const wxString& aLibItemName,
LIB_ID::LIB_ID( const wxString& aLibraryName, const wxString& aItemName,
const wxString& aRevision ) :
nickname( aLibName ),
item_name( aLibItemName ),
revision( aRevision )
m_libraryName( aLibraryName ),
m_itemName( aItemName ),
m_revision( aRevision )
{
}
@ -195,9 +195,7 @@ int LIB_ID::SetLibNickname( const UTF8& aLogical )
int offset = okLogical( aLogical );
if( offset == -1 )
{
nickname = aLogical;
}
m_libraryName = aLogical;
return offset;
}
@ -209,12 +207,12 @@ int LIB_ID::SetLibItemName( const UTF8& aLibItemName, bool aTestForRev )
if( aTestForRev && separation != -1 )
{
item_name = aLibItemName.substr( 0, separation-1 );
m_itemName = aLibItemName.substr( 0, separation-1 );
return separation;
}
else
{
item_name = aLibItemName;
m_itemName = aLibItemName;
}
return -1;
@ -226,9 +224,7 @@ int LIB_ID::SetRevision( const UTF8& aRevision )
int offset = okRevision( aRevision );
if( offset == -1 )
{
revision = aRevision;
}
m_revision = aRevision;
return offset;
}
@ -238,18 +234,18 @@ UTF8 LIB_ID::Format() const
{
UTF8 ret;
if( nickname.size() )
if( m_libraryName.size() )
{
ret += nickname;
ret += m_libraryName;
ret += ':';
}
ret += item_name;
ret += m_itemName;
if( revision.size() )
if( m_revision.size() )
{
ret += '/';
ret += revision;
ret += m_revision;
}
return ret;
@ -258,35 +254,34 @@ UTF8 LIB_ID::Format() const
UTF8 LIB_ID::GetLibItemNameAndRev() const
{
UTF8 ret = item_name;
UTF8 ret = m_itemName;
if( revision.size() )
if( m_revision.size() )
{
ret += '/';
ret += revision;
ret += m_revision;
}
return ret;
}
UTF8 LIB_ID::Format( const UTF8& aLogicalLib, const UTF8& aLibItemName, const UTF8& aRevision )
UTF8 LIB_ID::Format( const UTF8& aLibraryName, const UTF8& aLibItemName, const UTF8& aRevision )
{
UTF8 ret;
int offset;
if( aLogicalLib.size() )
if( aLibraryName.size() )
{
offset = okLogical( aLogicalLib );
offset = okLogical( aLibraryName );
if( offset != -1 )
{
THROW_PARSE_ERROR( _( "Illegal character found in logical library name" ),
wxString::FromUTF8( aLogicalLib.c_str() ),
aLogicalLib.c_str(), 0, offset );
wxString::FromUTF8( aLibraryName.c_str() ), aLibraryName.c_str(), 0, offset );
}
ret += aLogicalLib;
ret += aLibraryName;
ret += ':';
}
@ -319,27 +314,27 @@ int LIB_ID::compare( const LIB_ID& aLibId ) const
if( this == &aLibId )
return 0;
int retv = nickname.compare( aLibId.nickname );
int retv = m_libraryName.compare( aLibId.m_libraryName );
if( retv != 0 )
return retv;
retv = item_name.compare( aLibId.item_name );
retv = m_itemName.compare( aLibId.m_itemName );
if( retv != 0 )
return retv;
return revision.compare( aLibId.revision );
return m_revision.compare( aLibId.m_revision );
}
int LIB_ID::HasIllegalChars( const UTF8& aLibItemName, LIB_ID_TYPE aType )
int LIB_ID::HasIllegalChars( const UTF8& aLibItemName )
{
int offset = 0;
for( auto ch : aLibItemName )
{
if( !isLegalChar( ch, aType ) )
if( !isLegalChar( ch ) )
return offset;
else
++offset;
@ -349,7 +344,7 @@ int LIB_ID::HasIllegalChars( const UTF8& aLibItemName, LIB_ID_TYPE aType )
}
UTF8 LIB_ID::FixIllegalChars( const UTF8& aLibItemName, LIB_ID_TYPE aType, bool aLib )
UTF8 LIB_ID::FixIllegalChars( const UTF8& aLibItemName, bool aLib )
{
UTF8 fixedName;
@ -357,19 +352,19 @@ UTF8 LIB_ID::FixIllegalChars( const UTF8& aLibItemName, LIB_ID_TYPE aType, bool
{
auto ch = *chIt;
if( aLib )
fixedName += isLegalLibNicknameChar( ch, aType ) ? ch : '_';
fixedName += isLegalLibraryNameChar( ch ) ? ch : '_';
else
fixedName += isLegalChar( ch, aType ) ? ch : '_';
fixedName += isLegalChar( ch ) ? ch : '_';
}
return fixedName;
}
bool LIB_ID::isLegalChar( unsigned aUniChar, LIB_ID_TYPE aType )
bool LIB_ID::isLegalChar( unsigned aUniChar )
{
bool const space_allowed = ( aType == ID_PCB );
bool const illegal_filename_chars_allowed = ( aType == ID_SCH );
bool const space_allowed = true;
bool const illegal_filename_chars_allowed = false;
if( aUniChar < ' ' )
return false;
@ -400,11 +395,11 @@ bool LIB_ID::isLegalChar( unsigned aUniChar, LIB_ID_TYPE aType )
}
unsigned LIB_ID::FindIllegalLibNicknameChar( const UTF8& aNickname, LIB_ID_TYPE aType )
unsigned LIB_ID::FindIllegalLibraryNameChar( const UTF8& aLibraryName )
{
for( unsigned ch : aNickname )
for( unsigned ch : aLibraryName )
{
if( !isLegalLibNicknameChar( ch, aType ) )
if( !isLegalLibraryNameChar( ch ) )
return ch;
}
@ -412,9 +407,9 @@ unsigned LIB_ID::FindIllegalLibNicknameChar( const UTF8& aNickname, LIB_ID_TYPE
}
bool LIB_ID::isLegalLibNicknameChar( unsigned aUniChar, LIB_ID_TYPE aType )
bool LIB_ID::isLegalLibraryNameChar( unsigned aUniChar )
{
bool const space_allowed = ( aType != ID_SCH );
bool const space_allowed = true;
if( aUniChar < ' ' )
return false;
@ -453,7 +448,7 @@ void LIB_ID::Test()
LIB_ID lpid( lpids[i] ); // parse
// format
printf( "input:'%s' full:'%s' nickname: %s item_name:'%s' rev:'%s'\n",
printf( "input:'%s' full:'%s' nickname: %s m_itemName:'%s' rev:'%s'\n",
lpids[i],
lpid.Format().c_str(),
lpid.GetLibNickname().c_str(),

View File

@ -25,16 +25,12 @@
#include <wx/filename.h>
#include <wx/uri.h>
#include <set>
#include <common.h>
#include <kiface_i.h>
#include <lib_table_base.h>
#include <lib_table_lexer.h>
#include <macros.h>
#include <settings/app_settings.h>
#define OPT_SEP '|' ///< options separator character
@ -195,33 +191,21 @@ LIB_TABLE_ROW* LIB_TABLE::findRow( const wxString& aNickName ) const
{
cur->ensureIndex();
INDEX_CITER it = cur->nickIndex.find( aNickName );
if( it != cur->nickIndex.end() )
for( const std::pair<const wxString, int>& entry : cur->nickIndex )
{
return &cur->rows[it->second]; // found
if( entry.first == aNickName )
return &cur->rows[entry.second ];
}
// not found, search fall back table(s), if any
} while( ( cur = cur->fallBack ) != 0 );
return nullptr; // not found
}
LIB_TABLE_ROW* LIB_TABLE::findRow( const wxString& aNickName )
{
LIB_TABLE* cur = (LIB_TABLE*) this;
do
{
cur->ensureIndex();
INDEX_ITER it = cur->nickIndex.find( aNickName );
if( it != cur->nickIndex.end() )
// Repeat, this time looking for names that were "fixed" by legacy versions because
// the old eeschema file format didn't support spaces in tokens.
for( const std::pair<const wxString, int>& entry : cur->nickIndex )
{
return &cur->rows[it->second]; // found
wxString legacyLibName = entry.first;
legacyLibName.Replace( " ", "_" );
if( legacyLibName == aNickName )
return &cur->rows[entry.second ];
}
// not found, search fall back table(s), if any

View File

@ -29,7 +29,7 @@
#include <lib_id.h>
LIB_ID AltiumToKiCadLibID( LIB_ID::LIB_ID_TYPE aType, wxString aLibName, wxString aLibReference )
LIB_ID AltiumToKiCadLibID( wxString aLibName, wxString aLibReference )
{
ReplaceIllegalFileNameChars( aLibName, '_' );
ReplaceIllegalFileNameChars( aLibReference, '_' );
@ -37,7 +37,7 @@ LIB_ID AltiumToKiCadLibID( LIB_ID::LIB_ID_TYPE aType, wxString aLibName, wxStrin
wxString key = !aLibName.empty() ? ( aLibName + ":" + aLibReference ) : aLibReference;
LIB_ID libId;
libId.Parse( key, aType, true );
libId.Parse( key, true );
return libId;
}

View File

@ -297,7 +297,7 @@ bool LIB_ID_VALIDATOR::Validate( wxWindow *aParent )
{
msg = _( "Entry contains leading white space." );
}
else if( dummy.Parse( val, m_idType ) != -1 || !dummy.IsValid() ) // Is valid LIB_ID.
else if( dummy.Parse( val ) != -1 || !dummy.IsValid() ) // Is valid LIB_ID.
{
msg.Printf( _( "\"%s\" is not a valid library identifier format." ), val );
}

View File

@ -51,8 +51,8 @@ public:
unsigned int aComponentIndex, wxString aNewFootprint, wxString aOldFootprint = "" ) :
m_componentIndex( aComponentIndex )
{
m_newFootprint.Parse( aNewFootprint, LIB_ID::ID_PCB );
m_oldFootprint.Parse( aOldFootprint, LIB_ID::ID_PCB );
m_newFootprint.Parse( aNewFootprint );
m_oldFootprint.Parse( aOldFootprint );
}
/**

View File

@ -374,7 +374,7 @@ FOOTPRINT* DISPLAY_FOOTPRINTS_FRAME::GetFootprint( const wxString& aFootprintNam
FOOTPRINT* footprint = NULL;
LIB_ID fpid;
if( fpid.Parse( aFootprintName, LIB_ID::ID_PCB ) >= 0 )
if( fpid.Parse( aFootprintName ) >= 0 )
{
aReporter.Report( wxString::Format( _( "Footprint ID \"%s\" is not valid." ),
aFootprintName ),

View File

@ -61,7 +61,7 @@ int CVPCB_ASSOCIATION_TOOL::CopyAssoc( const TOOL_EVENT& aEvent )
switch( copyControl )
{
case CVPCB_MAINFRAME::CONTROL_FOOTPRINT:
fpid.Parse( m_frame->GetSelectedFootprint(), LIB_ID::ID_PCB );
fpid.Parse( m_frame->GetSelectedFootprint() );
break;
case CVPCB_MAINFRAME::CONTROL_COMPONENT:
@ -163,7 +163,7 @@ int CVPCB_ASSOCIATION_TOOL::PasteAssoc( const TOOL_EVENT& aEvent )
return 0;
}
if( fpid.Parse( data.GetText(), LIB_ID::ID_PCB ) >= 0 )
if( fpid.Parse( data.GetText() ) >= 0 )
return 0;
// Assign the fpid to the selections
@ -205,7 +205,7 @@ int CVPCB_ASSOCIATION_TOOL::Associate( const TOOL_EVENT& aEvent )
// Get the currently selected footprint
LIB_ID fpid;
wxString fp = m_frame->GetSelectedFootprint();
fpid.Parse( fp, LIB_ID::ID_PCB );
fpid.Parse( fp );
// Ignore the action if the footprint is empty (nothing selected)
if( fpid.empty() )

View File

@ -309,7 +309,7 @@ wxString LIB_PART::GetUnitReference( int aUnit )
void LIB_PART::SetName( const wxString& aName )
{
wxString validatedName = LIB_ID::FixIllegalChars( aName, LIB_ID::ID_SCH );
wxString validatedName = LIB_ID::FixIllegalChars( aName );
m_name = validatedName;
m_libId.SetLibItemName( validatedName, false );

View File

@ -286,7 +286,7 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList()
{
LIB_ID newId;
newId.Parse( m_newId->GetValue(), LIB_ID::ID_SCH );
newId.Parse( m_newId->GetValue() );
if( newId.IsValid() )
{
@ -384,7 +384,7 @@ bool DIALOG_CHANGE_SYMBOLS::isMatch( SCH_COMPONENT* aSymbol, SCH_SHEET_PATH* aIn
}
else if( m_matchById )
{
id.Parse( m_specifiedId->GetValue(), LIB_ID::ID_SCH );
id.Parse( m_specifiedId->GetValue() );
return aSymbol->GetLibId() == id;
}
@ -405,7 +405,7 @@ bool DIALOG_CHANGE_SYMBOLS::processMatchingSymbols()
if( m_mode == MODE::CHANGE )
{
newId.Parse( m_newId->GetValue(), LIB_ID::ID_SCH );
newId.Parse( m_newId->GetValue() );
if( !newId.IsValid() )
return false;

View File

@ -426,7 +426,7 @@ void DIALOG_CHOOSE_SYMBOL::ShowFootprint( wxString const& aName )
{
LIB_ID lib_id;
if( lib_id.Parse( aName, LIB_ID::ID_PCB ) == -1 && lib_id.IsValid() )
if( lib_id.Parse( aName ) == -1 && lib_id.IsValid() )
{
m_fp_preview->ClearStatus();
m_fp_preview->CacheFootprint( lib_id );

View File

@ -541,7 +541,7 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::validateLibIds()
// a new lib id is found. validate this new value
LIB_ID id;
id.Parse( new_libid, LIB_ID::ID_SCH );
id.Parse( new_libid );
if( !id.IsValid() )
{
@ -589,7 +589,7 @@ void DIALOG_EDIT_COMPONENTS_LIBID::onClickOrphansButton( wxCommandEvent& event )
int grid_row_idx = orphanRow; //row index in m_grid for the current item
LIB_ID curr_libid;
curr_libid.Parse( orphanLibid, LIB_ID::ID_SCH, true );
curr_libid.Parse( orphanLibid, true );
wxString symbName = curr_libid.GetLibItemName();
// number of full LIB_ID candidates (because we search for a symbol name
// inside all avaiable libraries, perhaps the same symbol name can be found
@ -674,17 +674,16 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::setLibIdByBrowser( int aRow )
0, 0, false );
#else
// Use library viewer to choose a symbol
LIB_ID aPreselectedLibid;
LIB_ID preselected;
wxString current = m_grid->GetCellValue( aRow, COL_NEW_LIBID );
if( current.IsEmpty() )
current = m_grid->GetCellValue( aRow, COL_CURR_LIBID );
if( !current.IsEmpty() )
aPreselectedLibid.Parse( current, LIB_ID::ID_SCH, true );
preselected.Parse( current, true );
PICKED_SYMBOL sel = GetParent()->PickSymbolFromLibBrowser( this, NULL, aPreselectedLibid,
0, 0 );
PICKED_SYMBOL sel = GetParent()->PickSymbolFromLibBrowser( this, NULL, preselected, 0, 0 );
#endif
if( sel.LibId.empty() ) // command aborted
@ -721,7 +720,7 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::TransferDataFromWindow()
// A new lib id is found and was already validated.
LIB_ID id;
id.Parse( new_libid, LIB_ID::ID_SCH, true );
id.Parse( new_libid, true );
for( CMP_CANDIDATE& cmp : m_components )
{

View File

@ -329,7 +329,7 @@ bool PANEL_SYM_LIB_TABLE::verifyTables()
// button.
model->DeleteRows( r, 1 );
}
else if( ( illegalCh = LIB_ID::FindIllegalLibNicknameChar( nick, LIB_ID::ID_SCH ) ) )
else if( ( illegalCh = LIB_ID::FindIllegalLibraryNameChar( nick ) ) )
{
wxString msg = wxString::Format( _( "Illegal character '%c' in Nickname: \"%s\"" ),
illegalCh,
@ -470,7 +470,7 @@ void PANEL_SYM_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event )
{
wxString filePath = dlg.GetDirectory() + wxFileName::GetPathSeparator() + file;
wxFileName fn( filePath );
wxString nickname = LIB_ID::FixIllegalChars( fn.GetName(), LIB_ID::ID_SCH );
wxString nickname = LIB_ID::FixIllegalChars( fn.GetName() );
bool doAdd = true;
if( cur_model()->ContainsNickname( nickname ) )

View File

@ -56,7 +56,7 @@ FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* a
m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), REFERENCE_FIELD ),
m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ),
m_libIdValidator( LIB_ID::ID_PCB ),
m_libIdValidator(),
m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME )
@ -76,7 +76,7 @@ FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* a
m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ),
m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETNAME_V ),
m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ),
m_libIdValidator( LIB_ID::ID_PCB ),
m_libIdValidator(),
m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ),
m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME_V )

View File

@ -970,7 +970,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
if( !fpField->GetText().IsEmpty() )
{
LIB_ID fpId;
fpId.Parse( fpField->GetText(), LIB_ID::ID_SCH, true );
fpId.Parse( fpField->GetText(), true );
fpId.SetLibNickname( newfilename.GetName() );
fpField->SetText( fpId.Format() );
}

View File

@ -73,7 +73,7 @@ PICKED_SYMBOL SCH_BASE_FRAME::PickSymbolFromLibBrowser( wxTopLevelWindow* aParen
{
LIB_ID id;
if( id.Parse( symbol, LIB_ID::ID_SCH ) == -1 )
if( id.Parse( symbol ) == -1 )
sel.LibId = id;
sel.Unit = viewlibFrame->GetUnit();

View File

@ -373,24 +373,24 @@ bool LIB_VIEW_FRAME::ShowModal( wxString* aSymbol, wxWindow* aParent )
LIB_TABLE* libTable = Prj().SchSymbolLibTable();
LIB_ID libid;
libid.Parse( *aSymbol, LIB_ID::ID_SCH, true );
libid.Parse( *aSymbol, true );
if( libid.IsValid() )
{
wxString nickname = libid.GetLibNickname();
wxString libName = libid.GetLibNickname();
if( !libTable->HasLibrary( libid.GetLibNickname(), false ) )
{
msg.sprintf( _( "The current configuration does not include a library with the\n"
"nickname \"%s\". Use Manage Symbol Libraries\n"
"to edit the configuration." ), nickname );
DisplayErrorMessage( aParent, _( "Symbol library not found." ), msg );
msg.Printf( _( "The current configuration does not include the library '%s'.\n"
"Use Manage Symbol Libraries to edit the configuration." ),
libName );
DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg );
}
else if ( !libTable->HasLibrary( libid.GetLibNickname(), true ) )
{
msg.sprintf( _( "The library with the nickname \"%s\" is not enabled\n"
"in the current configuration. Use Manage Symbol Libraries to\n"
"edit the configuration." ), nickname );
msg.Printf( _( "The library '%s' is not enabled in the current configuration.\n"
"Use Manage Symbol Libraries to edit the configuration." ),
libName );
DisplayErrorMessage( aParent, _( "Symbol library not enabled." ), msg );
}
else

View File

@ -89,7 +89,7 @@ static void get_components( SCHEMATIC* aSchematic, std::vector<SCH_COMPONENT*>&
static LIB_PART* find_component( const wxString& aName, PART_LIBS* aLibs, bool aCached )
{
LIB_PART *part = NULL;
wxString new_name = LIB_ID::FixIllegalChars( aName, LIB_ID::ID_SCH );
wxString new_name = LIB_ID::FixIllegalChars( aName );
for( PART_LIB& each_lib : *aLibs )
{
@ -149,7 +149,7 @@ void RESCUE_CASE_CANDIDATE::FindRescues( RESCUER& aRescuer,
for( SCH_COMPONENT* each_component : *( aRescuer.GetComponents() ) )
{
part_name = each_component->GetLibId().GetLibItemName();
search_name = LIB_ID::FixIllegalChars( part_name, LIB_ID::ID_SCH );
search_name = LIB_ID::FixIllegalChars( part_name );
if( last_part_name != part_name )
{
@ -254,7 +254,7 @@ void RESCUE_CACHE_CANDIDATE::FindRescues( RESCUER& aRescuer,
for( SCH_COMPONENT* each_component : *( aRescuer.GetComponents() ) )
{
part_name = each_component->GetLibId().GetLibItemName();
search_name = LIB_ID::FixIllegalChars( part_name, LIB_ID::ID_SCH );
search_name = LIB_ID::FixIllegalChars( part_name );
if( old_part_name != part_name )
{
@ -416,7 +416,7 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues(
}
// Test whether there is a conflict or if the symbol can only be found in the cache.
if( LIB_ID::HasIllegalChars( part_id.GetLibItemName(), LIB_ID::ID_SCH ) == -1 )
if( LIB_ID::HasIllegalChars( part_id.GetLibItemName() ) == -1 )
{
if( cache_match && lib_match &&
!cache_match->PinsConflictWith( *lib_match, true, true, true, true, false ) )
@ -427,7 +427,7 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues(
}
// Fix illegal LIB_ID name characters.
wxString new_name = LIB_ID::FixIllegalChars( part_id.GetLibItemName(), LIB_ID::ID_SCH );
wxString new_name = LIB_ID::FixIllegalChars( part_id.GetLibItemName() );
// Differentiate symbol name in the rescue library by appending the symbol library
// table nickname to the symbol name to prevent name clashes in the rescue library.

View File

@ -136,7 +136,7 @@ wxString SCH_ALTIUM_PLUGIN::getLibName()
m_libName = "noname";
m_libName += "-altium-import";
m_libName = LIB_ID::FixIllegalChars( m_libName, LIB_ID::ID_SCH, true );
m_libName = LIB_ID::FixIllegalChars( m_libName, true );
}
return m_libName;
@ -495,7 +495,7 @@ void SCH_ALTIUM_PLUGIN::ParseComponent( int aIndex,
elem.orientation,
elem.isMirrored ? "_mirrored" : "",
elem.libreference );
LIB_ID libId = AltiumToKiCadLibID( LIB_ID::ID_SCH, getLibName(), name );
LIB_ID libId = AltiumToKiCadLibID( getLibName(), name );
LIB_PART* kpart = new LIB_PART( wxEmptyString );
kpart->SetName( name );
@ -1555,7 +1555,7 @@ void SCH_ALTIUM_PLUGIN::ParsePowerPort( const std::map<wxString, wxString>& aPro
{
ASCH_POWER_PORT elem( aProperties );
LIB_ID libId = AltiumToKiCadLibID( LIB_ID::ID_SCH, getLibName(), elem.text );
LIB_ID libId = AltiumToKiCadLibID( getLibName(), elem.text );
LIB_PART* kpart = nullptr;

View File

@ -377,7 +377,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances()
//KiCad requires parts to be named the same as the net:
wxString partName = sym.SymbolVariant.Reference;
partName = LIB_ID::FixIllegalChars( partName, LIB_ID::ID_SCH );
partName = LIB_ID::FixIllegalChars( partName );
if( mPowerSymLibMap.find( symID ) == mPowerSymLibMap.end()
|| mPowerSymLibMap.at( symID )->GetName() != partName )

View File

@ -102,7 +102,7 @@ SCH_SHEET* CADSTAR_SCH_ARCHIVE_PLUGIN::Load( const wxString& aFileName, SCHEMATI
libName = "noname";
libName += "-cadstar-import";
libName = LIB_ID::FixIllegalChars( libName, LIB_ID::ID_SCH, true );
libName = LIB_ID::FixIllegalChars( libName, true );
wxFileName libFileName(
aSchematic->Prj().GetProjectPath(), libName, KiCadSymbolLibFileExtension );

View File

@ -149,7 +149,7 @@ wxString SCH_EAGLE_PLUGIN::getLibName()
m_libName = "noname";
m_libName += "-eagle-import";
m_libName = LIB_ID::FixIllegalChars( m_libName, LIB_ID::ID_SCH, true );
m_libName = LIB_ID::FixIllegalChars( m_libName, true );
}
return m_libName;
@ -2605,7 +2605,7 @@ void SCH_EAGLE_PLUGIN::addImplicitConnections(
wxString SCH_EAGLE_PLUGIN::fixSymbolName( const wxString& aName )
{
wxString ret = LIB_ID::FixIllegalChars( aName, LIB_ID::ID_SCH );
wxString ret = LIB_ID::FixIllegalChars( aName );
return ret;
}

View File

@ -149,7 +149,7 @@ LIB_PART* SCH_SEXPR_PARSER::ParseSymbol( LIB_PART_MAP& aSymbolLibMap, int aFileV
LIB_ID id;
if( id.Parse( name, LIB_ID::ID_SCH ) >= 0 )
if( id.Parse( name ) >= 0 )
{
error.Printf( _( "Invalid library identifier in\nfile: \"%s\"\nline: %d\noffset: %d" ),
CurSource().c_str(), CurLineNumber(), CurOffset() );
@ -2162,7 +2162,7 @@ SCH_COMPONENT* SCH_SEXPR_PARSER::parseSchematicSymbol()
LIB_ID libId;
if( libId.Parse( FromUTF8(), LIB_ID::ID_SCH ) >= 0 )
if( libId.Parse( FromUTF8() ) >= 0 )
{
error.Printf( _( "Invalid symbol library ID in\nfile: \"%s\"\nline: %d\n"
"offset: %d" ),

View File

@ -1529,7 +1529,7 @@ void SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( LIB_PART* aSymbol, OUTPUTFORMATTER& aFo
LIB_ID unitId;
wxCHECK2( unitId.Parse( aLibName, LIB_ID::ID_SCH ) < 0, /* do nothing */ );
wxCHECK2( unitId.Parse( aLibName ) < 0, /* do nothing */ );
unitName = unitId.GetLibItemName();
}

View File

@ -1510,7 +1510,7 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadComponent( LINE_READER& aReader )
// parsing the symbol name with LIB_ID::Parse() would break symbol library links
// that contained '/' and ':' characters.
if( m_version > 3 )
libId.Parse( libName, LIB_ID::ID_SCH, true );
libId.Parse( libName, true );
else
libId.SetLibItemName( libName, false );
@ -2687,7 +2687,7 @@ void SCH_LEGACY_PLUGIN_CACHE::loadDocs()
aliasName = wxString::FromUTF8( line );
aliasName.Trim();
aliasName = LIB_ID::FixIllegalChars( aliasName, LIB_ID::ID_SCH );
aliasName = LIB_ID::FixIllegalChars( aliasName );
LIB_PART_MAP::iterator it = m_symbols.find( aliasName );

Some files were not shown because too many files have changed in this diff Show More