KiCad PCB EDA Suite
Loading...
Searching...
No Matches
template_fieldnames.h File Reference
#include <initializer_list>
#include <wx/string.h>

Go to the source code of this file.

Classes

struct  TEMPLATE_FIELDNAME
 Hold a name of a symbol's field, field value, and default visibility. More...
 
class  TEMPLATES
 

Macros

#define MANDATORY_FIELDS
 
#define GLOBALLABEL_MANDATORY_FIELDS   { FIELD_T::INTERSHEET_REFS }
 
#define SHEET_MANDATORY_FIELDS
 
#define DO_TRANSLATE   true
 

Enumerations

enum class  FIELD_T : int {
  USER , REFERENCE , VALUE , FOOTPRINT ,
  DATASHEET , DESCRIPTION , INTERSHEET_REFS , SHEET_NAME ,
  SHEET_FILENAME , SHEET_USER
}
 The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hold. More...
 

Functions

wxString GetDefaultFieldName (FIELD_T aFieldId, bool aTranslateForHI)
 Return a default symbol field name for a mandatory field type.
 
wxString GetUserFieldName (int aFieldNdx, bool aTranslateForHI)
 
wxString GetCanonicalFieldName (FIELD_T aFieldType)
 
bool FieldNamesAreDuplicates (const wxString &aLhs, const wxString &aRhs, std::initializer_list< FIELD_T > aMandatoryFields)
 Test whether two field names should be treated as duplicates for the purposes of field name uniqueness within a given parent (symbol, sheet, or global label).
 
bool FieldNamesAreDuplicates (const wxString &aLhs, const wxString &aRhs)
 Convenience overload defaulting to symbol mandatory fields.
 

Macro Definition Documentation

◆ DO_TRANSLATE

◆ GLOBALLABEL_MANDATORY_FIELDS

◆ MANDATORY_FIELDS

◆ SHEET_MANDATORY_FIELDS

Enumeration Type Documentation

◆ FIELD_T

enum class FIELD_T : int
strong

The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hold.

The first fields are fixed fields and are defined by MANDATORY_FIELDS. After that come an unlimited number of user defined fields, only some of which have indices defined here.

NOTE: this must stay a enum class to prevent developers from trying to use it as an array index.

Enumerator
USER 

The field ID hasn't been set yet; field is invalid.

REFERENCE 

Field Reference of part, i.e. "IC21".

VALUE 

Field Value of part, i.e. "3.3K".

FOOTPRINT 

Field Name Module PCB, i.e. "16DIP300".

DATASHEET 

name of datasheet

DESCRIPTION 

Field Description of part, i.e. "1/4W 1% Metal Film Resistor".

INTERSHEET_REFS 

Global label cross-reference page numbers.

SHEET_NAME 
SHEET_FILENAME 
SHEET_USER 

Definition at line 41 of file template_fieldnames.h.

Function Documentation

◆ FieldNamesAreDuplicates() [1/2]

bool FieldNamesAreDuplicates ( const wxString & aLhs,
const wxString & aRhs )

Convenience overload defaulting to symbol mandatory fields.

Definition at line 118 of file template_fieldnames.cpp.

References FieldNamesAreDuplicates(), and MANDATORY_FIELDS.

◆ FieldNamesAreDuplicates() [2/2]

bool FieldNamesAreDuplicates ( const wxString & aLhs,
const wxString & aRhs,
std::initializer_list< FIELD_T > aMandatoryFields )

Test whether two field names should be treated as duplicates for the purposes of field name uniqueness within a given parent (symbol, sheet, or global label).

Mandatory field names in the supplied set are matched case-insensitively because the s-expression parser folds case variants onto the canonical mandatory field on load. User-defined field names retain their original case in storage, so two user fields that differ only in case (e.g. "Manufacturer" vs "MANUFACTURER") are considered distinct.

Pass MANDATORY_FIELDS for symbol contexts, SHEET_MANDATORY_FIELDS for sheets, or GLOBALLABEL_MANDATORY_FIELDS for global labels. Each parent has its own canonical folding domain in the parser.

Definition at line 95 of file template_fieldnames.cpp.

References GetCanonicalFieldName().

Referenced by DIALOG_LIB_FIELDS_TABLE::AddField(), DIALOG_SYMBOL_FIELDS_TABLE::AddField(), 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(), FieldNamesAreDuplicates(), FIELDS_EDITOR_GRID_DATA_MODEL::GetFieldNameCol(), LIB_FIELDS_EDITOR_GRID_DATA_MODEL::GetFieldNameCol(), DIALOG_LIB_FIELDS_TABLE::OnAddField(), DIALOG_SYMBOL_FIELDS_TABLE::OnAddField(), DIALOG_LABEL_PROPERTIES::OnGridCellChanging(), DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging(), DIALOG_SHEET_PROPERTIES::OnGridCellChanging(), and DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging().

◆ GetCanonicalFieldName()

wxString GetCanonicalFieldName ( FIELD_T aFieldType)
inline

Definition at line 83 of file template_fieldnames.h.

References DO_TRANSLATE, and GetDefaultFieldName().

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), TEMPLATES::AddTemplateFieldName(), FIELDS_EDITOR_GRID_DATA_MODEL::ApplyBomPreset(), BACK_ANNOTATE::applyChangelist(), BOARD_NETLIST_UPDATER::applyComponentVariants(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), FIELDS_EDITOR_GRID_DATA_MODEL::ColIsReference(), FIELDS_EDITOR_GRID_DATA_MODEL::ColIsValue(), PCB_PROPERTIES_PANEL::createPGProperty(), SCH_PROPERTIES_PANEL::createPGProperty(), PLACEFILE_GERBER_WRITER::CreatePlaceFile(), FieldNamesAreDuplicates(), PLACE_FILE_EXPORTER::GenPositionData(), PLACE_FILE_EXPORTER::GenReportData(), FIELDS_EDITOR_GRID_DATA_MODEL::GetAttr(), SCH_FIELD::GetCanonicalName(), FOOTPRINT::GetMsgPanelInfo(), PCB_FIELD::GetName(), SCH_FIELD::GetName(), PCB_FIELD::GetTextTypeDescription(), FIELDS_EDITOR_GRID_DATA_MODEL::groupMatch(), SCH_SYMBOL::Init(), EESCHEMA_JOBS_HANDLER::JobExportBom(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField(), DIALOG_SYMBOL_FIELDS_TABLE::LoadFieldNames(), SCH_IO_EAGLE::loadInstance(), SCH_IO_KICAD_LEGACY::loadSymbol(), DIALOG_CHANGE_SYMBOLS::onOkButtonClicked(), DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked(), SCH_IO_KICAD_SEXPR_PARSER::parseProperty(), SCH_IO_KICAD_SEXPR_PARSER::parseSchField(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveField(), DIALOG_LIB_FIELDS_TABLE::SetupColumnProperties(), DIALOG_SYMBOL_FIELDS_TABLE::SetupColumnProperties(), FIELDS_EDITOR_GRID_TRICKS::showPopupMenu(), LIB_FIELDS_EDITOR_GRID_TRICKS::showPopupMenu(), DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist(), DIALOG_LIB_FIELDS_TABLE::UpdateFieldList(), BOARD_NETLIST_UPDATER::updateFootprintParameters(), and BOARD_NETLIST_UPDATER::UpdateNetlist().

◆ GetDefaultFieldName()

◆ GetUserFieldName()