26#include <bs_thread_pool.hpp>
27#include <wx/datetime.h>
29#include <wx/tokenzr.h>
31#include <boost/algorithm/string.hpp>
52 SCH_IO( wxS(
"Database library" ) ),
69 const wxString& aLibraryPath,
70 const std::map<std::string, UTF8>* aProperties )
72 std::vector<LIB_SYMBOL*> symbols;
77 aSymbolNameList.Add( symbol->GetName() );
84 const wxString& aLibraryPath,
85 const std::map<std::string, UTF8>* aProperties )
87 wxCHECK_RET(
m_adapter,
"Database plugin missing library manager adapter handle!" );
103 if( !powerSymbolsOnly || symbol->
IsPower() )
104 aSymbolList.emplace_back( symbol->
Duplicate() );
110 const std::map<std::string, UTF8>* aProperties )
118 const wxString& aAliasName,
119 const std::map<std::string, UTF8>* aProperties )
121 wxCHECK_MSG(
m_adapter,
nullptr,
"Database plugin missing library manager adapter handle!" );
130 std::string tableName;
131 std::string symbolName( aAliasName.ToUTF8() );
146 tableName = sanitizedIt->second.first;
147 symbolName = sanitizedIt->second.second;
160 if( tableName.empty() && aAliasName.Contains(
'/' ) )
162 tableName = std::string( aAliasName.BeforeFirst(
'/' ).ToUTF8() );
163 symbolName = std::string( aAliasName.AfterFirst(
'/' ).ToUTF8() );
166 std::vector<const DATABASE_LIB_TABLE*> tablesToTry;
171 if( tableName.empty() || tableIter.
name == tableName )
172 tablesToTry.emplace_back( &tableIter );
175 if( tablesToTry.empty() )
177 wxLogTrace(
traceDatabase, wxT(
"LoadSymbol: table '%s' not found in config" ), tableName );
189 wxLogTrace(
traceDatabase, wxT(
"LoadSymbol: SelectOne (%s, %s) found in %s" ),
194 wxLogTrace(
traceDatabase, wxT(
"LoadSymbol: SelectOne (%s, %s) failed for table %s" ),
212 std::set<wxString> tableNames;
216 if( tableNames.count( tableIter.
name ) )
219 aNames.emplace_back( tableIter.
name );
220 tableNames.insert( tableIter.
name );
243 size_t signature = 0;
245 for(
const auto& [
table, results] : aTableResults )
249 size_t rowSignature = 0;
251 for(
const auto& [column, value] :
result )
255 if(
const std::string* str = std::any_cast<std::string>( &value ) )
263 if(
const std::string* str = std::any_cast<std::string>( &it->second ) )
266 symbolId.
Parse( *str );
273 if( std::optional<int> libHash =
m_adapter->GetLibraryModifyHash( nickname ) )
299 wxString::Format(
_(
"Symbol '%s' is in a database library and is not previewed." ),
311 wxString::Format(
_(
"Symbol '%s' was not found." ), aId.
Format().
wx_str() ),
320 bool aConnectNow,
const wxString& aBaseDir )
324 if(
source.connection_string.empty() )
326 return std::make_unique<DATABASE_CONNECTION>(
source.dsn,
source.username,
source.password,
327 source.timeout, aConnectNow );
330 std::string cs =
source.connection_string;
331 wxString baseDir = aBaseDir.IsEmpty() ? wxFileName( aSettings.
GetFilename() ).GetPath() : aBaseDir;
332 std::string basePath( baseDir.ToUTF8() );
336 boost::replace_all( cs,
"${CWD}", basePath );
338 return std::make_unique<DATABASE_CONNECTION>( cs,
source.timeout, aConnectNow );
345 auto it = aRow.find( aTable.
key_col );
347 if( it == aRow.end() )
348 return wxEmptyString;
350 std::string rawName = std::any_cast<std::string>( it->second );
352 std::string prefix = ( aGloballyUniqueKeys || aTable.
name.empty() ) ?
"" : fmt::format(
"{}/", aTable.
name );
357 return wxString( fmt::format(
"{}{}", prefix, sanitizedName.
c_str() ) );
361std::vector<std::unique_ptr<LIB_SYMBOL>>
363 bool aGloballyUniqueKeys,
const std::vector<DATABASE_CONNECTION::ROW>& aRows,
371 std::vector<std::unique_ptr<LIB_SYMBOL>> symbols;
372 std::map<wxString, std::pair<size_t, std::string>> listed;
390 if(
auto it = listed.find(
name ); it != listed.end() )
392 if( it->second.second == rawKey )
394 preview.
reportIssue( PREVIEW_ISSUE::FIELD::REPEATED_KEY,
395 wxString::Format(
_(
"Key '%s' appears in more than one row; only the last "
397 wxString::FromUTF8( rawKey ) ),
403 wxString::Format(
_(
"Keys '%s' and '%s' are both listed as '%s'; only the "
405 wxString::FromUTF8( it->second.second ),
406 wxString::FromUTF8( rawKey ),
name ),
410 symbols[it->second.first] = std::move( symbol );
411 it->second.second = rawKey;
415 listed[
name] = { symbols.size(), rawKey };
416 symbols.push_back( std::move( symbol ) );
433 Report( aMessage, aSeverity );
438 std::map<wxString, std::unique_ptr<LIB_SYMBOL>>& aSymbolCache,
439 std::map<wxString, std::pair<std::string, std::string>>& aSanitizedNameMap )
441 for(
const auto& [
table, results] : aTableResults )
451 aSanitizedNameMap[
name] = std::make_pair(
table->name, rawName );
456 aSymbolCache[symbol->GetName()] = std::move( symbol );
460 return !aSymbolCache.empty();
472 long long currentTimestampSeconds = wxDateTime::Now().GetValue().GetValue() / 1000;
484 struct CACHE_LIB_GUARD
487 ~CACHE_LIB_GUARD() { *
flag =
false; }
497 std::vector<DATABASE_CONNECTION::ROW> results;
501 if( !
m_conn->GetLastError().empty() )
507 tableResults.emplace_back( &
table, std::move( results ) );
522 std::map<wxString, std::unique_ptr<LIB_SYMBOL>> newSymbolCache;
523 std::map<wxString, std::pair<std::string, std::string>> newSanitizedNameMap;
549 wxLogTrace(
traceDatabase, wxT(
"Starting background refresh thread" ) );
566 BS::this_thread::set_os_thread_name(
"dblib bg" );
570 long long maxAge = 0;
586 wxLogTrace(
traceDatabase, wxT(
"Initiating background refresh" ) );
590 std::vector<std::pair<const DATABASE_LIB_TABLE*, std::vector<DATABASE_CONNECTION::ROW>>> tableResults;
591 bool querySuccess =
true;
597 std::vector<DATABASE_CONNECTION::ROW> results;
601 wxLogTrace(
traceDatabase, wxT(
"Background refresh: SelectAll failed for table %s" ),
603 querySuccess =
false;
607 tableResults.emplace_back( &
table, std::move( results ) );
614 bool dataChanged =
false;
629 std::map<wxString, std::unique_ptr<LIB_SYMBOL>> newSymbolCache;
630 std::map<wxString, std::pair<std::string, std::string>> newSanitizedNameMap;
634 wxLogTrace(
traceDatabase, wxT(
"Background refresh: new data" ) );
650 wxLogTrace(
traceDatabase, wxT(
"Background refresh: no new data" ) );
656 wxLogTrace(
traceDatabase, wxT(
"Background refresh failed: %s; cache preserved" ), e.
What() );
658 catch(
const std::exception& e )
660 wxLogTrace(
traceDatabase, wxT(
"Background refresh failed: %s; cache preserved" ), e.
what() );
666 m_refreshCV.wait_for( lock, std::chrono::seconds( maxAge ),
683 THROW_IO_ERRORF(
_(
"Could not load database library: settings file %s missing or invalid" ),
692 std::string
path( aSettingsPath.ToUTF8() );
705 wxASSERT_MSG( aSettingsPath ==
m_settings->GetFilename(),
706 "Path changed for database library without re-initializing plugin!" );
710 wxLogTrace(
traceDatabase, wxT(
"ensureSettings: no settings but no valid path!" ) );
717 wxCHECK_RET(
m_settings,
"Call ensureSettings before ensureConnection!" );
723 THROW_IO_ERRORF(
_(
"Could not load database library: could not connect to database %s (%s)" ),
731 wxCHECK_RET(
m_settings,
"Call ensureSettings before connect()!" );
744 if( !newConn->IsConnected() )
753 std::set<std::string> requiredColumns{ tableIter.
key_col,
758 requiredColumns.insert( field.
column );
761 requiredColumns.insert( tableIter.
pins_col );
771 newConn->CacheTableInfo( tableIter.
table, requiredColumns, optionalColumns );
777 m_conn = std::move( newConn );
786 bool val = std::any_cast<bool>( aVal );
789 catch(
const std::bad_any_cast& )
795 int val = std::any_cast<int>( aVal );
796 return static_cast<bool>( val );
798 catch(
const std::bad_any_cast& )
804 wxString strval( std::any_cast<std::string>( aVal ).c_str(), wxConvUTF8 );
806 if( strval.IsEmpty() )
811 for(
const auto& trueVal : { wxS(
"true" ), wxS(
"yes" ), wxS(
"y" ), wxS(
"1" ) } )
813 if( strval.Matches( trueVal ) )
817 for(
const auto& falseVal : { wxS(
"false" ), wxS(
"no" ), wxS(
"n" ), wxS(
"0" ) } )
819 if( strval.Matches( falseVal ) )
823 catch(
const std::bad_any_cast& )
835 std::unique_ptr<LIB_SYMBOL> symbol =
nullptr;
839 std::string symbols = std::any_cast<std::string>( aRow.at( aTable.
symbols_col ) );
840 wxString symbolsStr = wxString( symbols.c_str(), wxConvUTF8 );
841 wxStringTokenizer tokenizer( symbolsStr,
";\t\r\n", wxTOKEN_STRTOK );
843 std::vector<LIB_ID> symbolIds;
845 while( tokenizer.HasMoreTokens() )
847 wxString token = tokenizer.GetNextToken();
849 id.
Parse( std::string( token.ToUTF8() ) );
853 symbolIds.push_back(
id );
858 wxString::Format(
_(
"'%s' is not a symbol; expected Library:Symbol." ), token ),
867 std::vector<LIB_SYMBOL*> sourceSymbols;
868 std::vector<wxString> sourceSymbolNames;
870 for(
const LIB_ID& symbolId : symbolIds )
872 wxString symbolIdStr = symbolId.Format().wx_str();
876 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: cycle detected resolving '%s' "
877 "(row '%s' in table '%s'); skipping recursive load" ),
878 symbolIdStr, aSymbolName, aTable.
name );
884 std::unordered_set<wxString>* set;
886 ~CYCLE_GUARD() { set->erase( key ); }
898 sourceSymbols.push_back( src );
899 sourceSymbolNames.push_back( src->
GetName() );
903 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: source symbol '%s' not found" ), symbolIdStr );
907 if( sourceSymbols.empty() )
911 symbol.reset(
new LIB_SYMBOL( aSymbolName ) );
913 else if( sourceSymbols.size() == 1 )
915 symbol.reset( sourceSymbols[0]->Duplicate() );
916 symbol->SetSourceLibId( symbolIds[0] );
917 symbol->SetName( aSymbolName );
926 symbol.reset(
new LIB_SYMBOL( aSymbolName ) );
927 symbol->SetSourceLibId( symbolIds[0] );
929 symbol->SetUnitCount( sourceSymbols[0]->GetUnitCount(),
false );
930 symbol->SetPowerSymbolProp( sourceSymbols[0]->IsPower() );
931 symbol->SetShowPinNames( sourceSymbols[0]->GetShowPinNames() );
932 symbol->SetShowPinNumbers( sourceSymbols[0]->GetShowPinNumbers() );
933 symbol->SetPinNameOffset( sourceSymbols[0]->GetPinNameOffset() );
937 if(
SCH_FIELD* srcField = sourceSymbols[0]->GetField( fieldId ) )
939 SCH_FIELD* dstField = symbol->GetField( fieldId );
940 *dstField = *srcField;
945 std::vector<wxString> bodyStyleNames;
946 std::vector<int> sourceBodyStyleCounts;
947 std::vector<int> compositeBodyStyleBase;
949 int nextBodyStyle = 1;
951 for(
size_t i = 0; i < sourceSymbols.size(); ++i )
953 int srcCount = std::max( 1, sourceSymbols[i]->GetBodyStyleCount() );
954 sourceBodyStyleCounts.push_back( srcCount );
955 compositeBodyStyleBase.push_back( nextBodyStyle );
959 bodyStyleNames.push_back( sourceSymbolNames[i] );
963 for(
int style = 1; style <= srcCount; ++style )
965 wxString styleName = sourceSymbols[i]->GetBodyStyleDescription( style,
false );
966 bodyStyleNames.push_back( sourceSymbolNames[i] + wxT(
" (" ) + styleName + wxT(
")" ) );
970 nextBodyStyle += srcCount;
973 int totalBodyStyles = nextBodyStyle - 1;
975 symbol->SetHasDeMorganBodyStyles(
false );
976 symbol->SetBodyStyleNames( bodyStyleNames );
978 std::set<wxString> mergedFieldNames;
980 for(
size_t i = 0; i < sourceSymbols.size(); ++i )
982 std::unique_ptr<LIB_SYMBOL> srcSymbol = sourceSymbols[i]->Flatten();
983 int srcCount = sourceBodyStyleCounts[i];
984 int base = compositeBodyStyleBase[i];
986 for(
SCH_ITEM& item : srcSymbol->GetDrawItems() )
1000 targetStyle = base + ( item.GetBodyStyle() - 1 );
1002 if( targetStyle > totalBodyStyles )
1008 symbol->AddDrawItem( newItem,
false );
1012 for(
int bodyStyle = 0; bodyStyle < srcCount; ++bodyStyle )
1017 symbol->AddDrawItem( newItem,
false );
1022 int targetStyle = base + ( item.GetBodyStyle() - 1 );
1024 if( targetStyle > totalBodyStyles )
1030 symbol->AddDrawItem( newItem,
false );
1035 symbol->GetDrawItems().sort();
1040 symbol.reset(
new LIB_SYMBOL( aSymbolName ) );
1043 LIB_ID libId = symbol->GetLibId();
1045 symbol->SetLibId( libId );
1047 wxArrayString footprintsList;
1051 std::string footprints = std::any_cast<std::string>( aRow.at( aTable.
footprints_col ) );
1053 wxString footprintsStr = wxString( footprints.c_str(), wxConvUTF8 );
1054 wxStringTokenizer tokenizer( footprintsStr,
";\t\r\n", wxTOKEN_STRTOK );
1056 while( tokenizer.HasMoreTokens() )
1057 footprintsList.Add( tokenizer.GetNextToken() );
1059 if( footprintsList.size() > 0 )
1060 symbol->GetFootprintField().SetText( footprintsList[0] );
1074 std::string jsonStr = std::any_cast<std::string>( aRow.at( aTable.
pins_col ) );
1076 if( !jsonStr.empty() )
1078 nlohmann::json
json = nlohmann::json::parse( jsonStr );
1080 if(
json.is_object() &&
json.contains(
"pin_maps" ) )
1085 else if( !footprintsList.IsEmpty() )
1089 if( !assignments.empty() )
1091 const wxString mapName = wxS(
"Database" );
1093 symbol->PinMaps().AddOrReplace(
MakeLegacyPinMap( mapName, assignments ) );
1097 std::vector<ASSOCIATED_FOOTPRINT> associations;
1099 for(
const wxString& footprint : footprintsList )
1102 fpId.
Parse( footprint );
1103 associations.push_back( { fpId, mapName } );
1106 symbol->SetAssociatedFootprints( std::move( associations ) );
1111 catch(
const std::exception& e )
1116 wxString::Format(
_(
"Error parsing pin map for database symbol '%s': %s" ), aSymbolName,
1127 symbol->SetDescription( value );
1132 wxString value( std::any_cast<std::string>( aRow.at( aTable.
properties.
keywords ) ).c_str(),
1134 symbol->SetKeyWords( value );
1143 footprintsList.push_back( value );
1146 symbol->SetFPFilters( footprintsList );
1155 symbol->SetExcludedFromSim( *val );
1159 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: exclude_from_sim value for %s "
1160 "could not be cast to a boolean" ), aSymbolName );
1171 symbol->SetExcludedFromBoard( *val );
1175 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: exclude_from_board value for %s "
1176 "could not be cast to a boolean" ), aSymbolName );
1187 symbol->SetExcludedFromBOM( *val );
1191 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: exclude_from_bom value for %s "
1192 "could not be cast to a boolean" ), aSymbolName );
1196 std::vector<SCH_FIELD*> fields;
1197 symbol->GetFields( fields );
1199 std::unordered_map<wxString, SCH_FIELD*> fieldsMap;
1202 fieldsMap[field->GetName()] = field;
1204 static const wxString c_valueFieldName( wxS(
"Value" ) );
1205 static const wxString c_datasheetFieldName( wxS(
"Datasheet" ) );
1206 static const wxString c_footprintFieldName( wxS(
"Footprint" ) );
1212 int dbFieldOrdinal = symbol->GetNextFieldOrdinal();
1216 if( !aRow.count( mapping.
column ) )
1218 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: field %s not found in result" ), mapping.
column );
1231 strValue = std::any_cast<std::string>( aRow.at( mapping.
column ) );
1233 catch( std::bad_any_cast& )
1237 wxString value(
strValue.c_str(), wxConvUTF8 );
1239 if( mapping.
name_wx == c_valueFieldName )
1241 SCH_FIELD& field = symbol->GetValueField();
1252 else if( mapping.
name_wx == c_datasheetFieldName )
1254 SCH_FIELD& field = symbol->GetDatasheetField();
1272 if( fieldsMap.count( mapping.
name_wx ) )
1274 field = fieldsMap[mapping.
name_wx];
1281 fieldsMap[mapping.
name_wx] = field;
1301 symbol->AddDrawItem( field,
false );
1309 symbol->GetDrawItems().sort();
1314 symbol->RefreshLibraryTreeCaches();
std::map< std::string, std::any > ROW
Edits every setting of a .kicad_dbl file and previews the resulting symbols.
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
virtual void SetParent(EDA_ITEM *aParent)
virtual void SetVisible(bool aVisible)
virtual void Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) const
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()
virtual const char * what() const override
std::exception interface, returned as UTF-8
wxString GetFilename() const
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
bool IsValid() const
Check if this LID_ID is valid.
void SetSubLibraryName(const UTF8 &aName)
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib)
Replace illegal LIB_ID item name characters with underscores '_'.
Define a library symbol object.
bool IsPower() const override
virtual LIB_SYMBOL * Duplicate() const
Create a copy of a LIB_SYMBOL and assigns unique KIIDs to the copy and its children.
wxString GetName() const override
void SetOrdinal(int aOrdinal, FIELD_T aType)
void SetAutoAdded(bool aAutoAdded)
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetName(const wxString &aName)
void SetText(const wxString &aText) override
void SetNameShown(bool aShown=true)
void reportIssue(PREVIEW_ISSUE::FIELD aField, const wxString &aMessage, SEVERITY aSeverity) const
Reports to the preview's issue list when there is one, otherwise to the reporter.
static std::unique_ptr< DATABASE_CONNECTION > CreateConnection(const DATABASE_LIB_SETTINGS &aSettings, bool aConnectNow=true, const wxString &aBaseDir=wxEmptyString)
Opens a connection described by aSettings, expanding ${CWD} in a connection string to the directory h...
void EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
DIALOG_SHIM * CreateConfigurationDialog(wxWindow *aParent, const wxString &aLibraryPath) override
std::shared_mutex m_cacheMutex
PREVIEW_ISSUES * m_previewIssues
Collects the problems found while building a preview; null outside BuildPreviewSymbols()
std::unique_ptr< DATABASE_CONNECTION > m_conn
Generally will be null if no valid connection is established.
static wxString SymbolNameForRow(const DATABASE_LIB_TABLE &aTable, bool aGloballyUniqueKeys, const DATABASE_CONNECTION::ROW &aRow, std::string *aRawKey=nullptr)
void GetDefaultSymbolFields(std::vector< wxString > &aNames) override
Retrieves a list of (custom) field names that should be shown by default for this library in the symb...
void ensureSettings(const wxString &aSettingsPath)
static thread_local std::unordered_set< wxString > s_inProgressLoads
LIB_IDs whose resolution is in flight on the calling thread, used to break self-referential cycles wh...
void backgroundRefreshWorker()
static std::vector< std::unique_ptr< LIB_SYMBOL > > BuildPreviewSymbols(SYMBOL_LIBRARY_ADAPTER *aLibs, const DATABASE_LIB_TABLE &aTable, bool aGloballyUniqueKeys, const std::vector< DATABASE_CONNECTION::ROW > &aRows, PREVIEW_ISSUES *aIssues)
Builds symbols from already-fetched rows exactly as the library would name and load them,...
std::atomic< bool > m_cachePopulated
True once the LIB_SYMBOL cache has been materialized at least once.
void stopBackgroundRefresh()
bool m_inCacheLib
Re-entrancy guard for cacheLib(), tripped when a self-referential load routes back through the adapte...
std::map< wxString, std::unique_ptr< LIB_SYMBOL > > m_nameToSymbolcache
std::map< wxString, std::pair< std::string, std::string > > m_sanitizedNameMap
std::set< wxString > m_defaultShownFields
virtual ~SCH_IO_DATABASE()
size_t m_cacheSignature
Signature of the raw database rows at last materialization; used to skip rebuilding the LIB_SYMBOL ca...
std::vector< std::pair< const DATABASE_LIB_TABLE *, std::vector< DATABASE_CONNECTION::ROW > > > TABLE_RESULT_LIST
void GetSubLibraryNames(std::vector< wxString > &aNames) override
Retrieves a list of sub-libraries in this library.
std::unique_ptr< DATABASE_LIB_SETTINGS > m_settings
static std::optional< bool > boolFromAny(const std::any &aVal)
size_t computeSignature(const TABLE_RESULT_LIST &aTableResults) const
void CheckLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Validate that the library at aLibraryPath is reachable and well-formed, without necessarily loading s...
SYMBOL_LIBRARY_ADAPTER * m_adapter
void startBackgroundRefresh()
std::thread m_refreshThread
long long m_cacheTimestamp
std::condition_variable m_refreshCV
void GetAvailableSymbolFields(std::vector< wxString > &aNames) override
Retrieves a list of (custom) field names that are present on symbols in this library.
std::atomic< bool > m_refreshRunning
bool m_previewMode
Set on the throwaway instance behind BuildPreviewSymbols()
bool materializeCache(const TABLE_RESULT_LIST &aTableResults, std::map< wxString, std::unique_ptr< LIB_SYMBOL > > &aSymbolCache, std::map< wxString, std::pair< std::string, std::string > > &aSanitizedNameMap)
std::unique_ptr< LIB_SYMBOL > loadSymbolFromRow(const wxString &aSymbolName, const DATABASE_LIB_TABLE &aTable, const DATABASE_CONNECTION::ROW &aRow)
std::set< wxString > m_customFields
std::mutex m_symbolLoadMutex
LIB_SYMBOL * resolveSourceSymbol(const LIB_ID &aId)
Resolves one entry of a row's symbols column through the library adapter.
std::vector< PREVIEW_ISSUE > PREVIEW_ISSUES
LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aAliasName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
std::mutex m_refreshMutex
static SCH_FILE_T EnumFromStr(const wxString &aFileType)
Return the file type from the corresponding plugin type name: "kicad", "legacy", etc.
SCH_IO(const wxString &aName)
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_ITEM * Duplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr, bool aDoClone=false) const
Routine to create a new copy of given item.
virtual void SetBodyStyle(int aBodyStyle)
An interface to the global shared library manager that is schematic-specific and linked to one projec...
static const char * PropPowerSymsOnly
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
const char * c_str() const
const char *const traceDatabase
#define IGNORE_PARENT_GROUP
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
#define THROW_IO_ERRORF(msg,...)
static constexpr void hash_combine(std::size_t &seed)
This is a dummy function to take the final case of hash_combine below.
PIN_MAP MakeLegacyPinMap(const wxString &aName, const std::unordered_map< wxString, std::vector< wxString > > &aAssignments)
Build a single named PIN_MAP from a legacy symbol-pin to footprint-pad(s) assignment table (the flat ...
std::vector< ASSOCIATED_FOOTPRINT > ParseAssociatedFootprints(const nlohmann::json &aParent)
Parse the spec-form footprint associations from aParent["associated_footprints"] (issue #2282).
std::unordered_map< wxString, std::vector< wxString > > ParseLegacyPinAssignments(const nlohmann::json &aArray)
Parse the legacy flat pin-assignment JSON array (MR !2540 form) into a symbol-pin to footprint-pad(s)...
PIN_MAP_SET ParsePinMapSet(const nlohmann::json &aParent)
Parse the spec-form named maps from aParent["pin_maps"] into a PIN_MAP_SET (issue #2282).
static std::string strValue(double aValue)
bool visible_in_chooser
Whether the column is shown by default in the chooser.
std::string column
Database column name.
bool inherit_properties
Whether or not to inherit properties from symbol field.
bool visible_on_add
Whether to show the field when placing the symbol.
bool show_name
Whether or not to show the field name as well as its value.
wxString name_wx
KiCad field name (converted)
A database library table will be mapped to a sub-library provided by the database library entry in th...
std::string key_col
Unique key column name (will form part of the LIB_ID)
std::string name
KiCad library nickname (will form part of the LIB_ID)
std::string symbols_col
Column name containing KiCad symbol refs.
std::string footprints_col
Column name containing KiCad footprint refs.
std::vector< DATABASE_FIELD_MAPPING > fields
std::string table
Database table to pull content from.
MAPPABLE_SYMBOL_PROPERTIES properties
std::string pins_col
Column name containing JSON pin assignments (optional)
std::string footprint_filters
std::string exclude_from_sim
std::string exclude_from_board
std::string exclude_from_bom
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ USER
The field ID hasn't been set yet; field is invalid.
wxString result
Test unit parsing edge cases and error handling.