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 <[email protected]>
5 * Copyright (C) 2014-2022 KiCad Developers, see AUTHORS.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
32class TEMPLATE_FIELDNAMES_LEXER;
33
34
47
51};
52
53// A helper to call GetDefaultFieldName with or without translation.
54// Translation should be used only to display field names in dialogs
55#define DO_TRANSLATE true
56
63{
65 m_Visible( false ),
66 m_URL( false )
67 {
68 }
69
70 TEMPLATE_FIELDNAME( const wxString& aName ) :
71 m_Name( aName ),
72 m_Visible( false ),
73 m_URL( false )
74 {
75 }
76
78 {
79 m_Name = ref.m_Name;
80 m_Visible = ref.m_Visible;
81 m_URL = ref.m_URL;
82 }
83
87 void Format( OUTPUTFORMATTER* out, int nestLevel ) const ;
88
101 void Parse( TEMPLATE_FIELDNAMES_LEXER* aSpec );
102
112 static const wxString GetDefaultFieldName( int aFieldNdx, bool aTranslateForHI = false );
113
114 wxString m_Name; // The field name
115 bool m_Visible; // Field defaults to being visible in schematic.
116 bool m_URL; // If field should have a browse button
117};
118
119typedef std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES;
120
121
123{
124public:
126 m_resolvedDirty( true )
127 { }
128
132 void Format( OUTPUTFORMATTER* out, int nestLevel, bool aGlobal ) const ;
133
138 void Parse( TEMPLATE_FIELDNAMES_LEXER* in, bool aGlobal );
139
140
151 void AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName, bool aGlobal );
152
156 void DeleteAllFieldNameTemplates( bool aGlobal );
157
162
166 const TEMPLATE_FIELDNAMES& GetTemplateFieldNames( bool aGlobal );
167
174 const TEMPLATE_FIELDNAME* GetFieldName( const wxString& aName );
175
176protected:
177 void resolveTemplates();
178
179private:
182
183 // Combined list. Project templates override global ones.
186};
187
188#endif // _TEMPLATE_FIELDNAME_H_
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:310
TEMPLATE_FIELDNAMES m_globals
void AddTemplateFieldName(const TEMPLATE_FIELDNAME &aFieldName, bool aGlobal)
Insert or append a wanted symbol field name into the field names template.
TEMPLATE_FIELDNAMES m_project
TEMPLATE_FIELDNAMES m_resolved
const TEMPLATE_FIELDNAME * GetFieldName(const wxString &aName)
Search for aName in the template field name list.
void DeleteAllFieldNameTemplates(bool aGlobal)
Delete the entire contents.
void Parse(TEMPLATE_FIELDNAMES_LEXER *in, bool aGlobal)
Fill this object from information in the input stream handled by #TEMPLATE_FIELDNAMES_LEXER.
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames()
Return a template field name list for read only access.
void Format(OUTPUTFORMATTER *out, int nestLevel, bool aGlobal) const
Serialize this object out as text into the given OUTPUTFORMATTER.
Hold a name of a symbol's field, field value, and default visibility.
void Format(OUTPUTFORMATTER *out, int nestLevel) const
Serialize this object out as text into the given OUTPUTFORMATTER.
void Parse(TEMPLATE_FIELDNAMES_LEXER *aSpec)
Fill this object from information in the input stream aSpec, which is a #TEMPLATE_FIELDNAMES_LEXER.
TEMPLATE_FIELDNAME(const wxString &aName)
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
TEMPLATE_FIELDNAME(const TEMPLATE_FIELDNAME &ref)
MANDATORY_FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES