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-2017 Wayne Stambaugh <stambaughw@verizon.net>
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 
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 
113 {
114  if( m_pluginType != aPluginType )
115  {
116  m_pluginType = aPluginType;
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 )
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 )
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 )
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 )
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( this );
198 
199  return alias;
200 }
201 
202 
203 LIB_PART* PART_LIB::FindPart( const wxString& aName )
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 
361 PART_LIB* PART_LIBS::FindLibraryByFullFileName( const wxString& aFullFileName )
362 {
363  for( PART_LIBS::iterator it = begin(); it!=end(); ++it )
364  {
365  if( it->GetFullFileName() == aFullFileName )
366  return &*it;
367  }
368 
369  return NULL;
370 }
371 
372 
373 wxArrayString PART_LIBS::GetLibraryNames( bool aSorted )
374 {
375  wxArrayString cacheNames;
376  wxArrayString names;
377 
378  for( PART_LIB& lib : *this )
379  {
380  if( lib.IsCache() && aSorted )
381  cacheNames.Add( lib.GetName() );
382  else
383  names.Add( lib.GetName() );
384  }
385 
386  // Even sorted, the cache library is always at the end of the list.
387  if( aSorted )
388  names.Sort();
389 
390  for( unsigned int i = 0; i<cacheNames.Count(); i++ )
391  names.Add( cacheNames.Item( i ) );
392 
393  return names;
394 }
395 
396 
397 LIB_PART* PART_LIBS::FindLibPart( const LIB_ID& aLibId, const wxString& aLibraryName )
398 {
399  LIB_PART* part = NULL;
400 
401  for( PART_LIB& lib : *this )
402  {
403  if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName )
404  continue;
405 
406  part = lib.FindPart( FROM_UTF8( aLibId.GetLibItemName() ) );
407 
408  if( part )
409  break;
410  }
411 
412  return part;
413 }
414 
415 
416 LIB_ALIAS* PART_LIBS::FindLibraryAlias( const LIB_ID& aLibId, const wxString& aLibraryName )
417 {
418  LIB_ALIAS* entry = NULL;
419 
420  for( PART_LIB& lib : *this )
421  {
422  if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName )
423  continue;
424 
425  entry = lib.FindAlias( FROM_UTF8( aLibId.GetLibItemName() ) );
426 
427  if( entry )
428  break;
429  }
430 
431  return entry;
432 }
433 
434 
435 /* searches all libraries in the list for an entry, using a case insensitive comparison.
436  * Used to find an entry, when the normal (case sensitive) search fails.
437  */
438 void PART_LIBS::FindLibraryNearEntries( std::vector<LIB_ALIAS*>& aCandidates,
439  const wxString& aEntryName,
440  const wxString& aLibraryName )
441 {
442  for( PART_LIB& lib : *this )
443  {
444  if( !aLibraryName.IsEmpty() && lib.GetName() != aLibraryName )
445  continue;
446 
447  wxArrayString aliasNames;
448 
449  lib.GetAliasNames( aliasNames );
450 
451  if( aliasNames.IsEmpty() )
452  continue;
453 
454  for( size_t i = 0; i < aliasNames.size(); i++ )
455  {
456  if( aliasNames[i].CmpNoCase( aEntryName ) == 0 )
457  aCandidates.push_back( lib.FindAlias( aliasNames[i] ) );
458  }
459  }
460 }
461 
462 
463 int PART_LIBS::s_modify_generation = 1; // starts at 1 and goes up
464 
465 
467 {
468  int hash = 0;
469 
470  for( PART_LIBS::const_iterator it = begin(); it != end(); ++it )
471  {
472  hash += it->GetModHash();
473  }
474 
475  // Rebuilding the cache (m_cache) does not change the GetModHash() value,
476  // but changes PART_LIBS::s_modify_generation.
477  // Take this change in account:
479 
480  return hash;
481 }
482 
483 
484 void PART_LIBS::LibNamesAndPaths( PROJECT* aProject, bool doSave,
485  wxString* aPaths, wxArrayString* aNames )
486 {
487  wxString pro = aProject->GetProjectFullName();
488 
489  PARAM_CFG_ARRAY ca;
490 
491  if( aPaths )
492  ca.push_back( new PARAM_CFG_FILENAME( "LibDir", aPaths ) );
493 
494  if( aNames )
495  ca.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ), aNames, GROUP_SCH_LIBS ) );
496 
497  if( doSave )
498  {
499  aProject->ConfigSave( Kiface().KifaceSearch(), GROUP_SCH, ca );
500 
501  /*
502  {
503  wxString msg = wxString::Format( _(
504  "Unable save project's '%s' file" ),
505  GetChars( pro )
506  );
507  THROW_IO_ERROR( msg );
508  }
509  */
510  }
511  else
512  {
513  if( !aProject->ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH, ca ) )
514  {
515  wxString msg = wxString::Format( _(
516  "Unable to load project's '%s' file" ),
517  GetChars( pro )
518  );
519  THROW_IO_ERROR( msg );
520  }
521  }
522 }
523 
524 
525 const wxString PART_LIBS::CacheName( const wxString& aFullProjectFilename )
526 {
527  /* until apr 2009 the project cache lib was named: <root_name>.cache.lib,
528  * and after: <root_name>-cache.lib. So if the <name>-cache.lib is not found,
529  * the old file will be renamed and returned.
530  */
531  wxFileName new_name = aFullProjectFilename;
532 
533  new_name.SetName( new_name.GetName() + "-cache" );
534  new_name.SetExt( SchematicLibraryFileExtension );
535 
536  if( new_name.FileExists() )
537  return new_name.GetFullPath();
538  else
539  {
540  wxFileName old_name = aFullProjectFilename;
541  old_name.SetExt( "cache.lib" );
542 
543  if( old_name.FileExists() )
544  {
545  wxRenameFile( old_name.GetFullPath(), new_name.GetFullPath() );
546  return new_name.GetFullPath();
547  }
548  }
549  return wxEmptyString;
550 }
551 
552 
553 void PART_LIBS::LoadAllLibraries( PROJECT* aProject, bool aShowProgress )
554 {
555  wxString filename;
556  wxString libs_not_found;
557  SEARCH_STACK* lib_search = aProject->SchSearchS();
558 
559 #if defined(DEBUG) && 0
560  lib_search->Show( __func__ );
561 #endif
562 
563  wxArrayString lib_names;
564 
565  LibNamesAndPaths( aProject, false, NULL, &lib_names );
566 
567  // If the list is empty, force loading the standard power symbol library.
568  if( !lib_names.GetCount() )
569  lib_names.Add( "power" );
570 
571  wxASSERT( !size() ); // expect to load into "this" empty container.
572 
573  wxProgressDialog lib_dialog( _( "Loading Symbol Libraries" ),
574  wxEmptyString,
575  lib_names.GetCount(),
576  NULL,
577  wxPD_APP_MODAL );
578 
579  if( aShowProgress )
580  {
581  lib_dialog.Show();
582  }
583 
584  wxString progress_message;
585 
586  for( unsigned i = 0; i < lib_names.GetCount(); ++i )
587  {
588  if( aShowProgress )
589  {
590  lib_dialog.Update( i, _( "Loading " + lib_names[i] ) );
591  }
592 
593  // lib_names[] does not store the file extension. Set it.
594  // Remember lib_names[i] can contain a '.' in name, so using a wxFileName
595  // before adding the extension can create incorrect full filename
596  wxString fullname = lib_names[i] + "." + SchematicLibraryFileExtension;
597  // Now the full name is set, we can use a wxFileName.
598  wxFileName fn( fullname );
599 
600  // Skip if the file name is not valid..
601  if( !fn.IsOk() )
602  continue;
603 
604  if( !fn.FileExists() )
605  {
606  filename = lib_search->FindValidPath( fn.GetFullPath() );
607 
608  if( !filename )
609  {
610  libs_not_found += fn.GetFullPath();
611  libs_not_found += '\n';
612  continue;
613  }
614  }
615  else
616  { // ensure the lib filename has a absolute path.
617  // If the lib has no absolute path, and is found in the cwd by fn.FileExists(),
618  // make a full absolute path, to avoid issues with load library functions which
619  // expects an absolute path.
620  if( !fn.IsAbsolute() )
621  fn.MakeAbsolute();
622 
623  filename = fn.GetFullPath();
624  }
625 
626  try
627  {
628  AddLibrary( filename );
629  }
630  catch( const IO_ERROR& ioe )
631  {
632  wxString msg;
633  msg.Printf( _( "Part library '%s' failed to load. Error:\n %s" ),
634  GetChars( filename ), GetChars( ioe.What() ) );
635 
636  wxLogError( msg );
637  }
638  }
639 
640  if( aShowProgress )
641  {
642  lib_dialog.Destroy();
643  }
644 
645  // add the special cache library.
646  wxString cache_name = CacheName( aProject->GetProjectFullName() );
647  PART_LIB* cache_lib;
648 
649  if( !cache_name.IsEmpty() )
650  {
651  try
652  {
653  cache_lib = AddLibrary( cache_name );
654 
655  if( cache_lib )
656  cache_lib->SetCache();
657  }
658  catch( const IO_ERROR& ioe )
659  {
660  wxString msg = wxString::Format( _(
661  "Part library '%s' failed to load.\nError: %s" ),
662  GetChars( cache_name ),
663  GetChars( ioe.What() )
664  );
665 
666  THROW_IO_ERROR( msg );
667  }
668  }
669 
670  // Print the libraries not found
671  if( !libs_not_found.IsEmpty() )
672  {
673  // Use a different exception type so catch()er can route to proper use
674  // of the HTML_MESSAGE_BOX.
675  THROW_PARSE_ERROR( wxEmptyString, UTF8( __func__ ), UTF8( libs_not_found ), 0, 0 );
676  }
677 
678 #if defined(DEBUG) && 1
679  printf( "%s: lib_names:\n", __func__ );
680 
681  for( PART_LIBS::const_iterator it = begin(); it < end(); ++it )
682  printf( " %s\n", TO_UTF8( it->GetName() ) );
683 #endif
684 }
PART_LIB * GetLib()
bool HasPowerParts()
Function HasPowerParts.
Class UTF8 is an 8 bit std::string that is assuredly encoded in UTF8, and supplies special conversion...
Definition: utf8.h:53
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:307
Part library alias object definition.
bool IsBuffering() const
LIB_PART * ReplacePart(LIB_PART *aOldPart, LIB_PART *aNewPart)
Replace an existing part entry in the library.
void GetAliasNames(wxArrayString &aNames)
Load a string array with the names of all the entries in this 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
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
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)
void GetEntryTypePowerNames(wxArrayString &aNames)
Load a string array with the names of entries of type POWER in this library.
bool isModified
Library modification status.
This file is part of the common library.
static SCH_PLUGIN * FindPlugin(SCH_FILE_T aFileType)
Return a SCH_PLUGIN which the caller can use to import, export, save, or load design documents...
Definition: sch_io_mgr.cpp:48
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)
void GetAliases(std::vector< LIB_ALIAS * > &aAliases)
Load a vector with all the entries in this library.
#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.
The common library.
#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
#define THROW_IO_ERROR(x)
Definition: utf8.cpp:60
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:463
SCH_IO_MGR::SCH_FILE_T m_pluginType
const wxString SchematicLibraryFileExtension
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.
static const char * PropBuffering
const char* PropBuffering
PART_LIB * FindLibraryByFullFileName(const wxString &aFullFileName)
void SetPluginType(SCH_IO_MGR::SCH_FILE_T aPluginType)
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:342
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)
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
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...
LIB_ALIAS * FindAlias(const wxString &aName)
Find LIB_ALIAS by aName.
LIB_PART * FindPart(const wxString &aName)
Find part by aName.
SCH_FILE_T
A set of file types that the SCH_IO_MGR knows about, and for which there has been a plugin written...
Definition: sch_io_mgr.h:52