44#include <wx/progdlg.h>
45#include <wx/tokenzr.h>
49 SCH_IO_MGR::SCH_FILE_T aPluginType ) :
50 m_pluginType( aPluginType )
78 wxString::Format( wxT(
"no plugin defined for library `%s`." ),
93 wxString tmpFileName =
fileName.GetFullPath();
95 if( !aFileName.IsEmpty() )
96 tmpFileName = aFileName;
151 std::sort( aSymbols.begin(), aSymbols.end(),
154 return lhs->GetName() < rhs->GetName();
171 SIM_MODEL::MigrateSimModel<LIB_SYMBOL, LIB_FIELD>( *symbol,
nullptr );
202 wxCHECK_MSG( aEntry !=
nullptr,
nullptr,
"NULL pointer cannot be removed from library." );
218 wxASSERT( aOldSymbol !=
nullptr );
219 wxASSERT( aNewSymbol !=
nullptr );
239 std::unique_ptr<SYMBOL_LIB> lib = std::make_unique<SYMBOL_LIB>( SCH_LIB_TYPE::LT_EESCHEMA,
242 std::vector<LIB_SYMBOL*> parts;
244 lib->GetSymbols( parts );
249 for(
size_t ii = 0; ii < parts.size(); ii++ )
253 part->
SetLib( lib.get() );
265 wxFileName fn = aFileName;
289 wxFileName fn( aFileName );
299 if( aIterator >= begin() && aIterator < end() )
300 insert( aIterator, lib );
316 wxFileName fn = aFileName;
326 for(
auto it = begin(); it != end(); ++it )
328 if( it->GetName() == fn.GetName() )
350 push_back( cloneLib );
358 for( SYMBOL_LIBS::iterator it = begin(); it!=end(); ++it )
360 if( it->GetName() == aName )
370 for( SYMBOL_LIBS::iterator it = begin(); it!=end(); ++it )
382 for( SYMBOL_LIBS::iterator it = begin(); it!=end(); ++it )
384 if( it->GetFullFileName() == aFullFileName )
394 wxArrayString cacheNames;
400 cacheNames.Add( lib.
GetName() );
409 for(
unsigned int i = 0; i<cacheNames.Count(); i++ )
410 names.Add( cacheNames.Item( i ) );
422 if( !aLibraryName.IsEmpty() && lib.
GetName() != aLibraryName )
436 const wxString& aEntryName,
437 const wxString& aLibraryName )
441 if( !aLibraryName.IsEmpty() && lib.
GetName() != aLibraryName )
444 wxArrayString partNames;
448 if( partNames.IsEmpty() )
451 for(
size_t i = 0; i < partNames.size(); i++ )
453 if( partNames[i].CmpNoCase( aEntryName ) == 0 )
454 aCandidates.push_back( lib.
FindSymbol( partNames[i] ) );
462 wxCHECK_RET( aProject,
"Null PROJECT in GetLibNamesAndPaths" );
467 *aPaths =
project.m_LegacyLibDir;
470 *aNames =
project.m_LegacyLibNames;
475 const wxArrayString& aNames )
477 wxCHECK_RET( aProject,
"Null PROJECT in SetLibNamesAndPaths" );
481 project.m_LegacyLibDir = aPaths;
482 project.m_LegacyLibNames = aNames;
488 wxFileName
name = aFullProjectFilename;
490 name.SetName(
name.GetName() +
"-cache" );
493 if(
name.FileExists() )
494 return name.GetFullPath();
496 return wxEmptyString;
503 wxString libs_not_found;
506#if defined(DEBUG) && 0
507 lib_search->Show( __func__ );
510 wxArrayString lib_names;
515 if( !lib_names.empty() )
519 lib_names.GetCount(),
529 for(
unsigned i = 0; i < lib_names.GetCount(); ++i )
533 lib_dialog.
Update( i, wxString::Format(
_(
"Loading %s..." ), lib_names[i] ) );
541 wxFileName fn( fullname );
547 if( !fn.FileExists() )
549 filename = lib_search->FindValidPath( fn.GetFullPath() );
553 libs_not_found += fn.GetFullPath();
554 libs_not_found +=
'\n';
563 if( !fn.IsAbsolute() )
566 filename = fn.GetFullPath();
576 msg.Printf(
_(
"Symbol library '%s' failed to load." ), filename );
578 wxLogError( msg + wxS(
"\n" ) + ioe.
What() );
598 wxString msg = wxString::Format(
_(
"Error loading symbol library '%s'." )
608 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.
static SEARCH_STACK * SchSearchS(PROJECT *aProject)
Accessor for Eeschema search stack.
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.
bool ReloadLibrary(const wxString &aFileName)
Refreshes the library from the (possibly updated) contents on disk.
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.
Definition for symbol library class.
Definition of file extensions used in Kicad.