KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef ALTIUM_RULE_TRANSFORMER_H
22#define ALTIUM_RULE_TRANSFORMER_H
23
24#include "wx/string.h"
25
26// See: https://www.altium.com/documentation/altium-designer/query-operators-ad
68
70{
72 size_t pos;
73
74 long iValue;
75 double fValue;
76 wxString sValue;
77
79 kind( ALTIUM_RULE_TOKEN_KIND::UNKNOWN ), pos( 0 ), iValue( 0 ), fValue( 0. ),
80 sValue( "" )
81 {
82 }
83
85 kind( aKind ), pos( aPos ), iValue( 0 ), fValue( 0. ), sValue( "" )
86 {
87 }
88
89 ALTIUM_RULE_TOKEN( ALTIUM_RULE_TOKEN_KIND aKind, size_t aPos, long aValue ) :
90 kind( aKind ), pos( aPos ), iValue( aValue ), fValue( 0. ), sValue( "" )
91 {
92 }
93
94 ALTIUM_RULE_TOKEN( ALTIUM_RULE_TOKEN_KIND aKind, size_t aPos, float aValue ) :
95 kind( aKind ), pos( aPos ), iValue( 0 ), fValue( aValue ), sValue( "" )
96 {
97 }
98
99 ALTIUM_RULE_TOKEN( ALTIUM_RULE_TOKEN_KIND aKind, size_t aPos, wxString aValue ) :
100 kind( aKind ), pos( aPos ), iValue( 0 ), fValue( 0. ), sValue( aValue )
101 {
102 }
103};
104
106{
107public:
108 ALTIUM_RULE_TOKENIZER( const wxString& aExpr ) : m_pos( 0 ), m_expr( aExpr )
109 {
110 m_it = m_expr.begin();
111 Next();
112 }
113
114 const ALTIUM_RULE_TOKEN& Next();
115
116 const ALTIUM_RULE_TOKEN& Peek() const;
117
118private:
119 wxUniChar curChar() { return *m_it; }
120
121 wxUniChar nextChar()
122 {
123 if( m_it != m_expr.end() )
124 {
125 m_it++;
126 m_pos++;
127
128 if( m_it != m_expr.end() )
129 return *( m_it );
130 }
131
132 return wxUniChar();
133 }
134
135 size_t m_pos;
136 const wxString m_expr;
137 wxString::const_iterator m_it;
138
141};
142
143
144#endif //ALTIUM_RULE_TRANSFORMER_H
@ MUL
Definition am_param.h:146
@ SUB
Definition am_param.h:146
@ DIV
Definition am_param.h:146
@ ADD
Definition am_param.h:146
const ALTIUM_RULE_TOKEN & Peek() const
ALTIUM_RULE_TOKENIZER(const wxString &aExpr)
const ALTIUM_RULE_TOKEN & Next()
wxString::const_iterator m_it
@ OR
Definition image.h:40
@ AND
Definition image.h:39
@ XOR
Definition image.h:41
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)