KiCad PCB EDA Suite
altium_rule_transformer.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) 2021 Thomas Pointhuber <[email protected]>
5 * Copyright (C) 2021 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#ifndef ALTIUM_RULE_TRANSFORMER_H
26#define ALTIUM_RULE_TRANSFORMER_H
27
28#include "wx/string.h"
29
30// See: https://www.altium.com/documentation/altium-designer/query-operators-ad
32{
33 UNKNOWN,
34
35 IDENT,
39
42
43 LPAR,
44 RPAR,
45
46 ADD,
47 SUB,
48 MUL,
49 DIV,
51 MOD,
52
53 AND,
54 LOW_AND,
55 OR,
56 LOW_OR,
57 XOR,
58 NOT,
59
60 LESS,
63 GREATER,
65 EQUAL,
66
67 BETWEEN,
68 LIKE,
69
71};
72
74{
76 size_t pos;
77
78 long iValue;
79 double fValue;
80 wxString sValue;
81
83 kind( ALTIUM_RULE_TOKEN_KIND::UNKNOWN ), pos( 0 ), iValue( 0 ), fValue( 0. ),
84 sValue( "" )
85 {
86 }
87
89 kind( aKind ), pos( aPos ), iValue( 0 ), fValue( 0. ), sValue( "" )
90 {
91 }
92
93 ALTIUM_RULE_TOKEN( ALTIUM_RULE_TOKEN_KIND aKind, size_t aPos, long aValue ) :
94 kind( aKind ), pos( aPos ), iValue( aValue ), fValue( 0. ), sValue( "" )
95 {
96 }
97
98 ALTIUM_RULE_TOKEN( ALTIUM_RULE_TOKEN_KIND aKind, size_t aPos, float aValue ) :
99 kind( aKind ), pos( aPos ), iValue( 0 ), fValue( aValue ), sValue( "" )
100 {
101 }
102
103 ALTIUM_RULE_TOKEN( ALTIUM_RULE_TOKEN_KIND aKind, size_t aPos, wxString aValue ) :
104 kind( aKind ), pos( aPos ), iValue( 0 ), fValue( 0. ), sValue( aValue )
105 {
106 }
107};
108
110{
111public:
112 ALTIUM_RULE_TOKENIZER( const wxString& aExpr ) : m_pos( 0 ), m_expr( aExpr )
113 {
114 m_it = m_expr.begin();
115 Next();
116 }
117
118 const ALTIUM_RULE_TOKEN& Next();
119
120 const ALTIUM_RULE_TOKEN& Peek() const;
121
122private:
123 wxUniChar curChar() { return *m_it; }
124
125 wxUniChar nextChar()
126 {
127 if( m_it != m_expr.end() )
128 {
129 m_it++;
130 m_pos++;
131
132 if( m_it != m_expr.end() )
133 return *( m_it );
134 }
135
136 return wxUniChar();
137 }
138
139 size_t m_pos;
140 const wxString m_expr;
141 wxString::const_iterator m_it;
142
145};
146
147
148#endif //ALTIUM_RULE_TRANSFORMER_H
ALTIUM_RULE_TOKEN_KIND
@ MUL
Definition: am_param.h:150
@ SUB
Definition: am_param.h:150
@ DIV
Definition: am_param.h:150
@ ADD
Definition: am_param.h:150
const ALTIUM_RULE_TOKEN & Peek() const
ALTIUM_RULE_TOKENIZER(const wxString &aExpr)
ALTIUM_RULE_TOKEN m_currentToken
const ALTIUM_RULE_TOKEN & Next()
wxString::const_iterator m_it
@ UNKNOWN
Definition: sch_item.h:62
ALTIUM_RULE_TOKEN(ALTIUM_RULE_TOKEN_KIND aKind, size_t aPos, float aValue)
ALTIUM_RULE_TOKEN(ALTIUM_RULE_TOKEN_KIND aKind, size_t aPos)
ALTIUM_RULE_TOKEN_KIND kind
ALTIUM_RULE_TOKEN(ALTIUM_RULE_TOKEN_KIND aKind, size_t aPos, wxString aValue)
ALTIUM_RULE_TOKEN(ALTIUM_RULE_TOKEN_KIND aKind, size_t aPos, long aValue)