26#include <bs_thread_pool.hpp>
27#include <wx/datetime.h>
29#include <wx/tokenzr.h>
31#include <boost/algorithm/string.hpp>
49 SCH_IO( wxS(
"Database library" ) ),
66 const wxString& aLibraryPath,
67 const std::map<std::string, UTF8>* aProperties )
69 std::vector<LIB_SYMBOL*> symbols;
74 aSymbolNameList.Add( symbol->GetName() );
81 const wxString& aLibraryPath,
82 const std::map<std::string, UTF8>* aProperties )
84 wxCHECK_RET(
m_adapter,
"Database plugin missing library manager adapter handle!" );
100 if( !powerSymbolsOnly || symbol->
IsPower() )
101 aSymbolList.emplace_back( symbol->
Duplicate() );
107 const std::map<std::string, UTF8>* aProperties )
115 const wxString& aAliasName,
116 const std::map<std::string, UTF8>* aProperties )
118 wxCHECK_MSG(
m_adapter,
nullptr,
"Database plugin missing library manager adapter handle!" );
127 std::string tableName;
128 std::string symbolName( aAliasName.ToUTF8() );
143 tableName = sanitizedIt->second.first;
144 symbolName = sanitizedIt->second.second;
157 if( tableName.empty() && aAliasName.Contains(
'/' ) )
159 tableName = std::string( aAliasName.BeforeFirst(
'/' ).ToUTF8() );
160 symbolName = std::string( aAliasName.AfterFirst(
'/' ).ToUTF8() );
163 std::vector<const DATABASE_LIB_TABLE*> tablesToTry;
168 if( tableName.empty() || tableIter.
name == tableName )
169 tablesToTry.emplace_back( &tableIter );
172 if( tablesToTry.empty() )
174 wxLogTrace(
traceDatabase, wxT(
"LoadSymbol: table '%s' not found in config" ), tableName );
186 wxLogTrace(
traceDatabase, wxT(
"LoadSymbol: SelectOne (%s, %s) found in %s" ),
191 wxLogTrace(
traceDatabase, wxT(
"LoadSymbol: SelectOne (%s, %s) failed for table %s" ),
209 std::set<wxString> tableNames;
213 if( tableNames.count( tableIter.
name ) )
216 aNames.emplace_back( tableIter.
name );
217 tableNames.insert( tableIter.
name );
245 if( aErrorMsg && ( !
m_conn || !
m_conn->IsConnected() ) )
254 size_t signature = 0;
256 for(
const auto& [
table, results] : aTableResults )
260 size_t rowSignature = 0;
262 for(
const auto& [column, value] :
result )
266 if(
const std::string* str = std::any_cast<std::string>( &value ) )
274 if(
const std::string* str = std::any_cast<std::string>( &it->second ) )
277 symbolId.
Parse( *str );
284 if( std::optional<int> libHash =
m_adapter->GetLibraryModifyHash( nickname ) )
297 std::map<wxString, std::unique_ptr<LIB_SYMBOL>>& aSymbolCache,
298 std::map<wxString, std::pair<std::string, std::string>>& aSanitizedNameMap )
300 for(
const auto& [
table, results] : aTableResults )
307 std::string rawName = std::any_cast<std::string>(
result.at(
table->key_col ) );
309 std::string sanitizedKey = sanitizedName.
c_str();
310 std::string prefix = (
m_settings->m_GloballyUniqueKeys ||
table->name.empty() )
312 : fmt::format(
"{}/",
table->name );
313 std::string sanitizedDisplayName = fmt::format(
"{}{}", prefix, sanitizedKey );
314 wxString
name( sanitizedDisplayName );
316 aSanitizedNameMap[
name] = std::make_pair(
table->name, rawName );
321 aSymbolCache[symbol->GetName()] = std::move( symbol );
325 return !aSymbolCache.empty();
337 long long currentTimestampSeconds = wxDateTime::Now().GetValue().GetValue() / 1000;
349 struct CACHE_LIB_GUARD
352 ~CACHE_LIB_GUARD() { *
flag =
false; }
362 std::vector<DATABASE_CONNECTION::ROW> results;
366 if( !
m_conn->GetLastError().empty() )
372 tableResults.emplace_back( &
table, std::move( results ) );
387 std::map<wxString, std::unique_ptr<LIB_SYMBOL>> newSymbolCache;
388 std::map<wxString, std::pair<std::string, std::string>> newSanitizedNameMap;
414 wxLogTrace(
traceDatabase, wxT(
"Starting background refresh thread" ) );
431 BS::this_thread::set_os_thread_name(
"dblib bg" );
435 long long maxAge = 0;
451 wxLogTrace(
traceDatabase, wxT(
"Initiating background refresh" ) );
455 std::vector<std::pair<const DATABASE_LIB_TABLE*, std::vector<DATABASE_CONNECTION::ROW>>> tableResults;
456 bool querySuccess =
true;
462 std::vector<DATABASE_CONNECTION::ROW> results;
466 wxLogTrace(
traceDatabase, wxT(
"Background refresh: SelectAll failed for table %s" ),
468 querySuccess =
false;
472 tableResults.emplace_back( &
table, std::move( results ) );
479 bool dataChanged =
false;
494 std::map<wxString, std::unique_ptr<LIB_SYMBOL>> newSymbolCache;
495 std::map<wxString, std::pair<std::string, std::string>> newSanitizedNameMap;
499 wxLogTrace(
traceDatabase, wxT(
"Background refresh: new data" ) );
515 wxLogTrace(
traceDatabase, wxT(
"Background refresh: no new data" ) );
521 wxLogTrace(
traceDatabase, wxT(
"Background refresh failed: %s; cache preserved" ), e.
What() );
523 catch(
const std::exception& e )
525 wxLogTrace(
traceDatabase, wxT(
"Background refresh failed: %s; cache preserved" ), e.
what() );
531 m_refreshCV.wait_for( lock, std::chrono::seconds( maxAge ),
548 THROW_IO_ERRORF(
_(
"Could not load database library: settings file %s missing or invalid" ),
555 std::string
path( aSettingsPath.ToUTF8() );
568 wxASSERT_MSG( aSettingsPath ==
m_settings->GetFilename(),
569 "Path changed for database library without re-initializing plugin!" );
573 wxLogTrace(
traceDatabase, wxT(
"ensureSettings: no settings but no valid path!" ) );
580 wxCHECK_RET(
m_settings,
"Call ensureSettings before ensureConnection!" );
586 THROW_IO_ERRORF(
_(
"Could not load database library: could not connect to database %s (%s)" ),
594 wxCHECK_RET(
m_settings,
"Call ensureSettings before connect()!" );
605 std::unique_ptr<DATABASE_CONNECTION> newConn;
607 if(
m_settings->m_Source.connection_string.empty() )
609 newConn = std::make_unique<DATABASE_CONNECTION>(
m_settings->m_Source.dsn,
616 std::string cs =
m_settings->m_Source.connection_string;
617 std::string basePath( wxFileName(
m_settings->GetFilename() ).GetPath().ToUTF8() );
621 boost::replace_all( cs,
"${CWD}", basePath );
623 newConn = std::make_unique<DATABASE_CONNECTION>( cs,
m_settings->m_Source.timeout );
626 if( !newConn->IsConnected() )
635 std::set<std::string> requiredColumns{ tableIter.
key_col,
640 requiredColumns.insert( field.
column );
643 requiredColumns.insert( tableIter.
pins_col );
653 newConn->CacheTableInfo( tableIter.
table, requiredColumns, optionalColumns );
659 m_conn = std::move( newConn );
668 bool val = std::any_cast<bool>( aVal );
671 catch(
const std::bad_any_cast& )
677 int val = std::any_cast<int>( aVal );
678 return static_cast<bool>( val );
680 catch(
const std::bad_any_cast& )
686 wxString strval( std::any_cast<std::string>( aVal ).c_str(), wxConvUTF8 );
688 if( strval.IsEmpty() )
693 for(
const auto& trueVal : { wxS(
"true" ), wxS(
"yes" ), wxS(
"y" ), wxS(
"1" ) } )
695 if( strval.Matches( trueVal ) )
699 for(
const auto& falseVal : { wxS(
"false" ), wxS(
"no" ), wxS(
"n" ), wxS(
"0" ) } )
701 if( strval.Matches( falseVal ) )
705 catch(
const std::bad_any_cast& )
717 std::unique_ptr<LIB_SYMBOL> symbol =
nullptr;
721 std::string symbols = std::any_cast<std::string>( aRow.at( aTable.
symbols_col ) );
722 wxString symbolsStr = wxString( symbols.c_str(), wxConvUTF8 );
723 wxStringTokenizer tokenizer( symbolsStr,
";\t\r\n", wxTOKEN_STRTOK );
725 std::vector<LIB_ID> symbolIds;
727 while( tokenizer.HasMoreTokens() )
729 wxString token = tokenizer.GetNextToken();
731 id.
Parse( std::string( token.ToUTF8() ) );
734 symbolIds.push_back(
id );
741 std::vector<LIB_SYMBOL*> sourceSymbols;
742 std::vector<wxString> sourceSymbolNames;
744 for(
const LIB_ID& symbolId : symbolIds )
746 wxString symbolIdStr = symbolId.Format().wx_str();
750 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: cycle detected resolving '%s' "
751 "(row '%s' in table '%s'); skipping recursive load" ),
752 symbolIdStr, aSymbolName, aTable.
name );
758 std::unordered_set<wxString>* set;
760 ~CYCLE_GUARD() { set->erase( key ); }
772 sourceSymbols.push_back( src );
773 sourceSymbolNames.push_back( src->
GetName() );
777 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: source symbol '%s' not found" ), symbolIdStr );
781 if( sourceSymbols.empty() )
785 symbol.reset(
new LIB_SYMBOL( aSymbolName ) );
787 else if( sourceSymbols.size() == 1 )
789 symbol.reset( sourceSymbols[0]->Duplicate() );
790 symbol->SetSourceLibId( symbolIds[0] );
791 symbol->SetName( aSymbolName );
800 symbol.reset(
new LIB_SYMBOL( aSymbolName ) );
801 symbol->SetSourceLibId( symbolIds[0] );
803 symbol->SetUnitCount( sourceSymbols[0]->GetUnitCount(),
false );
804 symbol->SetPowerSymbolProp( sourceSymbols[0]->IsPower() );
805 symbol->SetShowPinNames( sourceSymbols[0]->GetShowPinNames() );
806 symbol->SetShowPinNumbers( sourceSymbols[0]->GetShowPinNumbers() );
807 symbol->SetPinNameOffset( sourceSymbols[0]->GetPinNameOffset() );
811 if(
SCH_FIELD* srcField = sourceSymbols[0]->GetField( fieldId ) )
813 SCH_FIELD* dstField = symbol->GetField( fieldId );
814 *dstField = *srcField;
819 std::vector<wxString> bodyStyleNames;
820 std::vector<int> sourceBodyStyleCounts;
821 std::vector<int> compositeBodyStyleBase;
823 int nextBodyStyle = 1;
825 for(
size_t i = 0; i < sourceSymbols.size(); ++i )
827 int srcCount = std::max( 1, sourceSymbols[i]->GetBodyStyleCount() );
828 sourceBodyStyleCounts.push_back( srcCount );
829 compositeBodyStyleBase.push_back( nextBodyStyle );
833 bodyStyleNames.push_back( sourceSymbolNames[i] );
837 for(
int style = 1; style <= srcCount; ++style )
839 wxString styleName = sourceSymbols[i]->GetBodyStyleDescription( style,
false );
840 bodyStyleNames.push_back( sourceSymbolNames[i] + wxT(
" (" ) + styleName + wxT(
")" ) );
844 nextBodyStyle += srcCount;
847 int totalBodyStyles = nextBodyStyle - 1;
849 symbol->SetHasDeMorganBodyStyles(
false );
850 symbol->SetBodyStyleNames( bodyStyleNames );
852 std::set<wxString> mergedFieldNames;
854 for(
size_t i = 0; i < sourceSymbols.size(); ++i )
856 std::unique_ptr<LIB_SYMBOL> srcSymbol = sourceSymbols[i]->Flatten();
857 int srcCount = sourceBodyStyleCounts[i];
858 int base = compositeBodyStyleBase[i];
860 for(
SCH_ITEM& item : srcSymbol->GetDrawItems() )
871 if( item.GetBodyStyle() == 0 )
874 targetStyle = base + ( item.GetBodyStyle() - 1 );
876 if( targetStyle > totalBodyStyles )
882 symbol->AddDrawItem( newItem,
false );
884 else if( item.GetBodyStyle() == 0 )
886 for(
int bodyStyle = 0; bodyStyle < srcCount; ++bodyStyle )
891 symbol->AddDrawItem( newItem,
false );
896 int targetStyle = base + ( item.GetBodyStyle() - 1 );
898 if( targetStyle > totalBodyStyles )
904 symbol->AddDrawItem( newItem,
false );
909 symbol->GetDrawItems().sort();
914 symbol.reset(
new LIB_SYMBOL( aSymbolName ) );
917 LIB_ID libId = symbol->GetLibId();
919 symbol->SetLibId( libId );
921 wxArrayString footprintsList;
925 std::string footprints = std::any_cast<std::string>( aRow.at( aTable.
footprints_col ) );
927 wxString footprintsStr = wxString( footprints.c_str(), wxConvUTF8 );
928 wxStringTokenizer tokenizer( footprintsStr,
";\t\r\n", wxTOKEN_STRTOK );
930 while( tokenizer.HasMoreTokens() )
931 footprintsList.Add( tokenizer.GetNextToken() );
933 if( footprintsList.size() > 0 )
934 symbol->GetFootprintField().SetText( footprintsList[0] );
948 std::string jsonStr = std::any_cast<std::string>( aRow.at( aTable.
pins_col ) );
950 if( !jsonStr.empty() )
952 nlohmann::json
json = nlohmann::json::parse( jsonStr );
954 if(
json.is_object() &&
json.contains(
"pin_maps" ) )
959 else if( !footprintsList.IsEmpty() )
963 if( !assignments.empty() )
965 const wxString mapName = wxS(
"Database" );
971 std::vector<ASSOCIATED_FOOTPRINT> associations;
973 for(
const wxString& footprint : footprintsList )
976 fpId.
Parse( footprint );
977 associations.push_back( { fpId, mapName } );
980 symbol->SetAssociatedFootprints( std::move( associations ) );
985 catch(
const std::exception& e )
989 Report( wxString::Format(
_(
"Error parsing pin map for database symbol '%s': %s" ),
990 aSymbolName, e.what() ),
1000 symbol->SetDescription( value );
1005 wxString value( std::any_cast<std::string>( aRow.at( aTable.
properties.
keywords ) ).c_str(),
1007 symbol->SetKeyWords( value );
1016 footprintsList.push_back( value );
1019 symbol->SetFPFilters( footprintsList );
1028 symbol->SetExcludedFromSim( *val );
1032 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: exclude_from_sim value for %s "
1033 "could not be cast to a boolean" ), aSymbolName );
1044 symbol->SetExcludedFromBoard( *val );
1048 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: exclude_from_board value for %s "
1049 "could not be cast to a boolean" ), aSymbolName );
1060 symbol->SetExcludedFromBOM( *val );
1064 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: exclude_from_bom value for %s "
1065 "could not be cast to a boolean" ), aSymbolName );
1069 std::vector<SCH_FIELD*> fields;
1070 symbol->GetFields( fields );
1072 std::unordered_map<wxString, SCH_FIELD*> fieldsMap;
1075 fieldsMap[field->GetName()] = field;
1077 static const wxString c_valueFieldName( wxS(
"Value" ) );
1078 static const wxString c_datasheetFieldName( wxS(
"Datasheet" ) );
1079 static const wxString c_footprintFieldName( wxS(
"Footprint" ) );
1085 int dbFieldOrdinal = symbol->GetNextFieldOrdinal();
1089 if( !aRow.count( mapping.
column ) )
1091 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: field %s not found in result" ), mapping.
column );
1104 strValue = std::any_cast<std::string>( aRow.at( mapping.
column ) );
1106 catch( std::bad_any_cast& )
1110 wxString value(
strValue.c_str(), wxConvUTF8 );
1112 if( mapping.
name_wx == c_valueFieldName )
1114 SCH_FIELD& field = symbol->GetValueField();
1125 else if( mapping.
name_wx == c_datasheetFieldName )
1127 SCH_FIELD& field = symbol->GetDatasheetField();
1145 if( fieldsMap.count( mapping.
name_wx ) )
1147 field = fieldsMap[mapping.
name_wx];
1154 fieldsMap[mapping.
name_wx] = field;
1174 symbol->AddDrawItem( field,
false );
1182 symbol->GetDrawItems().sort();
1187 symbol->RefreshLibraryTreeCaches();
std::map< std::string, std::any > ROW
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
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 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.
std::shared_mutex m_cacheMutex
std::unordered_set< wxString > m_inProgressLoads
LIB_IDs whose resolution is in flight, used to break self-referential cycles where a row's Symbols co...
std::unique_ptr< DATABASE_CONNECTION > m_conn
Generally will be null if no valid connection is established.
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)
void backgroundRefreshWorker()
std::atomic< bool > m_cachePopulated
True once the LIB_SYMBOL cache has been materialized at least once.
bool TestConnection(wxString *aErrorMsg=nullptr)
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
DIALOG_SHIM * CreateConfigurationDialog(wxWindow *aParent) override
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 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 * 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
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 doClone=false) const
Routine to create a new copy of given item.
virtual void SetBodyStyle(int aBodyStyle)
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
static constexpr void hash_combine(std::size_t &seed)
This is a dummy function to take the final case of hash_combine below.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
#define THROW_IO_ERRORF(msg,...)
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.