Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / CellFormula.cpp
diff options
context:
space:
mode:
Commitbf5379163331720265335174a3396693246c4c98 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-06-14 08:38:49 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-06-14 08:38:49 +0300
Files7a3bd939eb95cf4d4b51135e1951453fc1fd1595 /src/Models/CellFormula.cpp
FMI-OOP-P2_Tables-bf5379163331720265335174a3396693246c4c98.tar
FMI-OOP-P2_Tables-bf5379163331720265335174a3396693246c4c98.tar.gz
FMI-OOP-P2_Tables-bf5379163331720265335174a3396693246c4c98.zip
Parentcd27fe1454184e5f92457e950c81a904ea06a017 (diff)
Autocommit at 14.06.2022 @ 08:38
1 files changed, 6 insertions, 3 deletions
-rw-r--r--src/Models/CellFormula.cpp9
diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp
index 59dac1d..db73866 100644
--- a/src/Models/CellFormula.cpp
+++ b/src/Models/CellFormula.cpp
@@ -98,6 +98,7 @@ void CellFormula::parseAndSetValue(const char* str) {
Pair<int, int> loc;
char currOp = 0;
+ str++; // Removes = from the beginning
while (*str != '\0') {
List<char> buffer;
W(str);
@@ -129,7 +130,6 @@ void CellFormula::parseAndSetValue(const char* str) {
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;
@@ -138,11 +138,14 @@ void CellFormula::parseAndSetValue(const char* str) {
if (formula[i].right > 0) formula[i].right *= -1;
}
- if (currOp == '-') {
+ if (currOp == '-') { // a - b turns into a + -1 * b
formula.add({loc, '+'});
localCells.add(CellDouble(-1.0));
- formula.add({{-1, (int)(localCells.get_count() - 1)}, '*' * -1});
+ loc.left = -1;
+ loc.right = (int)(localCells.get_count() - 1);
+ currOp = '*' * -1;
}
+
formula.add(Pair<Pair<int, int>, char>(loc, currOp));
}
}