KiCad PCB EDA Suite
template_fieldnames.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
5  * Copyright (C) 2014-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 
26 #ifndef _TEMPLATE_FIELDNAME_H_
27 #define _TEMPLATE_FIELDNAME_H_
28 
29 #include <richio.h>
30 #include <template_fieldnames_lexer.h>
31 
32 class TEMPLATE_FIELDNAMES_LEXER;
33 
34 
44  REFERENCE = 0,
48 
52 
61 };
62 
63 
71 {
72  wxString m_Name; // The field name
73  bool m_Visible; // Field defaults to being visible in schematic.
74  bool m_URL; // If field should have a browse button
75 
77  m_Visible( false ),
78  m_URL( false )
79  {
80  }
81 
82  TEMPLATE_FIELDNAME( const wxString& aName ) :
83  m_Name( aName ),
84  m_Visible( false ),
85  m_URL( false )
86  {
87  }
88 
90  {
91  m_Name = ref.m_Name;
92  m_Visible = ref.m_Visible;
93  m_URL = ref.m_URL;
94  }
95 
100  void Format( OUTPUTFORMATTER* out, int nestLevel ) const ;
101 
115  void Parse( TEMPLATE_FIELDNAMES_LEXER* aSpec );
116 
124  static const wxString GetDefaultFieldName( int aFieldNdx, bool aTranslate = true );
125 };
126 
127 typedef std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES;
128 
129 
131 {
132 private:
135 
136  // Combined list. Project templates override global ones.
139 
140 public:
142  m_resolvedDirty( true )
143  { }
144 
149  void Format( OUTPUTFORMATTER* out, int nestLevel, bool aGlobal ) const ;
150 
155  void Parse( TEMPLATE_FIELDNAMES_LEXER* in, bool aGlobal );
156 
157 
168  void AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName, bool aGlobal );
169 
174  void DeleteAllFieldNameTemplates( bool aGlobal );
175 
181 
186  const TEMPLATE_FIELDNAMES& GetTemplateFieldNames( bool aGlobal );
187 
195  const TEMPLATE_FIELDNAME* GetFieldName( const wxString& aName );
196 
197 protected:
198  void resolveTemplates();
199 
200 };
201 
202 #endif // _TEMPLATE_FIELDNAME_H_
void Format(OUTPUTFORMATTER *out, int nestLevel, bool aGlobal) const
Function Format serializes this object out as text into the given OUTPUTFORMATTER.
TEMPLATE_FIELDNAMES m_project
name of datasheet
void AddTemplateFieldName(const TEMPLATE_FIELDNAME &aFieldName, bool aGlobal)
Function AddTemplateFieldName inserts or appends a wanted symbol field name into the fieldnames templ...
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
void Parse(TEMPLATE_FIELDNAMES_LEXER *in, bool aGlobal)
Function Parse fills this object from information in the input stream handled by TEMPLATE_FIELDNAMES_...
void Parse(TEMPLATE_FIELDNAMES_LEXER *aSpec)
Function Parse fills this object from information in the input stream aSpec, which is a TEMPLATE_FIEL...
OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a convenient ...
Definition: richio.h:328
void DeleteAllFieldNameTemplates(bool aGlobal)
Function DeleteAllFieldNameTemplates deletes the entire contents.
Field Name Module PCB, i.e. "16DIP300".
void Format(OUTPUTFORMATTER *out, int nestLevel) const
Function Format serializes this object out as text into the given OUTPUTFORMATTER.
Field Reference of part, i.e. "IC21".
TEMPLATE_FIELDNAMES m_globals
std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslate=true)
Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all componen...
const TEMPLATE_FIELDNAME * GetFieldName(const wxString &aName)
Function GetFieldName searches for aName in the the template field name list.
NumFieldType
Enum NumFieldType is the set of all field indices assuming an array like sequence that a SCH_COMPONEN...
TEMPLATE_FIELDNAMES m_resolved
Field Value of part, i.e. "3.3K".
TEMPLATE_FIELDNAME(const wxString &aName)
TEMPLATE_FIELDNAME(const TEMPLATE_FIELDNAME &ref)
Struct TEMPLATE_FIELDNAME holds a name of a component's field, field value, and default visibility.
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames()
Function GetTemplateFieldName returns a template fieldnames list for read only access.