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 <kicad_string.h>
36 #include <gestfich.h>
37 #include <eda_doc.h>
38 #include <wxstruct.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_PART* PART_LIB::FindPart( const wxString& aName ) const
204 {
205  LIB_ALIAS* alias = FindAlias( aName );
206 
207  if( alias != NULL )
208  return alias->GetPart();
209 
210  return NULL;
211 }
212 
213 
215 {
216  // return true if at least one power part is found in lib
217  std::vector<LIB_ALIAS*> aliases;
218 
219  m_plugin->EnumerateSymbolLib( aliases, fileName.GetFullPath(), m_properties.get() );
220 
221  for( size_t i = 0; i < aliases.size(); i++ )
222  {
223  LIB_ALIAS* alias = aliases[i];
224 
225  LIB_PART* root = alias->GetPart();
226 
227  if( !root || root->IsPower() )
228  return true;
229  }
230 
231  return false;
232 }
233 
234 
236 {
237  // add a clone, not the caller's copy, the plugin take ownership of the new symbol.
238  m_plugin->SaveSymbol( fileName.GetFullPath(), new LIB_PART( *aPart, this ), m_properties.get() );
239 
240  // If we are not buffering, the library file is updated immediately when the plugin
241  // SaveSymbol() function is called.
242  if( IsBuffering() )
243  isModified = true;
244 
245  ++m_mod_hash;
246 }
247 
248 
250 {
251  wxCHECK_MSG( aEntry != NULL, NULL, "NULL pointer cannot be removed from library." );
252 
253  m_plugin->DeleteAlias( fileName.GetFullPath(), aEntry->GetName(), m_properties.get() );
254 
255  // If we are not buffering, the library file is updated immediately when the plugin
256  // SaveSymbol() function is called.
257  if( IsBuffering() )
258  isModified = true;
259 
260  ++m_mod_hash;
261  return NULL;
262 }
263 
264 
266 {
267  wxASSERT( aOldPart != NULL );
268  wxASSERT( aNewPart != NULL );
269 
270  m_plugin->DeleteSymbol( fileName.GetFullPath(), aOldPart->GetName(), m_properties.get() );
271 
272  LIB_PART* my_part = new LIB_PART( *aNewPart, this );
273 
274  m_plugin->SaveSymbol( fileName.GetFullPath(), my_part, m_properties.get() );
275 
276  // If we are not buffering, the library file is updated immediately when the plugin
277  // SaveSymbol() function is called.
278  if( IsBuffering() )
279  isModified = true;
280 
281  ++m_mod_hash;
282  return my_part;
283 }
284 
285 
286 PART_LIB* PART_LIB::LoadLibrary( const wxString& aFileName )
287 {
288  std::unique_ptr<PART_LIB> lib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, aFileName ) );
289 
290  std::vector<LIB_ALIAS*> aliases;
291  // This loads the library.
292  lib->GetAliases( aliases );
293 
294  // Now, set the LIB_PART m_library member but it will only be used
295  // when loading legacy libraries in the future. Once the symbols in the
296  // schematic have a full #LIB_ID, this will not get called.
297  for( size_t ii = 0; ii < aliases.size(); ii++ )
298  {
299  LIB_ALIAS* alias = aliases[ii];
300 
301  if( alias->GetPart() )
302  alias->GetPart()->SetLib( lib.get() );
303  }
304 
305  PART_LIB* ret = lib.release();
306  return ret;
307 }
308 
309 
310 PART_LIB* PART_LIBS::AddLibrary( const wxString& aFileName )
311 {
312  PART_LIB* lib;
313 
314  wxFileName fn = aFileName;
315  // Don't reload the library if it is already loaded.
316  lib = FindLibrary( fn.GetName() );
317 
318  if( lib )
319  return lib;
320 
321  lib = PART_LIB::LoadLibrary( aFileName );
322 
323  push_back( lib );
324 
325  return lib;
326 }
327 
328 
329 PART_LIB* PART_LIBS::AddLibrary( const wxString& aFileName, PART_LIBS::iterator& aIterator )
330 {
331  // Don't reload the library if it is already loaded.
332  wxFileName fn( aFileName );
333  PART_LIB* lib = FindLibrary( fn.GetName() );
334 
335  if( lib )
336  return lib;
337 
338  lib = PART_LIB::LoadLibrary( aFileName );
339 
340  if( aIterator >= begin() && aIterator < end() )
341  insert( aIterator, lib );
342  else
343  push_back( lib );
344 
345  return lib;
346 }
347 
348 
349 PART_LIB* PART_LIBS::FindLibrary( const wxString& aName )
350 {
351  for( PART_LIBS::iterator it = begin(); it!=end(); ++it )
352  {
353  if( it->GetName() == aName )
354  return &*it;
355  }
356 
357  return NULL;
358 }
359 
360 
362 {
363  for( PART_LIBS::iterator it = begin(); it!=end(); ++it )
364  {
365  if( it->IsCache() )
366  return &*it;
367  }
368 
369  return NULL;
370 }
371 
372 
373 PART_LIB* PART_LIBS::FindLibraryByFullFileName( const wxString& aFullFileName )
374 {
375  for( PART_LIBS::iterator it = begin(); it!=end(); ++it )
376  {
377  if( it->GetFullFileName() == aFullFileName )
378  return &*it;
379  }
380 
381  return NULL;
382 }
383 
384 
385 wxArrayString PART_LIBS::GetLibraryNames( bool aSorted )
386 {
387  wxArrayString cacheNames;
388  wxArrayString names;
389 
390  for( PART_LIB& lib : *this )
391  {
392  if( lib.IsCache() && aSorted )
393  cacheNames.Add( lib.GetName() );
394  else
395  names.Add( lib.GetName() );
396  }
397 
398  // Even sorted, the cache library is always at the end of the list.
399  if( aSorted )
400  names.Sort();
401 
402  for( unsigned int i = 0; i<cacheNames.Count(); i++ )
403  names.Add( cacheNames.Item( i ) );
404 
405  return names;
406 }
407 
408 
409 LIB_PART* PART_LIBS::FindLibPart( const LIB_ID& aLibId, const wxString& aLibraryName )
410 {
411  LIB_PART* part = NULL;
412 
413  for( PART_LIB& lib : *this )
414  {
415  if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName )
416  continue;
417 
418  part = lib.FindPart( aLibId.GetLibItemName() );
419 
420  if( part )
421  break;
422  }
423 
424  return part;
425 }
426 
427 
428 LIB_ALIAS* PART_LIBS::FindLibraryAlias( const LIB_ID& aLibId, const wxString& aLibraryName )
429 {
430  LIB_ALIAS* entry = NULL;
431 
432  for( PART_LIB& lib : *this )
433  {
434  if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName )
435  continue;
436 
437  entry = lib.FindAlias( aLibId.GetLibItemName() );
438 
439  if( entry )
440  break;
441  }
442 
443  return entry;
444 }
445 
446 
447 void PART_LIBS::FindLibraryNearEntries( std::vector<LIB_ALIAS*>& aCandidates,
448  const wxString& aEntryName,
449  const wxString& aLibraryName )
450 {
451  for( PART_LIB& lib : *this )
452  {
453  if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName )
454  continue;
455 
456  wxArrayString aliasNames;
457 
458  lib.GetAliasNames( aliasNames );
459 
460  if( aliasNames.IsEmpty() )
461  continue;
462 
463  for( size_t i = 0; i < aliasNames.size(); i++ )
464  {
465  if( aliasNames[i].CmpNoCase( aEntryName ) == 0 )
466  aCandidates.push_back( lib.FindAlias( aliasNames[i] ) );
467  }
468  }
469 }
470 
471 
472 int PART_LIBS::s_modify_generation = 1; // starts at 1 and goes up
473 
474 
476 {
477  int hash = 0;
478 
479  for( PART_LIBS::const_iterator it = begin(); it != end(); ++it )
480  {
481  hash += it->GetModHash();
482  }
483 
484  // Rebuilding the cache (m_cache) does not change the GetModHash() value,
485  // but changes PART_LIBS::s_modify_generation.
486  // Take this change in account:
488 
489  return hash;
490 }
491 
492 
493 void PART_LIBS::LibNamesAndPaths( PROJECT* aProject, bool doSave,
494  wxString* aPaths, wxArrayString* aNames )
495 {
496  wxString pro = aProject->GetProjectFullName();
497 
498  PARAM_CFG_ARRAY ca;
499 
500  if( aPaths )
501  ca.push_back( new PARAM_CFG_FILENAME( "LibDir", aPaths ) );
502 
503  if( aNames )
504  ca.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ), aNames, GROUP_SCH_LIBS ) );
505 
506  if( doSave )
507  {
508  aProject->ConfigSave( Kiface().KifaceSearch(), GROUP_SCH, ca );
509 
510  /*
511  {
512  wxString msg = wxString::Format( _(
513  "Unable save project's '%s' file" ),
514  GetChars( pro )
515  );
516  THROW_IO_ERROR( msg );
517  }
518  */
519  }
520  else
521  {
522  if( !aProject->ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH, ca ) )
523  {
524  wxString msg = wxString::Format( _(
525  "Unable to load project's '%s' file" ),
526  GetChars( pro )
527  );
528  THROW_IO_ERROR( msg );
529  }
530  }
531 }
532 
533 
534 const wxString PART_LIBS::CacheName( const wxString& aFullProjectFilename )
535 {
536  /* until apr 2009 the project cache lib was named: <root_name>.cache.lib,
537  * and after: <root_name>-cache.lib. So if the <name>-cache.lib is not found,
538  * the old file will be renamed and returned.
539  */
540  wxFileName new_name = aFullProjectFilename;
541 
542  new_name.SetName( new_name.GetName() + "-cache" );
543  new_name.SetExt( SchematicLibraryFileExtension );
544 
545  if( new_name.FileExists() )
546  return new_name.GetFullPath();
547  else
548  {
549  wxFileName old_name = aFullProjectFilename;
550  old_name.SetExt( "cache.lib" );
551 
552  if( old_name.FileExists() )
553  {
554  wxRenameFile( old_name.GetFullPath(), new_name.GetFullPath() );
555  return new_name.GetFullPath();
556  }
557  }
558 
559  return wxEmptyString;
560 }
561 
562 
563 void PART_LIBS::LoadAllLibraries( PROJECT* aProject, bool aShowProgress )
564 {
565  wxString filename;
566  wxString libs_not_found;
567  SEARCH_STACK* lib_search = aProject->SchSearchS();
568 
569 #if defined(DEBUG) && 0
570  lib_search->Show( __func__ );
571 #endif
572 
573  wxArrayString lib_names;
574 
575  LibNamesAndPaths( aProject, false, NULL, &lib_names );
576 
577  // Post symbol library table, this should be empty. Only the cache library should get loaded.
578  if( !lib_names.empty() )
579  {
580  wxProgressDialog lib_dialog( _( "Loading Symbol Libraries" ),
581  wxEmptyString,
582  lib_names.GetCount(),
583  NULL,
584  wxPD_APP_MODAL );
585 
586  if( aShowProgress )
587  {
588  lib_dialog.Show();
589  }
590 
591  wxString progress_message;
592 
593  for( unsigned i = 0; i < lib_names.GetCount(); ++i )
594  {
595  if( aShowProgress )
596  {
597  lib_dialog.Update( i, _( "Loading " + lib_names[i] ) );
598  }
599 
600  // lib_names[] does not store the file extension. Set it.
601  // Remember lib_names[i] can contain a '.' in name, so using a wxFileName
602  // before adding the extension can create incorrect full filename
603  wxString fullname = lib_names[i] + "." + SchematicLibraryFileExtension;
604  // Now the full name is set, we can use a wxFileName.
605  wxFileName fn( fullname );
606 
607  // Skip if the file name is not valid..
608  if( !fn.IsOk() )
609  continue;
610 
611  if( !fn.FileExists() )
612  {
613  filename = lib_search->FindValidPath( fn.GetFullPath() );
614 
615  if( !filename )
616  {
617  libs_not_found += fn.GetFullPath();
618  libs_not_found += '\n';
619  continue;
620  }
621  }
622  else
623  { // ensure the lib filename has a absolute path.
624  // If the lib has no absolute path, and is found in the cwd by fn.FileExists(),
625  // make a full absolute path, to avoid issues with load library functions which
626  // expects an absolute path.
627  if( !fn.IsAbsolute() )
628  fn.MakeAbsolute();
629 
630  filename = fn.GetFullPath();
631  }
632 
633  try
634  {
635  AddLibrary( filename );
636  }
637  catch( const IO_ERROR& ioe )
638  {
639  wxString msg;
640  msg.Printf( _( "Part library '%s' failed to load. Error:\n %s" ),
641  GetChars( filename ), GetChars( ioe.What() ) );
642 
643  wxLogError( msg );
644  }
645  }
646  }
647 
648  // add the special cache library.
649  wxString cache_name = CacheName( aProject->GetProjectFullName() );
650  PART_LIB* cache_lib;
651 
652  if( !cache_name.IsEmpty() )
653  {
654  try
655  {
656  cache_lib = AddLibrary( cache_name );
657 
658  if( cache_lib )
659  cache_lib->SetCache();
660  }
661  catch( const IO_ERROR& ioe )
662  {
663  wxString msg = wxString::Format( _(
664  "Part library '%s' failed to load.\nError: %s" ),
665  GetChars( cache_name ),
666  GetChars( ioe.What() )
667  );
668 
669  THROW_IO_ERROR( msg );
670  }
671  }
672 
673  // Print the libraries not found
674  if( !libs_not_found.IsEmpty() )
675  {
676  // Use a different exception type so catch()er can route to proper use
677  // of the HTML_MESSAGE_BOX.
678  THROW_PARSE_ERROR( wxEmptyString, __func__, TO_UTF8( libs_not_found ), 0, 0 );
679  }
680 
681 #if defined(DEBUG) && 1
682  printf( "%s: lib_names:\n", __func__ );
683 
684  for( PART_LIBS::const_iterator it = begin(); it < end(); ++it )
685  printf( " %s\n", TO_UTF8( it->GetName() ) );
686 #endif
687 }
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:318
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)
Function LibNamesAndPaths either saves or loads the names of the currently configured part libraries ...
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)
Function LoadAllLibraries loads all of the project'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)
Function GetLibraryNames returns 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:96
The common library.
int type
Library type indicator.
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
Class LIB_ID.
Definition: lib_id.h:56
PART_LIB * FindLibrary(const wxString &aName)
Function FindLibrary finds a part library by aName.
static const wxString CacheName(const wxString &aFullProjectFilename)
Function cacheName returns the name of the cache library after potentially fixing it from an older na...
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)
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
Definition: ki_exception.h:133
Base window classes and related definitions.
const wxString & GetName() const
const UTF8 & GetLibItemName() const
Function GetLibItemName.
Definition: lib_id.h:129
wxDateTime timeStamp
Library save time and date.
PART_LIB * AddLibrary(const wxString &aFileName)
Function AddLibrary allocates 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)
Function LoadLibrary allocates and loads a part library file.
Class LIB_PART defines a library part object.
LIB_ALIAS * FindAlias(const wxString &aName) const
Find LIB_ALIAS by aName.
The common library.
bool HasPowerParts() const
Function HasPowerParts.
#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)
Function FindLibPart searches 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:477
SCH_IO_MGR::SCH_FILE_T m_pluginType
LIB_PART * GetPart() const
Function GetPart gets the shared LIB_PART.
wxFileName fileName
Library file name.
Class PART_LIBS is a collection of PART_LIBs.
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)
void SetPluginType(SCH_IO_MGR::SCH_FILE_T aPluginType)
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:353
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
Class PART_LIB is used to load, save, search, and otherwise manipulate part 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...