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