KiCad PCB EDA Suite
LIBEVAL::VALUE Class Reference

#include <libeval_compiler.h>

Inheritance diagram for LIBEVAL::VALUE:
PCB_LAYER_VALUE

Public Member Functions

 VALUE ()
 
 VALUE (const wxString &aStr, bool aIsWildcard=false)
 
 VALUE (const double aVal)
 
virtual ~VALUE ()
 
virtual double AsDouble () const
 
virtual const wxString & AsString () const
 
virtual bool EqualTo (CONTEXT *aCtx, const VALUE *b) const
 
virtual bool NotEqualTo (CONTEXT *aCtx, const VALUE *b) const
 
VAR_TYPE_T GetType () const
 
void Set (double aValue)
 
void SetDeferredEval (std::function< double()> aLambda)
 
void SetDeferredEval (std::function< wxString()> aLambda)
 
void Set (const wxString &aValue)
 
void Set (const VALUE &val)
 

Private Attributes

VAR_TYPE_T m_type
 
double m_valueDbl
 
wxString m_valueStr
 
bool m_stringIsWildcard
 
bool m_isDeferredDbl
 
std::function< double()> m_lambdaDbl
 
bool m_isDeferredStr
 
std::function< wxString()> m_lambdaStr
 

Detailed Description

Definition at line 184 of file libeval_compiler.h.

Constructor & Destructor Documentation

◆ VALUE() [1/3]

LIBEVAL::VALUE::VALUE ( )
inline

Definition at line 187 of file libeval_compiler.h.

187 :
189 m_valueDbl( 0 ),
190 m_stringIsWildcard( false ),
191 m_isDeferredDbl( false ),
192 m_isDeferredStr( false )
193 {};

◆ VALUE() [2/3]

LIBEVAL::VALUE::VALUE ( const wxString &  aStr,
bool  aIsWildcard = false 
)
inline

Definition at line 195 of file libeval_compiler.h.

195 :
196 m_type( VT_STRING ),
197 m_valueDbl( 0 ),
198 m_valueStr( aStr ),
199 m_stringIsWildcard( aIsWildcard ),
200 m_isDeferredDbl( false ),
201 m_isDeferredStr( false )
202 {};

◆ VALUE() [3/3]

LIBEVAL::VALUE::VALUE ( const double  aVal)
inline

Definition at line 204 of file libeval_compiler.h.

204 :
206 m_valueDbl( aVal ),
207 m_stringIsWildcard( false ),
208 m_isDeferredDbl( false ),
209 m_isDeferredStr( false )
210 {};

◆ ~VALUE()

virtual LIBEVAL::VALUE::~VALUE ( )
inlinevirtual

Definition at line 212 of file libeval_compiler.h.

213 {};

Member Function Documentation

◆ AsDouble()

virtual double LIBEVAL::VALUE::AsDouble ( ) const
inlinevirtual

Definition at line 215 of file libeval_compiler.h.

216 {
217 if( m_isDeferredDbl )
218 {
220 m_isDeferredDbl = false;
221 }
222
223 return m_valueDbl;
224 }
std::function< double()> m_lambdaDbl

References m_isDeferredDbl, m_lambdaDbl, and m_valueDbl.

Referenced by EqualTo(), PCB_EXPR_EVALUATOR::Evaluate(), LIBEVAL::UOP::Exec(), and testEvalExpr().

◆ AsString()

virtual const wxString & LIBEVAL::VALUE::AsString ( ) const
inlinevirtual

◆ EqualTo()

bool LIBEVAL::VALUE::EqualTo ( CONTEXT aCtx,
const VALUE b 
) const
virtual

Definition at line 113 of file libeval_compiler.cpp.

114{
115 if( m_type == VT_UNDEFINED || b->m_type == VT_UNDEFINED )
116 return false;
117
118 if( m_type == VT_NUMERIC && b->m_type == VT_NUMERIC )
119 {
120 return AsDouble() == b->AsDouble();
121 }
122 else if( m_type == VT_STRING && b->m_type == VT_STRING )
123 {
124 if( b->m_stringIsWildcard )
125 return WildCompareString( b->AsString(), AsString(), false );
126 else
127 return !AsString().CmpNoCase( b->AsString() );
128 }
129
130 return false;
131}
virtual const wxString & AsString() const
virtual double AsDouble() const
bool WildCompareString(const wxString &pattern, const wxString &string_to_tst, bool case_sensitive)
Compare a string against wild card (* and ?) pattern using the usual rules.

References AsDouble(), AsString(), m_stringIsWildcard, m_type, LIBEVAL::VT_NUMERIC, LIBEVAL::VT_STRING, LIBEVAL::VT_UNDEFINED, and WildCompareString().

Referenced by LIBEVAL::UOP::Exec(), NotEqualTo(), and testEvalExpr().

◆ GetType()

VAR_TYPE_T LIBEVAL::VALUE::GetType ( ) const
inline

Definition at line 242 of file libeval_compiler.h.

242{ return m_type; };

References m_type.

Referenced by PCB_EXPR_EVALUATOR::Evaluate(), LIBEVAL::UOP::Exec(), and testEvalExpr().

◆ NotEqualTo()

bool LIBEVAL::VALUE::NotEqualTo ( CONTEXT aCtx,
const VALUE b 
) const
virtual

Definition at line 134 of file libeval_compiler.cpp.

135{
136 if( m_type == VT_UNDEFINED || b->m_type == VT_UNDEFINED )
137 return false;
138
139 return !EqualTo( aCtx, b );
140}
virtual bool EqualTo(CONTEXT *aCtx, const VALUE *b) const

References EqualTo(), m_type, and LIBEVAL::VT_UNDEFINED.

Referenced by LIBEVAL::UOP::Exec().

◆ Set() [1/3]

void LIBEVAL::VALUE::Set ( const VALUE val)
inline

Definition at line 270 of file libeval_compiler.h.

271 {
272 m_type = val.m_type;
273 m_valueDbl = val.m_valueDbl;
274
275 if( m_type == VT_STRING )
276 m_valueStr = val.m_valueStr;
277 }

References m_type, m_valueDbl, m_valueStr, and LIBEVAL::VT_STRING.

◆ Set() [2/3]

void LIBEVAL::VALUE::Set ( const wxString &  aValue)
inline

Definition at line 264 of file libeval_compiler.h.

265 {
267 m_valueStr = aValue;
268 }

References m_type, m_valueStr, and LIBEVAL::VT_STRING.

◆ Set() [3/3]

◆ SetDeferredEval() [1/2]

void LIBEVAL::VALUE::SetDeferredEval ( std::function< double()>  aLambda)
inline

◆ SetDeferredEval() [2/2]

void LIBEVAL::VALUE::SetDeferredEval ( std::function< wxString()>  aLambda)
inline

Definition at line 257 of file libeval_compiler.h.

258 {
260 m_lambdaStr = aLambda;
261 m_isDeferredStr = true;
262 }

References m_isDeferredStr, m_lambdaStr, m_type, and LIBEVAL::VT_STRING.

Member Data Documentation

◆ m_isDeferredDbl

bool LIBEVAL::VALUE::m_isDeferredDbl
mutableprivate

Definition at line 285 of file libeval_compiler.h.

Referenced by AsDouble(), and SetDeferredEval().

◆ m_isDeferredStr

bool LIBEVAL::VALUE::m_isDeferredStr
mutableprivate

Definition at line 288 of file libeval_compiler.h.

Referenced by AsString(), and SetDeferredEval().

◆ m_lambdaDbl

std::function<double()> LIBEVAL::VALUE::m_lambdaDbl
private

Definition at line 286 of file libeval_compiler.h.

Referenced by AsDouble(), and SetDeferredEval().

◆ m_lambdaStr

std::function<wxString()> LIBEVAL::VALUE::m_lambdaStr
private

Definition at line 289 of file libeval_compiler.h.

Referenced by AsString(), and SetDeferredEval().

◆ m_stringIsWildcard

bool LIBEVAL::VALUE::m_stringIsWildcard
private

Definition at line 283 of file libeval_compiler.h.

Referenced by EqualTo().

◆ m_type

VAR_TYPE_T LIBEVAL::VALUE::m_type
private

Definition at line 280 of file libeval_compiler.h.

Referenced by EqualTo(), GetType(), NotEqualTo(), Set(), and SetDeferredEval().

◆ m_valueDbl

double LIBEVAL::VALUE::m_valueDbl
mutableprivate

Definition at line 281 of file libeval_compiler.h.

Referenced by AsDouble(), and Set().

◆ m_valueStr

wxString LIBEVAL::VALUE::m_valueStr
mutableprivate

Definition at line 282 of file libeval_compiler.h.

Referenced by AsString(), and Set().


The documentation for this class was generated from the following files: