KiCad PCB EDA Suite
Loading...
Searching...
No Matches
template_fieldnames.cpp File Reference
#include "template_fieldnames.h"
#include <mutex>
#include <template_fieldnames_lexer.h>
#include <string_utils.h>

Go to the source code of this file.

Macros

#define REFERENCE_CANONICAL   "Reference"
 
#define VALUE_CANONICAL   "Value"
 
#define FOOTPRINT_CANONICAL   "Footprint"
 
#define DATASHEET_CANONICAL   "Datasheet"
 
#define DESCRIPTION_CANONICAL   "Description"
 
#define SHEET_NAME_CANONICAL   "Sheetname"
 
#define SHEET_FILE_CANONICAL   "Sheetfile"
 
#define INTERSHEET_REFS_CANONICAL   "Intersheetrefs"
 
#define USER_FIELD_CANONICAL   "Field%d"
 

Functions

static wxString s_CanonicalReference (REFERENCE_CANONICAL)
 
static wxString s_CanonicalValue (VALUE_CANONICAL)
 
static wxString s_CanonicalFootprint (FOOTPRINT_CANONICAL)
 
static wxString s_CanonicalDatasheet (DATASHEET_CANONICAL)
 
static wxString s_CanonicalDescription (DESCRIPTION_CANONICAL)
 
static wxString s_CanonicalSheetName (SHEET_NAME_CANONICAL)
 
static wxString s_CanonicalSheetFile (SHEET_FILE_CANONICAL)
 
static wxString s_CanonicalIntersheetRefs (INTERSHEET_REFS_CANONICAL)
 
wxString GetDefaultFieldName (FIELD_T aFieldId, bool aTranslateForHI)
 Return a default symbol field name for a mandatory field type.
 
wxString GetUserFieldName (int aFieldNdx, bool aTranslateForHI)
 
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

◆ DATASHEET_CANONICAL

#define DATASHEET_CANONICAL   "Datasheet"

Definition at line 34 of file template_fieldnames.cpp.

Referenced by GetDefaultFieldName(), and s_CanonicalDatasheet().

◆ DESCRIPTION_CANONICAL

#define DESCRIPTION_CANONICAL   "Description"

Definition at line 35 of file template_fieldnames.cpp.

Referenced by GetDefaultFieldName(), and s_CanonicalDescription().

◆ FOOTPRINT_CANONICAL

#define FOOTPRINT_CANONICAL   "Footprint"

Definition at line 33 of file template_fieldnames.cpp.

Referenced by GetDefaultFieldName(), and s_CanonicalFootprint().

◆ INTERSHEET_REFS_CANONICAL

#define INTERSHEET_REFS_CANONICAL   "Intersheetrefs"

Definition at line 38 of file template_fieldnames.cpp.

Referenced by GetDefaultFieldName(), and s_CanonicalIntersheetRefs().

◆ REFERENCE_CANONICAL

#define REFERENCE_CANONICAL   "Reference"

Definition at line 31 of file template_fieldnames.cpp.

Referenced by GetDefaultFieldName(), and s_CanonicalReference().

◆ SHEET_FILE_CANONICAL

#define SHEET_FILE_CANONICAL   "Sheetfile"

Definition at line 37 of file template_fieldnames.cpp.

Referenced by GetDefaultFieldName(), and s_CanonicalSheetFile().

◆ SHEET_NAME_CANONICAL

#define SHEET_NAME_CANONICAL   "Sheetname"

Definition at line 36 of file template_fieldnames.cpp.

Referenced by GetDefaultFieldName(), and s_CanonicalSheetName().

◆ USER_FIELD_CANONICAL

#define USER_FIELD_CANONICAL   "Field%d"

Definition at line 39 of file template_fieldnames.cpp.

Referenced by GetUserFieldName().

◆ VALUE_CANONICAL

#define VALUE_CANONICAL   "Value"

Definition at line 32 of file template_fieldnames.cpp.

Referenced by GetDefaultFieldName(), and s_CanonicalValue().

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().

◆ GetDefaultFieldName()

◆ GetUserFieldName()

◆ s_CanonicalDatasheet()

static wxString s_CanonicalDatasheet ( DATASHEET_CANONICAL )
static

References DATASHEET_CANONICAL.

Referenced by GetDefaultFieldName().

◆ s_CanonicalDescription()

static wxString s_CanonicalDescription ( DESCRIPTION_CANONICAL )
static

References DESCRIPTION_CANONICAL.

Referenced by GetDefaultFieldName().

◆ s_CanonicalFootprint()

static wxString s_CanonicalFootprint ( FOOTPRINT_CANONICAL )
static

References FOOTPRINT_CANONICAL.

Referenced by GetDefaultFieldName().

◆ s_CanonicalIntersheetRefs()

static wxString s_CanonicalIntersheetRefs ( INTERSHEET_REFS_CANONICAL )
static

◆ s_CanonicalReference()

static wxString s_CanonicalReference ( REFERENCE_CANONICAL )
static

References REFERENCE_CANONICAL.

Referenced by GetDefaultFieldName().

◆ s_CanonicalSheetFile()

static wxString s_CanonicalSheetFile ( SHEET_FILE_CANONICAL )
static

References SHEET_FILE_CANONICAL.

Referenced by GetDefaultFieldName().

◆ s_CanonicalSheetName()

static wxString s_CanonicalSheetName ( SHEET_NAME_CANONICAL )
static

References SHEET_NAME_CANONICAL.

Referenced by GetDefaultFieldName().

◆ s_CanonicalValue()

static wxString s_CanonicalValue ( VALUE_CANONICAL )
static

References VALUE_CANONICAL.

Referenced by GetDefaultFieldName().