KiCad PCB EDA Suite
class_library.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2004-2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
30 #include <algorithm>
31 #include <fctsys.h>
32 #include <kiface_i.h>
33 #include <gr_basic.h>
34 #include <macros.h>
35 #include <eda_base_frame.h>
36 #include <kicad_string.h>
37 #include <gestfich.h>
38 #include <eda_doc.h>
39 #include <richio.h>
40 #include <config_params.h>
42 #include <project_rescue.h>
43 #include <properties.h>
44 
45 #include <general.h>
46 #include <class_library.h>
47 #include <sch_legacy_plugin.h>
48 
49 #include <wx/progdlg.h>
50 #include <wx/tokenzr.h>
51 #include <wx/regex.h>
52 
53 #define DUPLICATE_NAME_MSG \
54  _( "Library \"%s\" has duplicate entry name \"%s\".\n" \
55  "This may cause some unexpected behavior when loading components into a schematic." )
56 
57 
58 PART_LIB::PART_LIB( int aType, const wxString& aFileName, SCH_IO_MGR::SCH_FILE_T aPluginType ) :
59  // start @ != 0 so each additional library added
60  // is immediately detectable, zero would not be.
61  m_mod_hash( PART_LIBS::s_modify_generation ),
62  m_pluginType( aPluginType )
63 {
64  type = aType;
65  isModified = false;
66  timeStamp = 0;
67  timeStamp = wxDateTime::Now();
68  versionMajor = 0; // Will be updated after reading the lib file
69  versionMinor = 0; // Will be updated after reading the lib file
70 
71  fileName = aFileName;
72 
73  if( !fileName.IsOk() )
74  fileName = "unnamed.lib";
75 
76  m_plugin.reset( SCH_IO_MGR::FindPlugin( m_pluginType ) );
77  m_properties = std::make_unique<PROPERTIES>();
78 }
79 
80 
82 {
83 }
84 
85 
86 void PART_LIB::Save( bool aSaveDocFile )
87 {
88  wxCHECK_RET( m_plugin != NULL, wxString::Format( "no plugin defined for library `%s`.",
89  fileName.GetFullPath() ) );
90 
91  PROPERTIES props;
92 
93  if( !aSaveDocFile )
95 
96  m_plugin->SaveLibrary( fileName.GetFullPath(), &props );
97  isModified = false;
98 }
99 
100 
101 void PART_LIB::Create( const wxString& aFileName )
102 {
103  wxString tmpFileName = fileName.GetFullPath();
104 
105  if( !aFileName.IsEmpty() )
106  tmpFileName = aFileName;
107 
108  m_plugin->CreateSymbolLib( tmpFileName, m_properties.get() );
109 }
110 
111 
112 void PART_LIB::SetPluginType( SCH_IO_MGR::SCH_FILE_T aPluginType )
113 {
114  if( m_pluginType != aPluginType )
115  {
116  m_pluginType = aPluginType;
117  m_plugin.reset( SCH_IO_MGR::FindPlugin( m_pluginType ) );
118  }
119 }
120 
121 
122 bool PART_LIB::IsCache() const
123 {
125 }
126 
127 
129 {
130  (*m_properties)[ SCH_LEGACY_PLUGIN::PropNoDocFile ] = "";
131 }
132 
133 
135 {
137 }
138 
139 
140 void PART_LIB::EnableBuffering( bool aEnable )
141 {
142  if( aEnable )
143  (*m_properties)[ SCH_LEGACY_PLUGIN::PropBuffering ] = "";
144  else
146 }
147 
148 
149 void PART_LIB::GetAliasNames( wxArrayString& aNames ) const
150 {
151  m_plugin->EnumerateSymbolLib( aNames, fileName.GetFullPath(), m_properties.get() );
152 
153  aNames.Sort();
154 }
155 
156 
157 void PART_LIB::GetAliases( std::vector<LIB_ALIAS*>& aAliases ) const
158 {
159  m_plugin->EnumerateSymbolLib( aAliases, fileName.GetFullPath(), m_properties.get() );
160 
161  std::sort( aAliases.begin(), aAliases.end(),
162  [](LIB_ALIAS *lhs, LIB_ALIAS *rhs) -> bool
163  { return lhs->GetName() < rhs->GetName(); });
164 }
165 
166 
167 void PART_LIB::GetEntryTypePowerNames( wxArrayString& aNames ) const
168 {
169  std::vector<LIB_ALIAS*> aliases;
170 
171  m_plugin->EnumerateSymbolLib( aliases, fileName.GetFullPath() );
172 
173  for( size_t i = 0; i < aliases.size(); i++ )
174  {
175  LIB_ALIAS* alias = aliases[i];
176 
177  LIB_PART* root = alias->GetPart();
178 
179  if( !root || !root->IsPower() )
180  continue;
181 
182  aNames.Add( alias->GetName() );
183  }
184 
185  aNames.Sort();
186 }
187 
188 
189 LIB_ALIAS* PART_LIB::FindAlias( const wxString& aName ) const
190 {
191  LIB_ALIAS* alias = m_plugin->LoadSymbol( fileName.GetFullPath(), aName, m_properties.get() );
192 
193  // Set the library to this even though technically the legacy cache plugin owns the
194  // symbols. This allows the symbol library table conversion tool to determine the
195  // correct library where the symbol was found.
196  if( alias && alias->GetPart() && !alias->GetPart()->GetLib() )
197  alias->GetPart()->SetLib( const_cast<PART_LIB*>( this ) );
198 
199  return alias;
200 }
201 
202 
203 LIB_ALIAS* PART_LIB::FindAlias( const LIB_ID& aLibId ) const
204 {
205  return FindAlias( aLibId.Format().wx_str() );
206 }
207 
208 
209 LIB_PART* PART_LIB::FindPart( const wxString& aName ) const
210 {
211  LIB_ALIAS* alias = FindAlias( aName );
212 
213  if( alias != NULL )
214  return alias->GetPart();
215 
216  return NULL;
217 }
218 
219 
220 LIB_PART* PART_LIB::FindPart( const LIB_ID& aLibId ) const
221 {
222  return FindPart( aLibId.Format().wx_str() );
223 }
224 
225 
227 {
228  // return true if at least one power part is found in lib
229  std::vector<LIB_ALIAS*> aliases;
230 
231  m_plugin->EnumerateSymbolLib( aliases, fileName.GetFullPath(), m_properties.get() );
232 
233  for( size_t i = 0; i < aliases.size(); i++ )
234  {
235  LIB_ALIAS* alias = aliases[i];
236 
237  LIB_PART* root = alias->GetPart();
238 
239  if( !root || root->IsPower() )
240  return true;
241  }
242 
243  return false;
244 }
245 
246 
248 {
249  // add a clone, not the caller's copy, the plugin take ownership of the new symbol.
250  m_plugin->SaveSymbol( fileName.GetFullPath(), new LIB_PART( *aPart, this ), m_properties.get() );
251 
252  // If we are not buffering, the library file is updated immediately when the plugin
253  // SaveSymbol() function is called.
254  if( IsBuffering() )
255  isModified = true;
256 
257  ++m_mod_hash;
258 }
259 
260 
262 {
263  wxCHECK_MSG( aEntry != NULL, NULL, "NULL pointer cannot be removed from library." );
264 
265  m_plugin->DeleteAlias( fileName.GetFullPath(), aEntry->GetName(), m_properties.get() );
266 
267  // If we are not buffering, the library file is updated immediately when the plugin
268  // SaveSymbol() function is called.
269  if( IsBuffering() )
270  isModified = true;
271 
272  ++m_mod_hash;
273  return NULL;
274 }
275 
276 
278 {
279  wxASSERT( aOldPart != NULL );
280  wxASSERT( aNewPart != NULL );
281 
282  m_plugin->DeleteSymbol( fileName.GetFullPath(), aOldPart->GetName(), m_properties.get() );
283 
284  LIB_PART* my_part = new LIB_PART( *aNewPart, this );
285 
286  m_plugin->SaveSymbol( fileName.GetFullPath(), my_part, m_properties.get() );
287 
288  // If we are not buffering, the library file is updated immediately when the plugin
289  // SaveSymbol() function is called.
290  if( IsBuffering() )
291  isModified = true;
292 
293  ++m_mod_hash;
294  return my_part;
295 }
296 
297 
298 PART_LIB* PART_LIB::LoadLibrary( const wxString& aFileName )
299 {
300  std::unique_ptr<PART_LIB> lib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, aFileName ) );
301 
302  std::vector<LIB_ALIAS*> aliases;
303  // This loads the library.
304  lib->GetAliases( aliases );
305 
306  // Now, set the LIB_PART m_library member but it will only be used
307  // when loading legacy libraries in the future. Once the symbols in the
308  // schematic have a full #LIB_ID, this will not get called.
309  for( size_t ii = 0; ii < aliases.size(); ii++ )
310  {
311  LIB_ALIAS* alias = aliases[ii];
312 
313  if( alias->GetPart() )
314  alias->GetPart()->SetLib( lib.get() );
315  }
316 
317  PART_LIB* ret = lib.release();
318  return ret;
319 }
320 
321 
322 PART_LIB* PART_LIBS::AddLibrary( const wxString& aFileName )
323 {
324  PART_LIB* lib;
325 
326  wxFileName fn = aFileName;
327  // Don't reload the library if it is already loaded.
328  lib = FindLibrary( fn.GetName() );
329 
330  if( lib )
331  return lib;
332 
333  lib = PART_LIB::LoadLibrary( aFileName );
334 
335  push_back( lib );
336 
337  return lib;
338 }
339 
340 
341 PART_LIB* PART_LIBS::AddLibrary( const wxString& aFileName, PART_LIBS::iterator& aIterator )
342 {
343  // Don't reload the library if it is already loaded.
344  wxFileName fn( aFileName );
345  PART_LIB* lib = FindLibrary( fn.GetName() );
346 
347  if( lib )
348  return lib;
349 
350  lib = PART_LIB::LoadLibrary( aFileName );
351 
352  if( aIterator >= begin() && aIterator < end() )
353  insert( aIterator, lib );
354  else
355  push_back( lib );
356 
357  return lib;
358 }
359 
360 
361 PART_LIB* PART_LIBS::FindLibrary( const wxString& aName )
362 {
363  for( PART_LIBS::iterator it = begin(); it!=end(); ++it )
364  {
365  if( it->GetName() == aName )
366  return &*it;
367  }
368 
369  return NULL;
370 }
371 
372 
374 {
375  for( PART_LIBS::iterator it = begin(); it!=end(); ++it )
376  {
377  if( it->IsCache() )
378  return &*it;
379  }
380 
381  return NULL;
382 }
383 
384 
385 PART_LIB* PART_LIBS::FindLibraryByFullFileName( const wxString& aFullFileName )
386 {
387  for( PART_LIBS::iterator it = begin(); it!=end(); ++it )
388  {
389  if( it->GetFullFileName() == aFullFileName )
390  return &*it;
391  }
392 
393  return NULL;
394 }
395 
396 
397 wxArrayString PART_LIBS::GetLibraryNames( bool aSorted )
398 {
399  wxArrayString cacheNames;
400  wxArrayString names;
401 
402  for( PART_LIB& lib : *this )
403  {
404  if( lib.IsCache() && aSorted )
405  cacheNames.Add( lib.GetName() );
406  else
407  names.Add( lib.GetName() );
408  }
409 
410  // Even sorted, the cache library is always at the end of the list.
411  if( aSorted )
412  names.Sort();
413 
414  for( unsigned int i = 0; i<cacheNames.Count(); i++ )
415  names.Add( cacheNames.Item( i ) );
416 
417  return names;
418 }
419 
420 
421 LIB_PART* PART_LIBS::FindLibPart( const LIB_ID& aLibId, const wxString& aLibraryName )
422 {
423  LIB_PART* part = NULL;
424 
425  for( PART_LIB& lib : *this )
426  {
427  if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName )
428  continue;
429 
430  part = lib.FindPart( aLibId.GetLibItemName().wx_str() );
431 
432  if( part )
433  break;
434  }
435 
436  return part;
437 }
438 
439 
440 LIB_ALIAS* PART_LIBS::FindLibraryAlias( const LIB_ID& aLibId, const wxString& aLibraryName )
441 {
442  LIB_ALIAS* entry = NULL;
443 
444  for( PART_LIB& lib : *this )
445  {
446  if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName )
447  continue;
448 
449  entry = lib.FindAlias( aLibId.GetLibItemName().wx_str() );
450 
451  if( entry )
452  break;
453  }
454 
455  return entry;
456 }
457 
458 
459 void PART_LIBS::FindLibraryNearEntries( std::vector<LIB_ALIAS*>& aCandidates,
460  const wxString& aEntryName,
461  const wxString& aLibraryName )
462 {
463  for( PART_LIB& lib : *this )
464  {
465  if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName )
466  continue;
467 
468  wxArrayString aliasNames;
469 
470  lib.GetAliasNames( aliasNames );
471 
472  if( aliasNames.IsEmpty() )
473  continue;
474 
475  for( size_t i = 0; i < aliasNames.size(); i++ )
476  {
477  if( aliasNames[i].CmpNoCase( aEntryName ) == 0 )
478  aCandidates.push_back( lib.FindAlias( aliasNames[i] ) );
479  }
480  }
481 }
482 
483 
484 int PART_LIBS::s_modify_generation = 1; // starts at 1 and goes up
485 
486 
488 {
489  int hash = 0;
490 
491  for( PART_LIBS::const_iterator it = begin(); it != end(); ++it )
492  {
493  hash += it->GetModHash();
494  }
495 
496  // Rebuilding the cache (m_cache) does not change the GetModHash() value,
497  // but changes PART_LIBS::s_modify_generation.
498  // Take this change in account:
500 
501  return hash;
502 }
503 
504 
505 void PART_LIBS::LibNamesAndPaths( PROJECT* aProject, bool doSave,
506  wxString* aPaths, wxArrayString* aNames )
507 {
508  wxString pro = aProject->GetProjectFullName();
509 
510  PARAM_CFG_ARRAY ca;
511 
512  if( aPaths )
513  ca.push_back( new PARAM_CFG_FILENAME( "LibDir", aPaths ) );
514 
515  if( aNames )
516  ca.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ), aNames, GROUP_SCH_LIBS ) );
517 
518  if( doSave )
519  {
520  aProject->ConfigSave( Kiface().KifaceSearch(), GROUP_SCH, ca );
521 
522  /*
523  {
524  wxString msg = wxString::Format( _(
525  "Unable save project's \"%s\" file" ),
526  GetChars( pro )
527  );
528  THROW_IO_ERROR( msg );
529  }
530  */
531  }
532  else
533  {
534  if( !aProject->ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH, ca ) )
535  {
536  wxString msg = wxString::Format( _(
537  "Unable to load project's \"%s\" file" ),
538  GetChars( pro )
539  );
540  THROW_IO_ERROR( msg );
541  }
542  }
543 }
544 
545 
546 const wxString PART_LIBS::CacheName( const wxString& aFullProjectFilename )
547 {
548  /* until apr 2009 the project cache lib was named: <root_name>.cache.lib,
549  * and after: <root_name>-cache.lib. So if the <name>-cache.lib is not found,
550  * the old file will be renamed and returned.
551  */
552  wxFileName new_name = aFullProjectFilename;
553 
554  new_name.SetName( new_name.GetName() + "-cache" );
555  new_name.SetExt( SchematicLibraryFileExtension );
556 
557  if( new_name.FileExists() )
558  return new_name.GetFullPath();
559  else
560  {
561  wxFileName old_name = aFullProjectFilename;
562  old_name.SetExt( "cache.lib" );
563 
564  if( old_name.FileExists() )
565  {
566  wxRenameFile( old_name.GetFullPath(), new_name.GetFullPath() );
567  return new_name.GetFullPath();
568  }
569  }
570 
571  return wxEmptyString;
572 }
573 
574 
575 void PART_LIBS::LoadAllLibraries( PROJECT* aProject, bool aShowProgress )
576 {
577  wxString filename;
578  wxString libs_not_found;
579  SEARCH_STACK* lib_search = aProject->SchSearchS();
580 
581 #if defined(DEBUG) && 0
582  lib_search->Show( __func__ );
583 #endif
584 
585  wxArrayString lib_names;
586 
587  LibNamesAndPaths( aProject, false, NULL, &lib_names );
588 
589  // Post symbol library table, this should be empty. Only the cache library should get loaded.
590  if( !lib_names.empty() )
591  {
592  wxProgressDialog lib_dialog( _( "Loading Symbol Libraries" ),
593  wxEmptyString,
594  lib_names.GetCount(),
595  NULL,
596  wxPD_APP_MODAL );
597 
598  if( aShowProgress )
599  {
600  lib_dialog.Show();
601  }
602 
603  wxString progress_message;
604 
605  for( unsigned i = 0; i < lib_names.GetCount(); ++i )
606  {
607  if( aShowProgress )
608  {
609  lib_dialog.Update( i, _( "Loading " + lib_names[i] ) );
610  }
611 
612  // lib_names[] does not store the file extension. Set it.
613  // Remember lib_names[i] can contain a '.' in name, so using a wxFileName
614  // before adding the extension can create incorrect full filename
615  wxString fullname = lib_names[i] + "." + SchematicLibraryFileExtension;
616  // Now the full name is set, we can use a wxFileName.
617  wxFileName fn( fullname );
618 
619  // Skip if the file name is not valid..
620  if( !fn.IsOk() )
621  continue;
622 
623  if( !fn.FileExists() )
624  {
625  filename = lib_search->FindValidPath( fn.GetFullPath() );
626 
627  if( !filename )
628  {
629  libs_not_found += fn.GetFullPath();
630  libs_not_found += '\n';
631  continue;
632  }
633  }
634  else
635  { // ensure the lib filename has a absolute path.
636  // If the lib has no absolute path, and is found in the cwd by fn.FileExists(),
637  // make a full absolute path, to avoid issues with load library functions which
638  // expects an absolute path.
639  if( !fn.IsAbsolute() )
640  fn.MakeAbsolute();
641 
642  filename = fn.GetFullPath();
643  }
644 
645  try
646  {
647  AddLibrary( filename );
648  }
649  catch( const IO_ERROR& ioe )
650  {
651  wxString msg;
652  msg.Printf( _( "Symbol library \"%s\" failed to load. Error:\n %s" ),
653  GetChars( filename ), GetChars( ioe.What() ) );
654 
655  wxLogError( msg );
656  }
657  }
658  }
659 
660  // add the special cache library.
661  wxString cache_name = CacheName( aProject->GetProjectFullName() );
662  PART_LIB* cache_lib;
663 
664  if( !cache_name.IsEmpty() )
665  {
666  try
667  {
668  cache_lib = AddLibrary( cache_name );
669 
670  if( cache_lib )
671  cache_lib->SetCache();
672  }
673  catch( const IO_ERROR& ioe )
674  {
675  wxString msg = wxString::Format( _(
676  "Symbol library \"%s\" failed to load.\nError: %s" ),
677  GetChars( cache_name ),
678  GetChars( ioe.What() )
679  );
680 
681  THROW_IO_ERROR( msg );
682  }
683  }
684 
685  // Print the libraries not found
686  if( !libs_not_found.IsEmpty() )
687  {
688  // Use a different exception type so catch()er can route to proper use
689  // of the HTML_MESSAGE_BOX.
690  THROW_PARSE_ERROR( wxEmptyString, __func__, TO_UTF8( libs_not_found ), 0, 0 );
691  }
692 
693 #if defined(DEBUG) && 1
694  printf( "%s: lib_names:\n", __func__ );
695 
696  for( PART_LIBS::const_iterator it = begin(); it < end(); ++it )
697  printf( " %s\n", TO_UTF8( it->GetName() ) );
698 #endif
699 }
PART_LIB * GetLib()
int m_mod_hash
incremented each time library is changed.
void SetLib(PART_LIB *aLibrary)
A list of parameters type.
VTBL_ENTRY void ConfigSave(const SEARCH_STACK &aSList, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aFileName=wxEmptyString)
Function ConfigSave saves the current "project" parameters into the wxConfigBase* derivative...
Definition: project.cpp:316
Part library alias object definition.
bool IsBuffering() const
void GetAliasNames(wxArrayString &aNames) const
Load a string array with the names of all the entries in this library.
LIB_PART * ReplacePart(LIB_PART *aOldPart, LIB_PART *aNewPart)
Replace an existing part entry in the library.
std::unique_ptr< SCH_PLUGIN > m_plugin
static void LibNamesAndPaths(PROJECT *aProject, bool doSave, wxString *aPaths, wxArrayString *aNames=NULL)
Save or load the names of the currently configured part libraries (without paths).
Class PROJECT holds project specific data.
Definition: project.h:56
This file is part of the common library TODO brief description.
bool IsPower() const
void LoadAllLibraries(PROJECT *aProject, bool aShowProgress=true)
Load all of the project&#39;s libraries into this container, which should be cleared before calling it...
static int s_modify_generation
helper for GetModifyHash()
void Save(bool aSaveDocFile=true)
bool isModified
Library modification status.
This file is part of the common library.
PART_LIB * GetCacheLibrary()
LIB_ALIAS * RemoveAlias(LIB_ALIAS *aEntry)
Safely remove aEntry from the library and return the next entry.
bool IsCache() const
wxArrayString GetLibraryNames(bool aSorted=true)
Return the list of part library file names without path and extension.
int GetModifyHash()
Return the modification hash for all libraries.
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:94
The common library.
int type
Library type indicator.
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
PART_LIB * FindLibrary(const wxString &aName)
Find a part library by aName.
static const wxString CacheName(const wxString &aFullProjectFilename)
Return the name of the cache library after potentially fixing it from an older naming scheme...
Class PROPERTIES is a name/value tuple with unique names and optional values.
Definition: properties.h:34
LIB_ALIAS * FindLibraryAlias(const LIB_ID &aLibId, const wxString &aLibraryName=wxEmptyString)
Function FindLibraryEntry searches all libraries in the list for an entry.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
Configuration parameter - PARAM_CFG_FILENAME Class Same as PARAM_CFG_WXSTRING, but stores "\" as "/"...
This file contains miscellaneous commonly used macros and functions.
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
void EnableBuffering(bool aEnable=true)
wxString wx_str() const
Definition: utf8.cpp:48
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
Definition: ki_exception.h:133
const UTF8 & GetLibItemName() const
Definition: lib_id.h:115
wxDateTime timeStamp
Library save time and date.
PART_LIB * AddLibrary(const wxString &aFileName)
Allocate and adds a part library to the library list.
const wxString GetName() const
Return the file name without path or extension.
static PART_LIB * LoadLibrary(const wxString &aFileName)
Allocate and load a symbol library file.
Define a library symbol object.
LIB_ALIAS * FindAlias(const wxString &aName) const
Find LIB_ALIAS by aName.
The common library.
Base window classes and related definitions.
bool HasPowerParts() const
#define GROUP_SCH
Definition: config_params.h:44
void SetCache()
std::unique_ptr< PROPERTIES > m_properties
Library properties.
#define GROUP_SCH_LIBS
(Now in fp lib tables)
Definition: config_params.h:50
LIB_PART * FindLibPart(const LIB_ID &aLibId, const wxString &aLibraryName=wxEmptyString)
Search all libraries in the list for a part.
static const char * PropNoDocFile
const char* PropBuffering
static bool Sort(const EDA_ITEM *aLeft, const EDA_ITEM *aRight)
Function Sort is a helper function to be used by the C++ STL sort algorithm for sorting a STL contain...
Definition: base_struct.h:492
SCH_IO_MGR::SCH_FILE_T m_pluginType
LIB_PART * GetPart() const
Get the shared LIB_PART.
YYCODETYPE lhs
wxFileName fileName
Library file name.
A collection of PART_LIB objects.
void AddPart(LIB_PART *aPart)
Add aPart entry to library.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
const wxString & GetName() const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
int versionMinor
Library minor version number.
void GetAliases(std::vector< LIB_ALIAS * > &aAliases) const
Load a vector with all the entries in this library.
static const char * PropBuffering
const char* PropBuffering
PART_LIB * FindLibraryByFullFileName(const wxString &aFullFileName)
UTF8 Format() const
Definition: lib_id.cpp:263
void SetPluginType(SCH_IO_MGR::SCH_FILE_T aPluginType)
const wxString & GetName() const
void GetEntryTypePowerNames(wxArrayString &aNames) const
Load a string array with the names of entries of type POWER in this library.
LIB_PART * FindPart(const wxString &aName) const
Find part by aName.
VTBL_ENTRY bool ConfigLoad(const SEARCH_STACK &aSearchS, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aForeignConfigFileName=wxEmptyString)
Function ConfigLoad reads a subset of parameters from the "project" file.
Definition: project.cpp:351
wxString FindValidPath(const wxString &aFileName) const
Definition: search_stack.h:71
Definition for part library class.
PART_LIB(int aType, const wxString &aFileName, SCH_IO_MGR::SCH_FILE_T aPluginType=SCH_IO_MGR::SCH_LEGACY)
void Create(const wxString &aFileName=wxEmptyString)
const wxString SchematicLibraryFileExtension
Object used to load, save, search, and otherwise manipulate symbol library files. ...
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
int versionMajor
Library major version number.
void FindLibraryNearEntries(std::vector< LIB_ALIAS * > &aCandidates, const wxString &aEntryName, const wxString &aLibraryName=wxEmptyString)
Function FindLibraryNearEntries Searches all libraries in the list for an entry, using a case insensi...