From cd27fe1454184e5f92457e950c81a904ea06a017 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 14 Jun 2022 08:33:48 +0300 Subject: Autocommit at 14.06.2022 @ 08:33 --- src/Models/CellFormula.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/Models/CellFormula.cpp') 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 #include @@ -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, char>(loc, currOp)); } } -- cgit v1.3.1-23-gd82d