KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PADS_ATTRIBUTE_MAPPER Class Reference

Maps PADS attribute names to KiCad field names. More...

#include <pads_attribute_mapper.h>

Public Member Functions

 PADS_ATTRIBUTE_MAPPER ()
 
std::string GetKiCadFieldName (const std::string &aPadsAttr) const
 Get the KiCad field name for a PADS attribute.
 
bool IsStandardField (const std::string &aPadsAttr) const
 Check if a PADS attribute maps to a standard KiCad field.
 
bool IsReferenceField (const std::string &aPadsAttr) const
 Check if a PADS attribute maps to the Reference field.
 
bool IsValueField (const std::string &aPadsAttr) const
 Check if a PADS attribute maps to the Value field.
 
bool IsFootprintField (const std::string &aPadsAttr) const
 Check if a PADS attribute maps to the Footprint field.
 
void AddMapping (const std::string &aPadsAttr, const std::string &aKiCadField)
 Add or override a custom attribute mapping.
 
const std::map< std::string, std::string > & GetMappings () const
 Get all custom mappings.
 

Static Public Attributes

static constexpr const char * FIELD_REFERENCE = "Reference"
 
static constexpr const char * FIELD_VALUE = "Value"
 
static constexpr const char * FIELD_FOOTPRINT = "Footprint"
 
static constexpr const char * FIELD_DATASHEET = "Datasheet"
 
static constexpr const char * FIELD_MPN = "MPN"
 
static constexpr const char * FIELD_MANUFACTURER = "Manufacturer"
 

Private Member Functions

std::string normalizeAttrName (const std::string &aName) const
 

Private Attributes

std::map< std::string, std::string > m_standardMappings
 
std::map< std::string, std::string > m_customMappings
 

Detailed Description

Maps PADS attribute names to KiCad field names.

PADS uses different attribute names than KiCad for standard fields. This class provides mapping from PADS names to KiCad-compatible names, and identifies which attributes correspond to standard KiCad fields (Reference, Value, Footprint) versus custom user fields.

Definition at line 34 of file pads_attribute_mapper.h.

Constructor & Destructor Documentation

◆ PADS_ATTRIBUTE_MAPPER()

PADS_ATTRIBUTE_MAPPER::PADS_ATTRIBUTE_MAPPER ( )

Member Function Documentation

◆ AddMapping()

void PADS_ATTRIBUTE_MAPPER::AddMapping ( const std::string & aPadsAttr,
const std::string & aKiCadField )

Add or override a custom attribute mapping.

Parameters
aPadsAttrThe PADS attribute name.
aKiCadFieldThe KiCad field name to map to.

Definition at line 135 of file pads_attribute_mapper.cpp.

References m_customMappings, and normalizeAttrName().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ GetKiCadFieldName()

std::string PADS_ATTRIBUTE_MAPPER::GetKiCadFieldName ( const std::string & aPadsAttr) const

Get the KiCad field name for a PADS attribute.

For known PADS attributes (like "Ref.Des.", "Part Type"), returns the corresponding KiCad field name. For unknown attributes, returns the original name unchanged.

Parameters
aPadsAttrThe PADS attribute name.
Returns
The corresponding KiCad field name.

Definition at line 87 of file pads_attribute_mapper.cpp.

References m_customMappings, m_standardMappings, and normalizeAttrName().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateCustomFields(), IsFootprintField(), IsReferenceField(), and IsValueField().

◆ GetMappings()

const std::map< std::string, std::string > & PADS_ATTRIBUTE_MAPPER::GetMappings ( ) const
inline

Get all custom mappings.

Returns
Map of PADS attribute names to KiCad field names.

Definition at line 99 of file pads_attribute_mapper.h.

References m_customMappings.

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ IsFootprintField()

bool PADS_ATTRIBUTE_MAPPER::IsFootprintField ( const std::string & aPadsAttr) const

Check if a PADS attribute maps to the Footprint field.

Parameters
aPadsAttrThe PADS attribute name.
Returns
True if this maps to the Footprint field.

Definition at line 128 of file pads_attribute_mapper.cpp.

References FIELD_FOOTPRINT, and GetKiCadFieldName().

Referenced by PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::ApplyFieldSettings(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and IsStandardField().

◆ IsReferenceField()

bool PADS_ATTRIBUTE_MAPPER::IsReferenceField ( const std::string & aPadsAttr) const

Check if a PADS attribute maps to the Reference field.

Parameters
aPadsAttrThe PADS attribute name.
Returns
True if this maps to the Reference field.

Definition at line 114 of file pads_attribute_mapper.cpp.

References FIELD_REFERENCE, and GetKiCadFieldName().

Referenced by PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::ApplyFieldSettings(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and IsStandardField().

◆ IsStandardField()

bool PADS_ATTRIBUTE_MAPPER::IsStandardField ( const std::string & aPadsAttr) const

Check if a PADS attribute maps to a standard KiCad field.

Standard fields are Reference, Value, and Footprint. These are handled specially in KiCad and exist on every footprint.

Parameters
aPadsAttrThe PADS attribute name.
Returns
True if this is a standard field (Reference, Value, Footprint).

Definition at line 108 of file pads_attribute_mapper.cpp.

References IsFootprintField(), IsReferenceField(), and IsValueField().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::CreateCustomFields().

◆ IsValueField()

bool PADS_ATTRIBUTE_MAPPER::IsValueField ( const std::string & aPadsAttr) const

Check if a PADS attribute maps to the Value field.

Parameters
aPadsAttrThe PADS attribute name.
Returns
True if this maps to the Value field.

Definition at line 121 of file pads_attribute_mapper.cpp.

References FIELD_VALUE, and GetKiCadFieldName().

Referenced by PADS_SCH::PADS_SCH_SCHEMATIC_BUILDER::ApplyFieldSettings(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and IsStandardField().

◆ normalizeAttrName()

std::string PADS_ATTRIBUTE_MAPPER::normalizeAttrName ( const std::string & aName) const
private

Definition at line 73 of file pads_attribute_mapper.cpp.

Referenced by AddMapping(), and GetKiCadFieldName().

Member Data Documentation

◆ FIELD_DATASHEET

const char* PADS_ATTRIBUTE_MAPPER::FIELD_DATASHEET = "Datasheet"
staticconstexpr

◆ FIELD_FOOTPRINT

const char* PADS_ATTRIBUTE_MAPPER::FIELD_FOOTPRINT = "Footprint"
staticconstexpr

◆ FIELD_MANUFACTURER

const char* PADS_ATTRIBUTE_MAPPER::FIELD_MANUFACTURER = "Manufacturer"
staticconstexpr

◆ FIELD_MPN

const char* PADS_ATTRIBUTE_MAPPER::FIELD_MPN = "MPN"
staticconstexpr

◆ FIELD_REFERENCE

const char* PADS_ATTRIBUTE_MAPPER::FIELD_REFERENCE = "Reference"
staticconstexpr

◆ FIELD_VALUE

const char* PADS_ATTRIBUTE_MAPPER::FIELD_VALUE = "Value"
staticconstexpr

◆ m_customMappings

std::map<std::string, std::string> PADS_ATTRIBUTE_MAPPER::m_customMappings
private

Definition at line 113 of file pads_attribute_mapper.h.

Referenced by AddMapping(), GetKiCadFieldName(), and GetMappings().

◆ m_standardMappings

std::map<std::string, std::string> PADS_ATTRIBUTE_MAPPER::m_standardMappings
private

Definition at line 112 of file pads_attribute_mapper.h.

Referenced by GetKiCadFieldName(), and PADS_ATTRIBUTE_MAPPER().


The documentation for this class was generated from the following files: