diff options
Autocommit at 14.06.2022 @ 08:33
1 files changed, 6 insertions, 9 deletions
| -rw-r--r-- | src/Models/CellFormula.cpp | 15 |
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)); } } |
