KiCad PCB EDA Suite
TEMPLATE_FIELDNAME Struct Reference

Hold a name of a symbol's field, field value, and default visibility. More...

#include <template_fieldnames.h>

Public Member Functions

 TEMPLATE_FIELDNAME ()
 
 TEMPLATE_FIELDNAME (const wxString &aName)
 
 TEMPLATE_FIELDNAME (const TEMPLATE_FIELDNAME &ref)
 
void Format (OUTPUTFORMATTER *out, int nestLevel) const
 Serialize this object out as text into the given OUTPUTFORMATTER. More...
 
void Parse (TEMPLATE_FIELDNAMES_LEXER *aSpec)
 Fill this object from information in the input stream aSpec, which is a #TEMPLATE_FIELDNAMES_LEXER. More...
 

Static Public Member Functions

static const wxString GetDefaultFieldName (int aFieldNdx, bool aTranslateForHI=false)
 Return a default symbol field name for field aFieldNdx for all components. More...
 

Public Attributes

wxString m_Name
 
bool m_Visible
 
bool m_URL
 

Detailed Description

Hold a name of a symbol's field, field value, and default visibility.

Template fieldnames are wanted field names for use in the symbol property editors.

Definition at line 62 of file template_fieldnames.h.

Constructor & Destructor Documentation

◆ TEMPLATE_FIELDNAME() [1/3]

TEMPLATE_FIELDNAME::TEMPLATE_FIELDNAME ( )
inline

Definition at line 64 of file template_fieldnames.h.

64 :
65 m_Visible( false ),
66 m_URL( false )
67 {
68 }

◆ TEMPLATE_FIELDNAME() [2/3]

TEMPLATE_FIELDNAME::TEMPLATE_FIELDNAME ( const wxString &  aName)
inline

Definition at line 70 of file template_fieldnames.h.

70 :
71 m_Name( aName ),
72 m_Visible( false ),
73 m_URL( false )
74 {
75 }

◆ TEMPLATE_FIELDNAME() [3/3]

TEMPLATE_FIELDNAME::TEMPLATE_FIELDNAME ( const TEMPLATE_FIELDNAME ref)
inline

Definition at line 77 of file template_fieldnames.h.

78 {
79 m_Name = ref.m_Name;
80 m_Visible = ref.m_Visible;
81 m_URL = ref.m_URL;
82 }

References m_Name, m_URL, and m_Visible.

Member Function Documentation

◆ Format()

void TEMPLATE_FIELDNAME::Format ( OUTPUTFORMATTER out,
int  nestLevel 
) const

Serialize this object out as text into the given OUTPUTFORMATTER.

Definition at line 64 of file template_fieldnames.cpp.

65{
66 out->Print( nestLevel, "(field (name %s)", out->Quotew( m_Name ).c_str() );
67
68 if( m_Visible )
69 out->Print( 0, " visible" );
70
71 if( m_URL )
72 out->Print( 0, " url" );
73
74 out->Print( 0, ")\n" );
75}
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:501
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:433

References m_Name, m_URL, m_Visible, OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

◆ GetDefaultFieldName()

const wxString TEMPLATE_FIELDNAME::GetDefaultFieldName ( int  aFieldNdx,
bool  aTranslateForHI = false 
)
static

Return a default symbol field name for field aFieldNdx for all components.

These field names are not modifiable but template field names are.

Parameters
aFieldNdxThe field number index, > 0.
aTranslateForHIIf true, return the translated field name, else get the canonical name (defualt). Translation is intended only for dialogs

Definition at line 39 of file template_fieldnames.cpp.

40{
41 if( !aTranslateForHI )
42 {
43 switch( aFieldNdx )
44 {
45 case REFERENCE_FIELD: return REFERENCE_CANONICAL; // The symbol reference, R1, C1, etc.
46 case VALUE_FIELD: return VALUE_CANONICAL; // The symbol value
47 case FOOTPRINT_FIELD: return FOOTPRINT_CANONICAL; // The footprint for use with Pcbnew
48 case DATASHEET_FIELD: return DATASHEET_CANONICAL; // Link to a datasheet for symbol
49 default: return wxString::Format( wxT( "Field%d" ), aFieldNdx );
50 }
51 }
52
53 switch( aFieldNdx )
54 {
55 case REFERENCE_FIELD: return _( REFERENCE_CANONICAL ); // The symbol reference, R1, C1, etc.
56 case VALUE_FIELD: return _( VALUE_CANONICAL ); // The symbol value
57 case FOOTPRINT_FIELD: return _( FOOTPRINT_CANONICAL ); // The footprint for use with Pcbnew
58 case DATASHEET_FIELD: return _( DATASHEET_CANONICAL ); // Link to a datasheet for symbol
59 default: return wxString::Format( _( "Field%d" ), aFieldNdx );
60 }
61}
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define VALUE_CANONICAL
#define FOOTPRINT_CANONICAL
#define DATASHEET_CANONICAL
#define REFERENCE_CANONICAL
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".

References _, DATASHEET_CANONICAL, DATASHEET_FIELD, FOOTPRINT_CANONICAL, FOOTPRINT_FIELD, Format(), REFERENCE_CANONICAL, REFERENCE_FIELD, VALUE_CANONICAL, and VALUE_FIELD.

Referenced by TEMPLATES::AddTemplateFieldName(), DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS(), DIALOG_UPDATE_SYMBOL_FIELDS::DIALOG_UPDATE_SYMBOL_FIELDS(), SCH_EDIT_TOOL::editFieldText(), LIB_FIELD::GetCanonicalName(), FIELDS_EDITOR_GRID_DATA_MODEL::GetColLabelValue(), LIB_FIELD::GetName(), SCH_FIELD::GetName(), FIELDS_GRID_TABLE< T >::GetValue(), SCH_SYMBOL::Init(), LIB_FIELD::Init(), SCH_LEGACY_PLUGIN_CACHE::loadField(), SCH_LEGACY_PLUGIN::loadSymbol(), DIALOG_SYMBOL_PROPERTIES::OnAddField(), SCH_SEXPR_PARSER::parseProperty(), SCH_SEXPR_PARSER::parseSchField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), and SCH_SEXPR_PLUGIN_CACHE::saveField().

◆ Parse()

void TEMPLATE_FIELDNAME::Parse ( TEMPLATE_FIELDNAMES_LEXER *  aSpec)

Fill this object from information in the input stream aSpec, which is a #TEMPLATE_FIELDNAMES_LEXER.

The entire textual element spec is
(field (name yourfieldname)(value yourvalue) visible)). The presence of value is optional, the presence of visible is optional. When this function is called, the input token stream given by aSpec is assumed to be positioned at the '^' in the following example, i.e. just after the identifying keyword and before the content specifying stuff.
(field ^ (....) ).

Parameters
aSpecis the input token stream of keywords and symbols.

Definition at line 78 of file template_fieldnames.cpp.

79{
80 T tok;
81
82 in->NeedLEFT(); // begin (name ...)
83
84 if( ( tok = in->NextTok() ) != T_name )
85 in->Expecting( T_name );
86
87 in->NeedSYMBOLorNUMBER();
88
89 m_Name = FROM_UTF8( in->CurText() );
90
91 in->NeedRIGHT(); // end (name ...)
92
93 while( (tok = in->NextTok() ) != T_RIGHT && tok != T_EOF )
94 {
95 // "visible" has no '(' prefix, "value" does, so T_LEFT is optional.
96 if( tok == T_LEFT )
97 tok = in->NextTok();
98
99 switch( tok )
100 {
101 case T_value:
102 // older format; silently skip
103 in->NeedSYMBOLorNUMBER();
104 in->NeedRIGHT();
105 break;
106
107 case T_visible:
108 m_Visible = true;
109 break;
110
111 case T_url:
112 m_URL = true;
113 break;
114
115 default:
116 in->Expecting( "value|url|visible" );
117 break;
118 }
119 }
120}
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110

References FROM_UTF8(), m_Name, m_URL, and m_Visible.

Referenced by TEMPLATES::parse().

Member Data Documentation

◆ m_Name

wxString TEMPLATE_FIELDNAME::m_Name

◆ m_URL

bool TEMPLATE_FIELDNAME::m_URL

◆ m_Visible


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