Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models
diff options
context:
space:
mode:
Commitfe20ad7968a7c4d51ffd4d46d7905a59867032a7 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-28 18:44:32 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-28 18:44:32 +0300
Filese3444f4725f7bdc0197e4a121eadff3fa098464e /src/Models
FMI-OOP-P2_Tables-fe20ad7968a7c4d51ffd4d46d7905a59867032a7.tar
FMI-OOP-P2_Tables-fe20ad7968a7c4d51ffd4d46d7905a59867032a7.tar.gz
FMI-OOP-P2_Tables-fe20ad7968a7c4d51ffd4d46d7905a59867032a7.zip
Parent38857d8714495bf5ea72bb1faa75232dbcc0f77c (diff)
Autocommit at 28.05.2022 @ 18:44
4 files changed, 14 insertions, 3 deletions
-rw-r--r--src/Models/CellFormula.cpp6
-rw-r--r--src/Models/CellFormula.h1
-rw-r--r--src/Models/CellString.cpp9
-rw-r--r--src/Models/CellString.h1
diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp
index 71e4e29..21de3ec 100644
--- a/src/Models/CellFormula.cpp
+++ b/src/Models/CellFormula.cpp
@@ -2,8 +2,12 @@
#include "CellDouble.h"
#include <cstring>
+CellFormula::CellFormula(const char* str) : referencedCells(), formula(), rawFormula() {
+ parseAndSetValue(str);
+}
+
double CellFormula::calculate(unsigned index) {
- double lval = CellDouble(formula[index].left->getValue()).getNumeralValue();
+ double lval = formula[index].left->getNumeralValue();
switch(formula[index].right) {
case plus: return lval + calculate(index++);
diff --git a/src/Models/CellFormula.h b/src/Models/CellFormula.h
index 5838b38..688f805 100644
--- a/src/Models/CellFormula.h
+++ b/src/Models/CellFormula.h
@@ -23,6 +23,7 @@ class CellFormula : public Cell {
public:
CellFormula() = default;
+ CellFormula(const char* str);
double getNumeralValue() override;
String getValueForPrint() override;
diff --git a/src/Models/CellString.cpp b/src/Models/CellString.cpp
index ffc760c..20eacf4 100644
--- a/src/Models/CellString.cpp
+++ b/src/Models/CellString.cpp
@@ -1,7 +1,12 @@
#include "CellString.h"
+#include <cstring>
-String CellString::getNumeralValue() {
- return value;
+CellString::CellString(const char* str) {
+ value = String(str);
+}
+
+double CellString::getNumeralValue() {
+ return atof(value.get_cstr());
}
String CellString::getValueForPrint() {
diff --git a/src/Models/CellString.h b/src/Models/CellString.h
index ee581e8..f15e904 100644
--- a/src/Models/CellString.h
+++ b/src/Models/CellString.h
@@ -8,6 +8,7 @@ class CellString : public Cell {
public:
CellString() = default;
+ CellString(const char* str);
double getNumeralValue() override;
String getValueForPrint() override;