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 
47 
51 };
52 
53 
60 {
62  m_Visible( false ),
63  m_URL( false )
64  {
65  }
66 
67  TEMPLATE_FIELDNAME( const wxString& aName ) :
68  m_Name( aName ),
69  m_Visible( false ),
70  m_URL( false )
71  {
72  }
73 
75  {
76  m_Name = ref.m_Name;
77  m_Visible = ref.m_Visible;
78  m_URL = ref.m_URL;
79  }
80 
84  void Format( OUTPUTFORMATTER* out, int nestLevel ) const ;
85 
98  void Parse( TEMPLATE_FIELDNAMES_LEXER* aSpec );
99 
108  static const wxString GetDefaultFieldName( int aFieldNdx, bool aTranslate = true );
109 
110  wxString m_Name; // The field name
111  bool m_Visible; // Field defaults to being visible in schematic.
112  bool m_URL; // If field should have a browse button
113 };
114 
115 typedef std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES;
116 
117 
119 {
120 public:
122  m_resolvedDirty( true )
123  { }
124 
128  void Format( OUTPUTFORMATTER* out, int nestLevel, bool aGlobal ) const ;
129 
134  void Parse( TEMPLATE_FIELDNAMES_LEXER* in, bool aGlobal );
135 
136 
147  void AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName, bool aGlobal );
148 
152  void DeleteAllFieldNameTemplates( bool aGlobal );
153 
158 
162  const TEMPLATE_FIELDNAMES& GetTemplateFieldNames( bool aGlobal );
163 
170  const TEMPLATE_FIELDNAME* GetFieldName( const wxString& aName );
171 
172 protected:
173  void resolveTemplates();
174 
175 private:
178 
179  // Combined list. Project templates override global ones.
182 };
183 
184 #endif // _TEMPLATE_FIELDNAME_H_
void Format(OUTPUTFORMATTER *out, int nestLevel, bool aGlobal) const
Serialize this object out as text into the given OUTPUTFORMATTER.
Field Reference of part, i.e. "IC21".
MANDATORY_FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
TEMPLATE_FIELDNAMES m_project
void AddTemplateFieldName(const TEMPLATE_FIELDNAME &aFieldName, bool aGlobal)
Insert or append a wanted symbol field name into the field names template.
void Parse(TEMPLATE_FIELDNAMES_LEXER *in, bool aGlobal)
Fill this object from information in the input stream handled by #TEMPLATE_FIELDNAMES_LEXER.
void Parse(TEMPLATE_FIELDNAMES_LEXER *aSpec)
Fill this object from information in the input stream aSpec, which is a #TEMPLATE_FIELDNAMES_LEXER.
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:309
void DeleteAllFieldNameTemplates(bool aGlobal)
Delete the entire contents.
void Format(OUTPUTFORMATTER *out, int nestLevel) const
Serialize this object out as text into the given OUTPUTFORMATTER.
name of datasheet
TEMPLATE_FIELDNAMES m_globals
std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES
Field Value of part, i.e. "3.3K".
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslate=true)
Return a default symbol field name for field aFieldNdx for all components.
const TEMPLATE_FIELDNAME * GetFieldName(const wxString &aName)
Search for aName in the template field name list.
TEMPLATE_FIELDNAMES m_resolved
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
TEMPLATE_FIELDNAME(const wxString &aName)
TEMPLATE_FIELDNAME(const TEMPLATE_FIELDNAME &ref)
Hold a name of a symbol's field, field value, and default visibility.
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames()
Return a template field name list for read only access.
Field Name Module PCB, i.e. "16DIP300".