diff options
Autocommit at 28.05.2022 @ 15:43
4 files changed, 61 insertions, 4 deletions
| -rw-r--r-- | src/Models/CellDouble.cpp | 18 | ||||
| -rw-r--r-- | src/Models/CellDouble.h | 18 | ||||
| -rw-r--r-- | src/Models/CellFormula.cpp | 21 | ||||
| -rw-r--r-- | src/Models/CellInt.cpp | 8 |
diff --git a/src/Models/CellDouble.cpp b/src/Models/CellDouble.cpp new file mode 100644 index 0000000..9cb6eea --- /dev/null +++ b/src/Models/CellDouble.cpp @@ -0,0 +1,18 @@ +#include "CellDouble.h" +#include <cstring> + +String CellDouble::getValueForPrint() { + return String() += value; +} + +void CellDouble::parseAndSetValue(const char* str) { + value = atof(str); +} + +void CellDouble::readFromFile(std::ifstream& file) { + file >> value; +} + +void CellDouble::writeToFile(std::ofstream& file) { + file << value; +} diff --git a/src/Models/CellDouble.h b/src/Models/CellDouble.h new file mode 100644 index 0000000..508d561 --- /dev/null +++ b/src/Models/CellDouble.h @@ -0,0 +1,18 @@ +#ifndef HEADER_CELLDOUBLE +#define HEADER_CELLDOUBLE + +#include "Cell.h" + +class CellDouble : public Cell { + double value; + +public: + CellDouble() = default; + + String getValueForPrint() override; + void parseAndSetValue(const char* str) override; + void readFromFile(std::ifstream& file) override; + void writeToFile(std::ofstream& file) override; +}; + +#endif diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp new file mode 100644 index 0000000..d3c3304 --- /dev/null +++ b/src/Models/CellFormula.cpp @@ -0,0 +1,21 @@ +#ifndef HEADER_CELLFORMULA +#define HEADER_CELLFORMULA + +#include "Cell.h" +#include "../Generic/List/List.hpp" + +class CellFormula : public Cell { + List<Cell*> referencedCells; + String rawFormula; + double value; + +public: + CellFormula() = default; + + String getValueForPrint() override; + void parseAndSetValue(const char* str) override; + void readFromFile(std::ifstream& file) override; + void writeToFile(std::ofstream& file) override; +}; + +#endif diff --git a/src/Models/CellInt.cpp b/src/Models/CellInt.cpp index 01b262b..b2e4578 100644 --- a/src/Models/CellInt.cpp +++ b/src/Models/CellInt.cpp @@ -2,17 +2,17 @@ #include <cstring> String CellInt::getValueForPrint() { - return value; + return String() += value; } void CellInt::parseAndSetValue(const char* str) { - value = String(str); + value = atoi(str); } void CellInt::readFromFile(std::ifstream& file) { - value.read(file); + file >> value; } void CellInt::writeToFile(std::ofstream& file) { - value.write(file); + file << value; } |
