28#if defined( _MSC_VER ) && wxCHECK_VERSION( 3, 3, 0 )
29extern template class WXDLLIMPEXP_BASE std::vector<wxString>;
44 return e.m_PinNumber == aPinNumber;
54 return e.m_PinNumber == aPinNumber;
64 m_entries.push_back( { aPinNumber, aPadNumber } );
66 it->m_PadNumber = aPadNumber;
87 static const wxString
empty;
97 return std::all_of( aPinNumbers.begin(), aPinNumbers.end(),
98 [&](
const wxString&
pin )
100 auto it = findEntry( pin );
102 return it == m_entries.end() || it->m_PadNumber == pin;
116 *existing = std::move( aMap );
118 m_maps.push_back( std::move( aMap ) );
127 return m.GetName() == aName;
138 return m.GetName() == aName;
141 return it ==
m_maps.end() ? nullptr : &*it;
147 return const_cast<PIN_MAP*
>( std::as_const( *this ).FindByName( aName ) );
152 const std::unordered_map<wxString, std::vector<wxString>>& aAssignments )
156 for(
const auto& [pinNumber, pads] : aAssignments )
161 if( pads.size() == 1 )
163 map.
SetEntry( pinNumber, pads.front() );
167 wxString stacked = wxS(
"[" );
169 for(
size_t ii = 0; ii < pads.size(); ++ii )
172 stacked += wxS(
"," );
177 stacked += wxS(
"]" );
186std::unordered_map<wxString, std::vector<wxString>>
189 std::unordered_map<wxString, std::vector<wxString>> assignments;
191 if( !aArray.is_array() )
194 for(
const auto& entry : aArray )
196 if( !entry.contains(
"sym" ) || !entry.contains(
"fp" ) )
199 wxString symbolPin = wxString::FromUTF8( entry[
"sym"].get<std::string>() );
200 std::vector<wxString> pads;
201 const auto& fp = entry[
"fp"];
205 for(
const auto&
pad : fp )
206 pads.push_back( wxString::FromUTF8(
pad.get<std::string>() ) );
208 else if( fp.is_string() )
210 pads.push_back( wxString::FromUTF8( fp.get<std::string>() ) );
213 if( !symbolPin.empty() && !pads.empty() )
214 assignments[symbolPin] = std::move( pads );
225 if( !aParent.contains(
"pin_maps" ) || !aParent[
"pin_maps"].is_array() )
228 for(
const auto& mapJson : aParent[
"pin_maps"] )
230 if( !mapJson.contains(
"name" ) )
233 PIN_MAP map( wxString::FromUTF8( mapJson[
"name"].get<std::string>() ) );
235 if( mapJson.contains(
"entries" ) && mapJson[
"entries"].is_array() )
237 for(
const auto& entryJson : mapJson[
"entries"] )
239 if( entryJson.contains(
"pin" ) && entryJson.contains(
"pad" ) )
241 map.
SetEntry( wxString::FromUTF8( entryJson[
"pin"].get<std::string>() ),
242 wxString::FromUTF8( entryJson[
"pad"].get<std::string>() ) );
256 std::vector<ASSOCIATED_FOOTPRINT> associations;
258 if( !aParent.contains(
"associated_footprints" ) || !aParent[
"associated_footprints"].is_array() )
261 for(
const auto& assocJson : aParent[
"associated_footprints"] )
263 if( !assocJson.contains(
"footprint" ) )
269 if( assocJson.contains(
"map" ) )
270 assoc.
m_MapName = wxString::FromUTF8( assocJson[
"map"].get<std::string>() );
272 associations.push_back( std::move( assoc ) );
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
A symbol-owned ordered set of named pin maps.
void AddOrReplace(PIN_MAP aMap)
Insert aMap, replacing any existing entry with the same name.
void Remove(const wxString &aName)
Remove the map with the given name.
const PIN_MAP * FindByName(const wxString &aName) const
std::vector< PIN_MAP > m_maps
const wxString & GetPadNumber(const wxString &aPinNumber) const
bool operator==(const PIN_MAP &aOther) const
const wxString & GetName() const
bool HasEntry(const wxString &aPinNumber) const
void ClearEntry(const wxString &aPinNumber)
Remove the entry for aPinNumber.
std::vector< PIN_MAP_ENTRY > m_entries
bool IsIdentity(const std::vector< wxString > &aPinNumbers) const
void SetEntry(const wxString &aPinNumber, const wxString &aPadNumber)
Set the pad number for a symbol pin.
std::vector< PIN_MAP_ENTRY >::iterator findEntry(const wxString &aPinNumber)
static bool empty(const wxTextEntryBase *aCtrl)
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).
One symbol-pin to footprint-pad mapping inside a PIN_MAP.