From 5f2b8e0409a0ccfd955337aea6d5cb810870847a Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 27 Feb 2018 11:40:27 +0100 Subject: [PATCH] Change NumericEvaluator::clear() to optionally accept an object to clear --- common/libeval/numeric_evaluator.cpp | 4 +++- include/libeval/numeric_evaluator.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/libeval/numeric_evaluator.cpp b/common/libeval/numeric_evaluator.cpp index 6945f715bc..46884113ce 100644 --- a/common/libeval/numeric_evaluator.cpp +++ b/common/libeval/numeric_evaluator.cpp @@ -96,12 +96,14 @@ NumericEvaluator :: init() } void -NumericEvaluator :: clear() +NumericEvaluator :: clear(const void* pObj) { free(clToken.token); clToken.token = nullptr; clToken.input = nullptr; bClError = true; + + if (bClTextInputStorage && pObj) clObjMap.erase(pObj); } void diff --git a/include/libeval/numeric_evaluator.h b/include/libeval/numeric_evaluator.h index 274c22e14a..000c913790 100644 --- a/include/libeval/numeric_evaluator.h +++ b/include/libeval/numeric_evaluator.h @@ -100,10 +100,10 @@ public: /* Initialization and destruction. init() is invoked be the constructor and should not be needed * by the user. * clear() should be invoked by the user if a new input string is to be processed. It will reset - * the parser. User defined variables are retained. + * the parser and clear the original expression value for a requested object (if pObj != null). */ void init(); - void clear(); + void clear(const void* pObj = nullptr); /* Set the decimal separator for the input string. Defaults to '.' */ void setDecimalSeparator(char sep);