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 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
 

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  :
188  m_type( VT_UNDEFINED ),
189  m_valueDbl( 0 ),
190  m_stringIsWildcard( false ),
191  m_isDeferredDbl( false )
192  {};

◆ VALUE() [2/3]

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

Definition at line 194 of file libeval_compiler.h.

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

◆ VALUE() [3/3]

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

Definition at line 202 of file libeval_compiler.h.

202  :
203  m_type( VT_NUMERIC ),
204  m_valueDbl( aVal ),
205  m_stringIsWildcard( false ),
206  m_isDeferredDbl( false )
207  {};

◆ ~VALUE()

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

Definition at line 209 of file libeval_compiler.h.

210  {};

Member Function Documentation

◆ AsDouble()

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

Definition at line 212 of file libeval_compiler.h.

213  {
214  if( m_isDeferredDbl )
215  {
217  m_isDeferredDbl = false;
218  }
219 
220  return m_valueDbl;
221  }
std::function< double()> m_lambdaDbl

References m_isDeferredDbl, m_lambdaDbl, and m_valueDbl.

Referenced by PCB_LAYER_VALUE::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 112 of file libeval_compiler.cpp.

113 {
114  if( m_type == VT_UNDEFINED || b->m_type == VT_UNDEFINED )
115  return false;
116 
117  if( m_type == VT_NUMERIC && b->m_type == VT_NUMERIC )
118  {
119  return m_valueDbl == b->m_valueDbl;
120  }
121  else if( m_type == VT_STRING && b->m_type == VT_STRING )
122  {
123  if( b->m_stringIsWildcard )
124  return WildCompareString( b->m_valueStr, m_valueStr, false );
125  else
126  return !m_valueStr.CmpNoCase( b->m_valueStr );
127  }
128 
129  return false;
130 }
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 m_stringIsWildcard, m_type, m_valueDbl, m_valueStr, 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 233 of file libeval_compiler.h.

233 { 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 133 of file libeval_compiler.cpp.

134 {
135  if( m_type == VT_UNDEFINED || b->m_type == VT_UNDEFINED )
136  return false;
137 
138  return !EqualTo( aCtx, b );
139 }
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]

◆ Set() [2/3]

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

Definition at line 248 of file libeval_compiler.h.

249  {
250  m_type = VT_STRING;
251  m_valueStr = aValue;
252  }

References m_type, m_valueStr, and LIBEVAL::VT_STRING.

◆ Set() [3/3]

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

Definition at line 254 of file libeval_compiler.h.

255  {
256  m_type = val.m_type;
257  m_valueDbl = val.m_valueDbl;
258 
259  if( m_type == VT_STRING )
260  m_valueStr = val.m_valueStr;
261  }

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

◆ SetDeferredEval()

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

Member Data Documentation

◆ m_isDeferredDbl

bool LIBEVAL::VALUE::m_isDeferredDbl
mutableprivate

Definition at line 269 of file libeval_compiler.h.

Referenced by AsDouble(), and SetDeferredEval().

◆ m_lambdaDbl

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

Definition at line 270 of file libeval_compiler.h.

Referenced by AsDouble(), and SetDeferredEval().

◆ m_stringIsWildcard

bool LIBEVAL::VALUE::m_stringIsWildcard
private

Definition at line 267 of file libeval_compiler.h.

Referenced by EqualTo().

◆ m_type

VAR_TYPE_T LIBEVAL::VALUE::m_type
private

Definition at line 264 of file libeval_compiler.h.

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

◆ m_valueDbl

double LIBEVAL::VALUE::m_valueDbl
mutableprivate

Definition at line 265 of file libeval_compiler.h.

Referenced by AsDouble(), EqualTo(), and Set().

◆ m_valueStr

wxString LIBEVAL::VALUE::m_valueStr
private

Definition at line 266 of file libeval_compiler.h.

Referenced by AsString(), EqualTo(), and Set().


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