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 72 of file template_fieldnames.h.

Constructor & Destructor Documentation

TEMPLATE_FIELDNAME::TEMPLATE_FIELDNAME ( )
inline

Definition at line 78 of file template_fieldnames.h.

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

Definition at line 83 of file template_fieldnames.h.

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

Definition at line 89 of file template_fieldnames.h.

References m_Name, m_Value, and m_Visible.

90  {
91  m_Name = ref.m_Name;
92  m_Value = ref.m_Value;
93  m_Visible = ref.m_Visible;
94  }
bool m_Visible
If first appearance of the field'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 60 of file template_fieldnames.cpp.

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

61 {
62  out->Print( nestLevel, "(field (name %s)", out->Quotew( m_Name ).c_str() );
63 
64  if( !m_Value.IsEmpty() )
65  out->Print( 0, "(value %s)", out->Quotew( m_Value ).c_str() );
66 
67  if( m_Visible )
68  out->Print( 0, " visible" );
69 
70  out->Print( 0, ")\n" );
71 }
bool m_Visible
If first appearance of the field'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:486
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:408
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 32 of file template_fieldnames.cpp.

References DATASHEET, FOOTPRINT, 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(), LIB_FIELD::Load(), SCH_COMPONENT::Load(), SCH_LEGACY_PLUGIN::loadComponent(), SCH_LEGACY_PLUGIN_CACHE::loadField(), and LIB_FIELD::Save().

33 {
34  // Fixed values for the first few default fields used by EESCHEMA
35  // (mandatory fields)
36  switch( aFieldNdx )
37  {
38  case REFERENCE:
39  return _( "Reference" ); // The component reference, R1, C1, etc.
40 
41  case VALUE:
42  return _( "Value" ); // The component value + name
43 
44  case FOOTPRINT:
45  return _( "Footprint" ); // The footprint for use with Pcbnew
46 
47  case DATASHEET:
48  return _( "Datasheet" ); // Link to a datasheet for component
49 
50  default:
51  break;
52  }
53 
54  // Other fields are use fields, give a default name:
55  wxString fieldName = _( "Field" );
56  fieldName << aFieldNdx;
57  return fieldName;
58 }
name of datasheet
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
Field Value of part, i.e. "3.3K".
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 74 of file template_fieldnames.cpp.

References DSNLEXER::CurText(), DSNLEXER::Expecting(), FROM_UTF8(), DSNLEXER::NeedLEFT(), DSNLEXER::NeedRIGHT(), TEMPLATE_FIELDNAMES_LEXER::NeedSYMBOLorNUMBER(), TEMPLATE_FIELDNAMES_LEXER::NextTok(), TFIELD_T::T_EOF, TFIELD_T::T_LEFT, TFIELD_T::T_name, TFIELD_T::T_RIGHT, TFIELD_T::T_value, and TFIELD_T::T_visible.

Referenced by TEMPLATES::Parse().

75 {
76  T tok;
77 
78  in->NeedLEFT(); // begin (name ...)
79 
80  if( (tok = in->NextTok()) != T_name )
81  in->Expecting( T_name );
82 
83  in->NeedSYMBOLorNUMBER();
84 
85  m_Name = FROM_UTF8( in->CurText() );
86 
87  in->NeedRIGHT(); // end (name ...)
88 
89  while( (tok = in->NextTok() ) != T_RIGHT && tok != T_EOF )
90  {
91  // "visible" has no '(' prefix, "value" does, so T_LEFT is optional.
92  if( tok == T_LEFT )
93  tok = in->NextTok();
94 
95  switch( tok )
96  {
97  case T_value:
98  in->NeedSYMBOLorNUMBER();
99  m_Value = FROM_UTF8( in->CurText() );
100  in->NeedRIGHT();
101  break;
102 
103  case T_visible:
104  m_Visible = true;
105  break;
106 
107  default:
108  in->Expecting( "value|visible" );
109  break;
110  }
111  }
112 }
bool m_Visible
If first appearance of the field'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.
T
enum T contains all this lexer's tokens.

Member Data Documentation

wxString TEMPLATE_FIELDNAME::m_Name

The field name.

Definition at line 74 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 75 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 76 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: