blob: 7f45c2ea0a61254628787472d0b7452e1d2e4ba0 (
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
32
33
34
35
36
|
#include "CellFormula.h"
#include "CellDouble.h"
#include <cstring>
double CellFormula::calculate(unsigned index) {
double lval = CellDouble(formula[index].left->getValue()).getValue();
switch(formula[index].right) {
plus: return lval + calculate(index++);
minus: return lval - calculate(index++);
mult: return lval * calculate(index++);
div: return lval / calculate(index++);
pow:
double power = calculate(index++);
for (unsigned i = 0; i < power; i++)
lval *= lval;
none:
default: return lval;
}
}
String CellFormula::getValueForPrint() {
double result = calculate();
return "";
}
void CellFormula::parseAndSetValue(const char* str) {
}
void CellFormula::readFromFile(std::ifstream& file) {
file >> rawFormula;
}
void CellFormula::writeToFile(std::ofstream& file) {
file << rawFormula;
}
|