45#include <wx/progdlg.h>
46#include <wx/tokenzr.h>
50 SCH_IO_MGR::SCH_FILE_T aPluginType ) :
51 m_pluginType( aPluginType )
94 wxString tmpFileName =
fileName.GetFullPath();
96 if( !aFileName.IsEmpty() )
97 tmpFileName = aFileName;
152 std::sort( aSymbols.begin(), aSymbols.end(),
155 return lhs->GetName() < rhs->GetName();
172 SIM_MODEL::MigrateSimModel<LIB_SYMBOL, LIB_FIELD>( *symbol,
nullptr );
203 wxCHECK_MSG( aEntry !=
nullptr,
nullptr,
"NULL pointer cannot be removed from library." );
219 wxASSERT( aOldSymbol !=
nullptr );
220 wxASSERT( aNewSymbol !=
nullptr );
243 std::vector<LIB_SYMBOL*> parts;
245 lib->GetSymbols( parts );
250 for(
size_t ii = 0; ii < parts.size(); ii++ )
254 part->
SetLib( lib.get() );
266 wxFileName fn = aFileName;
290 wxFileName fn( aFileName );
300 if( aIterator >= begin() && aIterator < end() )
301 insert( aIterator, lib );
316 for( SYMBOL_LIBS::iterator it = begin(); it!=end(); ++it )
318 if( it->GetName() == aName )
328 for( SYMBOL_LIBS::iterator it = begin(); it!=end(); ++it )
340 for( SYMBOL_LIBS::iterator it = begin(); it!=end(); ++it )
342 if( it->GetFullFileName() == aFullFileName )
352 wxArrayString cacheNames;
358 cacheNames.Add( lib.
GetName() );
367 for(
unsigned int i = 0; i<cacheNames.Count(); i++ )
368 names.Add( cacheNames.Item( i ) );
380 if( !aLibraryName.IsEmpty() && lib.
GetName() != aLibraryName )
394 const wxString& aEntryName,
395 const wxString& aLibraryName )
399 if( !aLibraryName.IsEmpty() && lib.
GetName() != aLibraryName )
402 wxArrayString partNames;
406 if( partNames.IsEmpty() )
409 for(
size_t i = 0; i < partNames.size(); i++ )
411 if( partNames[i].CmpNoCase( aEntryName ) == 0 )
412 aCandidates.push_back( lib.
FindSymbol( partNames[i] ) );
420 wxCHECK_RET( aProject,
"Null PROJECT in GetLibNamesAndPaths" );
425 *aPaths =
project.m_LegacyLibDir;
428 *aNames =
project.m_LegacyLibNames;
433 const wxArrayString& aNames )
435 wxCHECK_RET( aProject,
"Null PROJECT in SetLibNamesAndPaths" );
439 project.m_LegacyLibDir = aPaths;
440 project.m_LegacyLibNames = aNames;
446 wxFileName
name = aFullProjectFilename;
448 name.SetName(
name.GetName() +
"-cache" );
451 if(
name.FileExists() )
452 return name.GetFullPath();
454 return wxEmptyString;
461 wxString libs_not_found;
464#if defined(DEBUG) && 0
465 lib_search->Show( __func__ );
468 wxArrayString lib_names;
473 if( !lib_names.empty() )
477 lib_names.GetCount(),
487 for(
unsigned i = 0; i < lib_names.GetCount(); ++i )
499 wxFileName fn( fullname );
505 if( !fn.FileExists() )
507 filename = lib_search->FindValidPath( fn.GetFullPath() );
511 libs_not_found += fn.GetFullPath();
512 libs_not_found +=
'\n';
521 if( !fn.IsAbsolute() )
524 filename = fn.GetFullPath();
534 msg.Printf(
_(
"Symbol library '%s' failed to load." ), filename );
536 wxLogError( msg + wxS(
"\n" ) + ioe.
What() );
566 if( !libs_not_found.IsEmpty() )
wxProgressDialog with the option to also update the application progress on the taskbar
virtual bool Update(int aValue, const wxString &aNewMsg=wxEmptyString, bool *aSkip=nullptr) override
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
A logical library item identifier and consists of various portions much like a URI.
const UTF8 & GetLibItemName() const
Define a library symbol object.
wxString GetName() const override
void SetLib(SYMBOL_LIB *aLibrary)
LIB_SYMBOL_SPTR SharedPtr() const
SYMBOL_LIB * GetLib() const
The backing store for a PROJECT, in JSON format.
Container for project specific data.
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
virtual PROJECT_FILE & GetProjectFile() const
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
static const char * PropNoDocFile
The property used internally by the plugin to disable writing the library documentation (....
static const char * PropBuffering
The property used internally by the plugin to enable cache buffering which prevents the library file ...
Look for files in a number of paths.
A name/value tuple with unique names and optional values.
void FindLibraryNearEntries(std::vector< LIB_SYMBOL * > &aCandidates, const wxString &aEntryName, const wxString &aLibraryName=wxEmptyString)
Search all libraries in the list for a LIB_SYMBOL using a case insensitive comparison.
static void SetLibNamesAndPaths(PROJECT *aProject, const wxString &aPaths, const wxArrayString &aNames)
SYMBOL_LIB * FindLibrary(const wxString &aName)
Find a symbol library by aName.
SYMBOL_LIB * FindLibraryByFullFileName(const wxString &aFullFileName)
wxArrayString GetLibraryNames(bool aSorted=true)
Return the list of symbol library file names without path and extension.
void LoadAllLibraries(PROJECT *aProject, bool aShowProgress=true)
Load all of the project's libraries into this container, which should be cleared before calling it.
static const wxString CacheName(const wxString &aFullProjectFilename)
Return the name of the cache library after potentially fixing it from an older naming scheme.
LIB_SYMBOL * FindLibSymbol(const LIB_ID &aLibId, const wxString &aLibraryName=wxEmptyString)
Search all libraries in the list for a symbol.
SYMBOL_LIB * AddLibrary(const wxString &aFileName)
Allocate and adds a symbol library to the library list.
static void GetLibNamesAndPaths(PROJECT *aProject, wxString *aPaths, wxArrayString *aNames=nullptr)
SYMBOL_LIB * GetCacheLibrary()
Object used to load, save, search, and otherwise manipulate symbol library files.
SCH_IO_MGR::SCH_FILE_T m_pluginType
void Create(const wxString &aFileName=wxEmptyString)
void GetSymbols(std::vector< LIB_SYMBOL * > &aSymbols) const
Load a vector with all the entries in this library.
std::unique_ptr< SCH_PLUGIN > m_plugin
void SetPluginType(SCH_IO_MGR::SCH_FILE_T aPluginType)
SCH_LIB_TYPE type
Library type indicator.
SYMBOL_LIB(SCH_LIB_TYPE aType, const wxString &aFileName, SCH_IO_MGR::SCH_FILE_T aPluginType=SCH_IO_MGR::SCH_LEGACY)
void EnableBuffering(bool aEnable=true)
void Save(bool aSaveDocFile=true)
LIB_SYMBOL * FindSymbol(const wxString &aName) const
Find LIB_SYMBOL by aName.
void AddSymbol(LIB_SYMBOL *aSymbol)
Add aSymbol entry to library.
static SYMBOL_LIB * LoadSymbolLibrary(const wxString &aFileName)
Allocate and load a symbol library file.
bool isModified
Library modification status.
void GetSymbolNames(wxArrayString &aNames) const
Load a string array with the names of all the entries in this library.
wxDateTime timeStamp
Library save time and date.
int versionMinor
Library minor version number.
int m_mod_hash
incremented each time library is changed.
LIB_SYMBOL * ReplaceSymbol(LIB_SYMBOL *aOldSymbol, LIB_SYMBOL *aNewSymbol)
Replace an existing symbol entry in the library.
wxFileName fileName
Library file name.
int versionMajor
Library major version number.
std::unique_ptr< STRING_UTF8_MAP > m_properties
Library properties.
const wxString GetName() const
Return the file name without path or extension.
LIB_SYMBOL * RemoveSymbol(LIB_SYMBOL *aEntry)
Safely remove aEntry from the library and return the next entry.
Base window classes and related definitions.
const std::string LegacySymbolLibFileExtension
#define THROW_IO_ERROR(msg)
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
This file contains miscellaneous commonly used macros and functions.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition for symbol library class.
Definition of file extensions used in Kicad.