blob: 71e4e291de36f80731882be49891304f08947365 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include "CellFormula.h"
#include "CellDouble.h"
#include <cstring>
double CellFormula::calculate(unsigned index) {
double lval = CellDouble(formula[index].left->getValue()).getNumeralValue();
switch(formula[index].right) {
case plus: return lval + calculate(index++);
case minus: return lval - calculate(index++);
case mult: return lval * calculate(index++);
case div: return lval / calculate(index++);
default: return lval;
}
}
String CellFormula::getValueForPrint() {
return String() += calculate();
}
void CellFormula::parseAndSetValue(const char* str) {
//TODO
}
void CellFormula::readFromFile(std::ifstream& file) {
file >> rawFormula;
}
void CellFormula::writeToFile(std::ofstream& file) {
file << rawFormula;
}
|