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 );
248 if( aErrorMsg && ( !
m_conn || !
m_conn->IsConnected() ) )
257 size_t signature = 0;
259 for(
const auto& [
table, results] : aTableResults )
263 size_t rowSignature = 0;
265 for(
const auto& [column, value] :
result )
269 if(
const std::string* str = std::any_cast<std::string>( &value ) )
277 if(
const std::string* str = std::any_cast<std::string>( &it->second ) )
280 symbolId.
Parse( *str );
287 if( std::optional<int> libHash =
m_adapter->GetLibraryModifyHash( nickname ) )
300 std::map<wxString, std::unique_ptr<LIB_SYMBOL>>& aSymbolCache,
301 std::map<wxString, std::pair<std::string, std::string>>& aSanitizedNameMap )
303 for(
const auto& [
table, results] : aTableResults )
310 std::string rawName = std::any_cast<std::string>(
result.at(
table->key_col ) );
312 std::string sanitizedKey = sanitizedName.
c_str();
313 std::string prefix = (
m_settings->m_GloballyUniqueKeys ||
table->name.empty() )
315 : fmt::format(
"{}/",
table->name );
316 std::string sanitizedDisplayName = fmt::format(
"{}{}", prefix, sanitizedKey );
317 wxString
name( sanitizedDisplayName );
319 aSanitizedNameMap[
name] = std::make_pair(
table->name, rawName );
324 aSymbolCache[symbol->GetName()] = std::move( symbol );
328 return !aSymbolCache.empty();
340 long long currentTimestampSeconds = wxDateTime::Now().GetValue().GetValue() / 1000;
352 struct CACHE_LIB_GUARD
355 ~CACHE_LIB_GUARD() { *
flag =
false; }
365 std::vector<DATABASE_CONNECTION::ROW> results;
369 if( !
m_conn->GetLastError().empty() )
375 tableResults.emplace_back( &
table, std::move( results ) );
390 std::map<wxString, std::unique_ptr<LIB_SYMBOL>> newSymbolCache;
391 std::map<wxString, std::pair<std::string, std::string>> newSanitizedNameMap;
417 wxLogTrace(
traceDatabase, wxT(
"Starting background refresh thread" ) );
434 BS::this_thread::set_os_thread_name(
"dblib bg" );
438 long long maxAge = 0;
454 wxLogTrace(
traceDatabase, wxT(
"Initiating background refresh" ) );
458 std::vector<std::pair<const DATABASE_LIB_TABLE*, std::vector<DATABASE_CONNECTION::ROW>>> tableResults;
459 bool querySuccess =
true;
465 std::vector<DATABASE_CONNECTION::ROW> results;
469 wxLogTrace(
traceDatabase, wxT(
"Background refresh: SelectAll failed for table %s" ),
471 querySuccess =
false;
475 tableResults.emplace_back( &
table, std::move( results ) );
482 bool dataChanged =
false;
497 std::map<wxString, std::unique_ptr<LIB_SYMBOL>> newSymbolCache;
498 std::map<wxString, std::pair<std::string, std::string>> newSanitizedNameMap;
502 wxLogTrace(
traceDatabase, wxT(
"Background refresh: new data" ) );
518 wxLogTrace(
traceDatabase, wxT(
"Background refresh: no new data" ) );
524 wxLogTrace(
traceDatabase, wxT(
"Background refresh failed: %s; cache preserved" ), e.
What() );
526 catch(
const std::exception& e )
528 wxLogTrace(
traceDatabase, wxT(
"Background refresh failed: %s; cache preserved" ), e.
what() );
534 m_refreshCV.wait_for( lock, std::chrono::seconds( maxAge ),
551 THROW_IO_ERRORF(
_(
"Could not load database library: settings file %s missing or invalid" ),
558 std::string
path( aSettingsPath.ToUTF8() );
571 wxASSERT_MSG( aSettingsPath ==
m_settings->GetFilename(),
572 "Path changed for database library without re-initializing plugin!" );
576 wxLogTrace(
traceDatabase, wxT(
"ensureSettings: no settings but no valid path!" ) );
583 wxCHECK_RET(
m_settings,
"Call ensureSettings before ensureConnection!" );
589 THROW_IO_ERRORF(
_(
"Could not load database library: could not connect to database %s (%s)" ),
597 wxCHECK_RET(
m_settings,
"Call ensureSettings before connect()!" );
608 std::unique_ptr<DATABASE_CONNECTION> newConn;
610 if(
m_settings->m_Source.connection_string.empty() )
612 newConn = std::make_unique<DATABASE_CONNECTION>(
m_settings->m_Source.dsn,
619 std::string cs =
m_settings->m_Source.connection_string;
620 std::string basePath( wxFileName(
m_settings->GetFilename() ).GetPath().ToUTF8() );
624 boost::replace_all( cs,
"${CWD}", basePath );
626 newConn = std::make_unique<DATABASE_CONNECTION>( cs,
m_settings->m_Source.timeout );
629 if( !newConn->IsConnected() )
638 std::set<std::string> requiredColumns{ tableIter.
key_col,
643 requiredColumns.insert( field.
column );
646 requiredColumns.insert( tableIter.
pins_col );
656 newConn->CacheTableInfo( tableIter.
table, requiredColumns, optionalColumns );
662 m_conn = std::move( newConn );
671 bool val = std::any_cast<bool>( aVal );
674 catch(
const std::bad_any_cast& )
680 int val = std::any_cast<int>( aVal );
681 return static_cast<bool>( val );
683 catch(
const std::bad_any_cast& )
689 wxString strval( std::any_cast<std::string>( aVal ).c_str(), wxConvUTF8 );
691 if( strval.IsEmpty() )
696 for(
const auto& trueVal : { wxS(
"true" ), wxS(
"yes" ), wxS(
"y" ), wxS(
"1" ) } )
698 if( strval.Matches( trueVal ) )
702 for(
const auto& falseVal : { wxS(
"false" ), wxS(
"no" ), wxS(
"n" ), wxS(
"0" ) } )
704 if( strval.Matches( falseVal ) )
708 catch(
const std::bad_any_cast& )
720 std::unique_ptr<LIB_SYMBOL> symbol =
nullptr;
724 std::string symbols = std::any_cast<std::string>( aRow.at( aTable.
symbols_col ) );
725 wxString symbolsStr = wxString( symbols.c_str(), wxConvUTF8 );
726 wxStringTokenizer tokenizer( symbolsStr,
";\t\r\n", wxTOKEN_STRTOK );
728 std::vector<LIB_ID> symbolIds;
730 while( tokenizer.HasMoreTokens() )
732 wxString token = tokenizer.GetNextToken();
734 id.
Parse( std::string( token.ToUTF8() ) );
737 symbolIds.push_back(
id );
744 std::vector<LIB_SYMBOL*> sourceSymbols;
745 std::vector<wxString> sourceSymbolNames;
747 for(
const LIB_ID& symbolId : symbolIds )
749 wxString symbolIdStr = symbolId.Format().wx_str();
753 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: cycle detected resolving '%s' "
754 "(row '%s' in table '%s'); skipping recursive load" ),
755 symbolIdStr, aSymbolName, aTable.
name );
761 std::unordered_set<wxString>* set;
763 ~CYCLE_GUARD() { set->erase( key ); }
775 sourceSymbols.push_back( src );
776 sourceSymbolNames.push_back( src->
GetName() );
780 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: source symbol '%s' not found" ), symbolIdStr );
784 if( sourceSymbols.empty() )
788 symbol.reset(
new LIB_SYMBOL( aSymbolName ) );
790 else if( sourceSymbols.size() == 1 )
792 symbol.reset( sourceSymbols[0]->Duplicate() );
793 symbol->SetSourceLibId( symbolIds[0] );
794 symbol->SetName( aSymbolName );
803 symbol.reset(
new LIB_SYMBOL( aSymbolName ) );
804 symbol->SetSourceLibId( symbolIds[0] );
806 symbol->SetUnitCount( sourceSymbols[0]->GetUnitCount(),
false );
807 symbol->SetPowerSymbolProp( sourceSymbols[0]->IsPower() );
808 symbol->SetShowPinNames( sourceSymbols[0]->GetShowPinNames() );
809 symbol->SetShowPinNumbers( sourceSymbols[0]->GetShowPinNumbers() );
810 symbol->SetPinNameOffset( sourceSymbols[0]->GetPinNameOffset() );
814 if(
SCH_FIELD* srcField = sourceSymbols[0]->GetField( fieldId ) )
816 SCH_FIELD* dstField = symbol->GetField( fieldId );
817 *dstField = *srcField;
822 std::vector<wxString> bodyStyleNames;
823 std::vector<int> sourceBodyStyleCounts;
824 std::vector<int> compositeBodyStyleBase;
826 int nextBodyStyle = 1;
828 for(
size_t i = 0; i < sourceSymbols.size(); ++i )
830 int srcCount = std::max( 1, sourceSymbols[i]->GetBodyStyleCount() );
831 sourceBodyStyleCounts.push_back( srcCount );
832 compositeBodyStyleBase.push_back( nextBodyStyle );
836 bodyStyleNames.push_back( sourceSymbolNames[i] );
840 for(
int style = 1; style <= srcCount; ++style )
842 wxString styleName = sourceSymbols[i]->GetBodyStyleDescription( style,
false );
843 bodyStyleNames.push_back( sourceSymbolNames[i] + wxT(
" (" ) + styleName + wxT(
")" ) );
847 nextBodyStyle += srcCount;
850 int totalBodyStyles = nextBodyStyle - 1;
852 symbol->SetHasDeMorganBodyStyles(
false );
853 symbol->SetBodyStyleNames( bodyStyleNames );
855 std::set<wxString> mergedFieldNames;
857 for(
size_t i = 0; i < sourceSymbols.size(); ++i )
859 std::unique_ptr<LIB_SYMBOL> srcSymbol = sourceSymbols[i]->Flatten();
860 int srcCount = sourceBodyStyleCounts[i];
861 int base = compositeBodyStyleBase[i];
863 for(
SCH_ITEM& item : srcSymbol->GetDrawItems() )
877 targetStyle = base + ( item.GetBodyStyle() - 1 );
879 if( targetStyle > totalBodyStyles )
885 symbol->AddDrawItem( newItem,
false );
889 for(
int bodyStyle = 0; bodyStyle < srcCount; ++bodyStyle )
894 symbol->AddDrawItem( newItem,
false );
899 int targetStyle = base + ( item.GetBodyStyle() - 1 );
901 if( targetStyle > totalBodyStyles )
907 symbol->AddDrawItem( newItem,
false );
912 symbol->GetDrawItems().sort();
917 symbol.reset(
new LIB_SYMBOL( aSymbolName ) );
920 LIB_ID libId = symbol->GetLibId();
922 symbol->SetLibId( libId );
924 wxArrayString footprintsList;
928 std::string footprints = std::any_cast<std::string>( aRow.at( aTable.
footprints_col ) );
930 wxString footprintsStr = wxString( footprints.c_str(), wxConvUTF8 );
931 wxStringTokenizer tokenizer( footprintsStr,
";\t\r\n", wxTOKEN_STRTOK );
933 while( tokenizer.HasMoreTokens() )
934 footprintsList.Add( tokenizer.GetNextToken() );
936 if( footprintsList.size() > 0 )
937 symbol->GetFootprintField().SetText( footprintsList[0] );
951 std::string jsonStr = std::any_cast<std::string>( aRow.at( aTable.
pins_col ) );
953 if( !jsonStr.empty() )
955 nlohmann::json
json = nlohmann::json::parse( jsonStr );
957 if(
json.is_object() &&
json.contains(
"pin_maps" ) )
962 else if( !footprintsList.IsEmpty() )
966 if( !assignments.empty() )
968 const wxString mapName = wxS(
"Database" );
974 std::vector<ASSOCIATED_FOOTPRINT> associations;
976 for(
const wxString& footprint : footprintsList )
979 fpId.
Parse( footprint );
980 associations.push_back( { fpId, mapName } );
983 symbol->SetAssociatedFootprints( std::move( associations ) );
988 catch(
const std::exception& e )
992 Report( wxString::Format(
_(
"Error parsing pin map for database symbol '%s': %s" ),
993 aSymbolName, e.what() ),
1003 symbol->SetDescription( value );
1008 wxString value( std::any_cast<std::string>( aRow.at( aTable.
properties.
keywords ) ).c_str(),
1010 symbol->SetKeyWords( value );
1019 footprintsList.push_back( value );
1022 symbol->SetFPFilters( footprintsList );
1031 symbol->SetExcludedFromSim( *val );
1035 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: exclude_from_sim value for %s "
1036 "could not be cast to a boolean" ), aSymbolName );
1047 symbol->SetExcludedFromBoard( *val );
1051 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: exclude_from_board value for %s "
1052 "could not be cast to a boolean" ), aSymbolName );
1063 symbol->SetExcludedFromBOM( *val );
1067 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: exclude_from_bom value for %s "
1068 "could not be cast to a boolean" ), aSymbolName );
1072 std::vector<SCH_FIELD*> fields;
1073 symbol->GetFields( fields );
1075 std::unordered_map<wxString, SCH_FIELD*> fieldsMap;
1078 fieldsMap[field->GetName()] = field;
1080 static const wxString c_valueFieldName( wxS(
"Value" ) );
1081 static const wxString c_datasheetFieldName( wxS(
"Datasheet" ) );
1082 static const wxString c_footprintFieldName( wxS(
"Footprint" ) );
1088 int dbFieldOrdinal = symbol->GetNextFieldOrdinal();
1092 if( !aRow.count( mapping.
column ) )
1094 wxLogTrace(
traceDatabase, wxT(
"loadSymbolFromRow: field %s not found in result" ), mapping.
column );
1107 strValue = std::any_cast<std::string>( aRow.at( mapping.
column ) );
1109 catch( std::bad_any_cast& )
1113 wxString value(
strValue.c_str(), wxConvUTF8 );
1115 if( mapping.
name_wx == c_valueFieldName )
1117 SCH_FIELD& field = symbol->GetValueField();
1128 else if( mapping.
name_wx == c_datasheetFieldName )
1130 SCH_FIELD& field = symbol->GetDatasheetField();
1148 if( fieldsMap.count( mapping.
name_wx ) )
1150 field = fieldsMap[mapping.
name_wx];
1157 fieldsMap[mapping.
name_wx] = field;
1177 symbol->AddDrawItem( field,
false );
1185 symbol->GetDrawItems().sort();
1190 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::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)
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()
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 aDoClone=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
#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.