[apps] Factorize portions checking whether text approximates to double

This commit is contained in:
Ruben Dashyan
2019-03-08 11:40:45 +01:00
committed by Émilie Feral
parent 5e5e07e963
commit 82685cb371
8 changed files with 24 additions and 30 deletions

View File

@@ -41,6 +41,15 @@ bool TextFieldDelegateApp::isAcceptableText(const char * text) {
return isAcceptableExpression(exp);
}
bool TextFieldDelegateApp::hasUndefinedValue(const char * text, double & value) {
value = PoincareHelpers::ApproximateToScalar<double>(text, *localContext());
bool isUndefined = std::isnan(value) || std::isinf(value);
if (isUndefined) {
displayWarning(I18n::Message::UndefinedValue);
}
return isUndefined;
}
/* Protected */
TextFieldDelegateApp::TextFieldDelegateApp(Container * container, Snapshot * snapshot, ViewController * rootViewController) :