diff options
Autocommit at 28.05.2022 @ 19:29
2 files changed, 13 insertions, 9 deletions
| -rw-r--r-- | src/Models/CellFormula.cpp | 9 | ||||
| -rw-r--r-- | src/Models/CellFormula.h | 13 |
diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp index 395e31c..631621d 100644 --- a/src/Models/CellFormula.cpp +++ b/src/Models/CellFormula.cpp @@ -10,8 +10,8 @@ CellFormula::CellFormula(const char* str, const List<List<Cell*>>* tableCells) : double CellFormula::calculate(unsigned index) { double lval = formula[index].left->getNumeralValue(); - if (formula[index].right & branch) { - switch (formula[index++].right & !branch) { + if (formula[index].right < 0) { + switch (-formula[index++].right) { case plus : lval += formula[index].left->getNumeralValue(); break; case minus : lval -= formula[index].left->getNumeralValue(); break; case mult : lval *= formula[index].left->getNumeralValue(); break; @@ -42,6 +42,11 @@ void CellFormula::parseAndSetValue(const char* str) { while (*str == ' ') str++; if (*str == 'R') { unsigned row = atoi(++str); + while (*str != 'C') str++; + unsigned col = atoi(++str); + while (*str != ' ') str++; + + formula.add({(*tableCells)[row][col], (Op)*str}); } } diff --git a/src/Models/CellFormula.h b/src/Models/CellFormula.h index 28134ab..819e758 100644 --- a/src/Models/CellFormula.h +++ b/src/Models/CellFormula.h @@ -7,13 +7,12 @@ class CellFormula : public Cell { enum Op { - none = 0b000000, - branch = 0b000001, - plus = 0b000010, - minus = 0b000100, - mult = 0b001000, - div = 0b010000, - pow = 0b100000, + none = 0, + plus = '+', + minus = '-', + mult = '*', + div = '/', + pow = '^', }; const List<List<Cell*>>* tableCells; |
