Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / CellFormula.cpp
diff options
context:
space:
mode:
Commitcd27fe1454184e5f92457e950c81a904ea06a017 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-06-14 08:33:48 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-06-14 08:33:48 +0300
Files07ccdd7af20174268bfb7a3f4411fc84b892e338 /src/Models/CellFormula.cpp
FMI-OOP-P2_Tables-cd27fe1454184e5f92457e950c81a904ea06a017.tar
FMI-OOP-P2_Tables-cd27fe1454184e5f92457e950c81a904ea06a017.tar.gz
FMI-OOP-P2_Tables-cd27fe1454184e5f92457e950c81a904ea06a017.zip
Parent3082d96e3338bfb9dc8fa94039192ce1030b4d47 (diff)
Autocommit at 14.06.2022 @ 08:33
1 files changed, 6 insertions, 9 deletions
-rw-r--r--src/Models/CellFormula.cpp15
diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp
index 1ef0357..59dac1d 100644
--- a/src/Models/CellFormula.cpp
+++ b/src/Models/CellFormula.cpp
@@ -1,5 +1,4 @@
#include "CellFormula.h"
-#include "CellInt.h"
#include "CellDouble.h"
#include <cstring>
#include <iostream>
@@ -110,7 +109,6 @@ void CellFormula::parseAndSetValue(const char* str) {
buffer.clear();
D(str, buffer);
loc.right = atoi(buffer.raw_data());
- W(str);
}
else if (*str >= '0' && *str <= '9') {
D(str, buffer);
@@ -120,21 +118,20 @@ void CellFormula::parseAndSetValue(const char* str) {
localCells.add(CellDouble(atof(buffer.raw_data())));
}
else
- localCells.add(CellInt(atoi(buffer.raw_data())));
- W(str);
+ localCells.add(CellDouble(atoi(buffer.raw_data())));
- currOp = *str;
- localCells.add(CellDouble(val));
- loc = {-1, (int)(localCells.get_count() - 1)};
+ loc.left = -1;
+ loc.right = (int)(localCells.get_count() - 1);
}
else
throw std::logic_error("Error: Invalid value!");
+ W(str);
O(str, currOp);
if (currOp == 0) throw std::logic_error("Error: Could not find operand!");
W(str);
-
+ // Operator priority magic
if (currOp == '^') currOp *= -1;
else if ((currOp == '+' || currOp == '-') && formula.get_count() != 0) {
for (unsigned i = formula.get_count() - 1; i < formula.get_count() && (formula[i].right == '*' || formula[i].right == '/'); i--)
@@ -146,7 +143,7 @@ void CellFormula::parseAndSetValue(const char* str) {
localCells.add(CellDouble(-1.0));
formula.add({{-1, (int)(localCells.get_count() - 1)}, '*' * -1});
}
- else formula.add({loc, currOp});
+ formula.add(Pair<Pair<int, int>, char>(loc, currOp));
}
}