KiCad PCB EDA Suite
|
NUMERIC_EVALUATOR compatible wrapper around EXPRESSION_EVALUATOR. More...
#include <text_eval_wrapper.h>
Public Member Functions | |
NUMERIC_EVALUATOR_COMPAT (EDA_UNITS aUnits) | |
Constructor with default units. | |
~NUMERIC_EVALUATOR_COMPAT () | |
Destructor. | |
void | Clear () |
Clear parser state but retain variables. | |
void | SetDefaultUnits (EDA_UNITS aUnits) |
Set default units for evaluation. | |
void | LocaleChanged () |
Handle locale changes (for decimal separator) | |
bool | IsValid () const |
Check if the last evaluation was successful. | |
wxString | Result () const |
Get the result of the last evaluation. | |
bool | Process (const wxString &aString) |
Process and evaluate an expression. | |
wxString | OriginalText () const |
Get the original input text. | |
void | SetVar (const wxString &aString, double aValue) |
Set a variable value. | |
double | GetVar (const wxString &aString) |
Get a variable value. | |
void | RemoveVar (const wxString &aString) |
Remove a single variable. | |
void | ClearVar () |
Remove all variables. | |
Private Attributes | |
EXPRESSION_EVALUATOR | m_evaluator |
wxString | m_lastInput |
wxString | m_lastResult |
bool | m_lastValid |
NUMERIC_EVALUATOR compatible wrapper around EXPRESSION_EVALUATOR.
This class provides a drop-in replacement for NUMERIC_EVALUATOR that uses the new EXPRESSION_EVALUATOR backend. It maintains the same API to allow seamless migration of existing code.
The key difference is that expressions are automatically wrapped in...} syntax before evaluation.
Example usage:
Definition at line 438 of file text_eval_wrapper.h.
|
explicit |
Constructor with default units.
aUnits | Default units for the evaluator |
Definition at line 1913 of file text_eval_wrapper.cpp.
References m_evaluator, and m_lastValid.
|
default |
Destructor.
References Clear(), ClearVar(), GetVar(), IsValid(), LocaleChanged(), OriginalText(), Process(), RemoveVar(), Result(), SetDefaultUnits(), and SetVar().
void NUMERIC_EVALUATOR_COMPAT::Clear | ( | ) |
Clear parser state but retain variables.
Resets the parser state for processing a new expression. User-defined variables are retained.
Definition at line 1920 of file text_eval_wrapper.cpp.
References m_evaluator, m_lastInput, m_lastResult, and m_lastValid.
Referenced by BOOST_AUTO_TEST_CASE(), and ~NUMERIC_EVALUATOR_COMPAT().
void NUMERIC_EVALUATOR_COMPAT::ClearVar | ( | ) |
Remove all variables.
Definition at line 2064 of file text_eval_wrapper.cpp.
References m_evaluator.
Referenced by BOOST_AUTO_TEST_CASE(), and ~NUMERIC_EVALUATOR_COMPAT().
double NUMERIC_EVALUATOR_COMPAT::GetVar | ( | const wxString & | aString | ) |
Get a variable value.
aString | Variable name |
Definition at line 2043 of file text_eval_wrapper.cpp.
References m_evaluator, and result.
Referenced by BOOST_AUTO_TEST_CASE(), and ~NUMERIC_EVALUATOR_COMPAT().
bool NUMERIC_EVALUATOR_COMPAT::IsValid | ( | ) | const |
Check if the last evaluation was successful.
Definition at line 1938 of file text_eval_wrapper.cpp.
References m_lastValid.
Referenced by BOOST_AUTO_TEST_CASE(), and ~NUMERIC_EVALUATOR_COMPAT().
void NUMERIC_EVALUATOR_COMPAT::LocaleChanged | ( | ) |
Handle locale changes (for decimal separator)
This is a no-op in the EXPRESSION_EVALUATOR implementation since it handles locale properly internally.
Definition at line 1933 of file text_eval_wrapper.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), and ~NUMERIC_EVALUATOR_COMPAT().
wxString NUMERIC_EVALUATOR_COMPAT::OriginalText | ( | ) | const |
Get the original input text.
Definition at line 2033 of file text_eval_wrapper.cpp.
References m_lastInput.
Referenced by BOOST_AUTO_TEST_CASE(), and ~NUMERIC_EVALUATOR_COMPAT().
bool NUMERIC_EVALUATOR_COMPAT::Process | ( | const wxString & | aString | ) |
Process and evaluate an expression.
aString | Expression to evaluate |
Definition at line 1948 of file text_eval_wrapper.cpp.
References m_evaluator, m_lastInput, m_lastResult, and m_lastValid.
Referenced by BOOST_AUTO_TEST_CASE(), and ~NUMERIC_EVALUATOR_COMPAT().
void NUMERIC_EVALUATOR_COMPAT::RemoveVar | ( | const wxString & | aString | ) |
Remove a single variable.
aString | Variable name to remove |
Definition at line 2059 of file text_eval_wrapper.cpp.
References m_evaluator.
Referenced by BOOST_AUTO_TEST_CASE(), and ~NUMERIC_EVALUATOR_COMPAT().
wxString NUMERIC_EVALUATOR_COMPAT::Result | ( | ) | const |
Get the result of the last evaluation.
Definition at line 1943 of file text_eval_wrapper.cpp.
References m_lastResult.
Referenced by BOOST_AUTO_TEST_CASE(), and ~NUMERIC_EVALUATOR_COMPAT().
void NUMERIC_EVALUATOR_COMPAT::SetDefaultUnits | ( | EDA_UNITS | aUnits | ) |
Set default units for evaluation.
aUnits | The default units to use |
Definition at line 1928 of file text_eval_wrapper.cpp.
References m_evaluator.
Referenced by ~NUMERIC_EVALUATOR_COMPAT().
void NUMERIC_EVALUATOR_COMPAT::SetVar | ( | const wxString & | aString, |
double | aValue ) |
Set a variable value.
aString | Variable name |
aValue | Variable value |
Definition at line 2038 of file text_eval_wrapper.cpp.
References m_evaluator.
Referenced by BOOST_AUTO_TEST_CASE(), and ~NUMERIC_EVALUATOR_COMPAT().
|
private |
Definition at line 441 of file text_eval_wrapper.h.
Referenced by Clear(), ClearVar(), GetVar(), NUMERIC_EVALUATOR_COMPAT(), Process(), RemoveVar(), SetDefaultUnits(), and SetVar().
|
private |
Definition at line 442 of file text_eval_wrapper.h.
Referenced by Clear(), OriginalText(), and Process().
|
private |
Definition at line 443 of file text_eval_wrapper.h.
|
private |
Definition at line 444 of file text_eval_wrapper.h.
Referenced by Clear(), IsValid(), NUMERIC_EVALUATOR_COMPAT(), and Process().