KiCad PCB EDA Suite
TEMPLATE_FIELDNAME Struct Reference

Struct TEMPLATE_FIELDNAME holds a name of a component'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
 Function Format serializes this object out as text into the given OUTPUTFORMATTER. More...
 
void Parse (TEMPLATE_FIELDNAMES_LEXER *aSpec)
 Function Parse fills 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)
 Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all components. More...
 

Public Attributes

wxString m_Name
 The field name. More...
 
wxString m_Value
 The default value or empty. More...
 
bool m_Visible
 If first appearance of the field's editor has as visible. More...
 

Detailed Description

Struct TEMPLATE_FIELDNAME holds a name of a component's field, field value, and default visibility.

Template fieldnames are wanted fieldnames for use in the symbol/component property editors.

Definition at line 71 of file template_fieldnames.h.

Constructor & Destructor Documentation

TEMPLATE_FIELDNAME::TEMPLATE_FIELDNAME ( )
inline

Definition at line 77 of file template_fieldnames.h.

77  :
78  m_Visible( false )
79  {
80  }
bool m_Visible
If first appearance of the field&#39;s editor has as visible.
TEMPLATE_FIELDNAME::TEMPLATE_FIELDNAME ( const wxString &  aName)
inline

Definition at line 82 of file template_fieldnames.h.

82  :
83  m_Name( aName ),
84  m_Visible( false )
85  {
86  }
bool m_Visible
If first appearance of the field&#39;s editor has as visible.
wxString m_Name
The field name.
TEMPLATE_FIELDNAME::TEMPLATE_FIELDNAME ( const TEMPLATE_FIELDNAME ref)
inline

Definition at line 88 of file template_fieldnames.h.

References Format(), GetDefaultFieldName(), m_Name, m_Value, m_Visible, and Parse().

89  {
90  m_Name = ref.m_Name;
91  m_Value = ref.m_Value;
92  m_Visible = ref.m_Visible;
93  }
bool m_Visible
If first appearance of the field&#39;s editor has as visible.
wxString m_Value
The default value or empty.
wxString m_Name
The field name.

Member Function Documentation

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

Function Format serializes this object out as text into the given OUTPUTFORMATTER.

Definition at line 81 of file template_fieldnames.cpp.

References OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

Referenced by TEMPLATE_FIELDNAME().

82 {
83  out->Print( nestLevel, "(field (name %s)", out->Quotew( m_Name ).c_str() );
84 
85  if( !m_Value.IsEmpty() )
86  out->Print( 0, "(value %s)", out->Quotew( m_Value ).c_str() );
87 
88  if( m_Visible )
89  out->Print( 0, " visible" );
90 
91  out->Print( 0, ")\n" );
92 }
bool m_Visible
If first appearance of the field&#39;s editor has as visible.
wxString m_Value
The default value or empty.
wxString m_Name
The field name.
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:482
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
const wxString TEMPLATE_FIELDNAME::GetDefaultFieldName ( int  aFieldNdx)
static

Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all components.

These fieldnames are not modifiable, but template fieldnames are.

Parameters
aFieldNdxThe field number index, > 0

Definition at line 34 of file template_fieldnames.cpp.

References DATASHEET, FOOTPRINT, PGM_BASE::GetLocale(), Pgm(), REFERENCE, and VALUE.

Referenced by DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::addFieldButtonHandler(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler(), TEMPLATES::AddTemplateFieldName(), SCH_COMPONENT::GetFieldText(), SCH_FIELD::GetName(), LIB_FIELD::Init(), SCH_COMPONENT::Init(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers(), SCH_LEGACY_PLUGIN::loadComponent(), SCH_LEGACY_PLUGIN_CACHE::loadField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem(), and TEMPLATE_FIELDNAME().

35 {
36  static void* locale = nullptr;
37  static wxString referenceDefault;
38  static wxString valueDefault;
39  static wxString footprintDefault;
40  static wxString datasheetDefault;
41  static wxString fieldDefault;
42 
43  // Fetching translations can take a surprising amount of time when loading libraries,
44  // so only do it when necessary.
45  if( Pgm().GetLocale() != locale )
46  {
47  referenceDefault = _( "Reference" );
48  valueDefault = _( "Value" );
49  footprintDefault = _( "Footprint" );
50  datasheetDefault = _( "Datasheet" );
51  fieldDefault = _( "Field" );
52  locale = Pgm().GetLocale();
53  }
54 
55  // Fixed values for the first few default fields used by EESCHEMA
56  // (mandatory fields)
57  switch( aFieldNdx )
58  {
59  case REFERENCE:
60  return referenceDefault; // The component reference, R1, C1, etc.
61 
62  case VALUE:
63  return valueDefault; // The component value + name
64 
65  case FOOTPRINT:
66  return footprintDefault; // The footprint for use with Pcbnew
67 
68  case DATASHEET:
69  return datasheetDefault; // Link to a datasheet for component
70 
71  default:
72  break;
73  }
74 
75  // Other fields are use fields, give a default name:
76  wxString fieldName = fieldDefault;
77  fieldName << aFieldNdx;
78  return fieldName;
79 }
name of datasheet
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
VTBL_ENTRY wxLocale * GetLocale()
Definition: pgm_base.h:175
#define VALUE
void TEMPLATE_FIELDNAME::Parse ( TEMPLATE_FIELDNAMES_LEXER *  aSpec)

Function Parse fills 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 95 of file template_fieldnames.cpp.

References FROM_UTF8().

Referenced by TEMPLATES::Parse(), and TEMPLATE_FIELDNAME().

96 {
97  T tok;
98 
99  in->NeedLEFT(); // begin (name ...)
100 
101  if( (tok = in->NextTok()) != T_name )
102  in->Expecting( T_name );
103 
104  in->NeedSYMBOLorNUMBER();
105 
106  m_Name = FROM_UTF8( in->CurText() );
107 
108  in->NeedRIGHT(); // end (name ...)
109 
110  while( (tok = in->NextTok() ) != T_RIGHT && tok != T_EOF )
111  {
112  // "visible" has no '(' prefix, "value" does, so T_LEFT is optional.
113  if( tok == T_LEFT )
114  tok = in->NextTok();
115 
116  switch( tok )
117  {
118  case T_value:
119  in->NeedSYMBOLorNUMBER();
120  m_Value = FROM_UTF8( in->CurText() );
121  in->NeedRIGHT();
122  break;
123 
124  case T_visible:
125  m_Visible = true;
126  break;
127 
128  default:
129  in->Expecting( "value|visible" );
130  break;
131  }
132  }
133 }
bool m_Visible
If first appearance of the field&#39;s editor has as visible.
wxString m_Value
The default value or empty.
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
wxString m_Name
The field name.

Member Data Documentation

wxString TEMPLATE_FIELDNAME::m_Name

The field name.

Definition at line 73 of file template_fieldnames.h.

Referenced by TEMPLATES::AddTemplateFieldName(), and TEMPLATE_FIELDNAME().

wxString TEMPLATE_FIELDNAME::m_Value

The default value or empty.

Definition at line 74 of file template_fieldnames.h.

Referenced by DIALOG_EESCHEMA_OPTIONS::OnAddButtonClick(), and TEMPLATE_FIELDNAME().

bool TEMPLATE_FIELDNAME::m_Visible

If first appearance of the field's editor has as visible.

Definition at line 75 of file template_fieldnames.h.

Referenced by DIALOG_EESCHEMA_OPTIONS::OnAddButtonClick(), and TEMPLATE_FIELDNAME().


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