diff options
Autocommit at 28.05.2022 @ 16:24
8 files changed, 30 insertions, 5 deletions
| -rw-r--r-- | src/Models/Cell.h | 2 | ||||
| -rw-r--r-- | src/Models/CellDouble.cpp | 8 | ||||
| -rw-r--r-- | src/Models/CellDouble.h | 5 | ||||
| -rw-r--r-- | src/Models/CellFormula.h | 4 | ||||
| -rw-r--r-- | src/Models/CellInt.cpp | 4 | ||||
| -rw-r--r-- | src/Models/CellInt.h | 5 | ||||
| -rw-r--r-- | src/Models/CellString.cpp | 4 | ||||
| -rw-r--r-- | src/Models/CellString.h | 3 |
diff --git a/src/Models/Cell.h b/src/Models/Cell.h index 14f8be5..f202945 100644 --- a/src/Models/Cell.h +++ b/src/Models/Cell.h @@ -4,8 +4,10 @@ #include <fstream> #include "../Generic/String/String.h" +template <typename T> class Cell { public: + virtual T getValue() = 0; virtual String getValueForPrint() = 0; virtual void parseAndSetValue(const char* str) = 0; virtual void readFromFile(std::ifstream& file) = 0; diff --git a/src/Models/CellDouble.cpp b/src/Models/CellDouble.cpp index 9cb6eea..5c972f2 100644 --- a/src/Models/CellDouble.cpp +++ b/src/Models/CellDouble.cpp @@ -1,6 +1,14 @@ #include "CellDouble.h" #include <cstring> +CellDouble::CellDouble(int val) { + value = val; +} + +double CellDouble::getValue() { + return value; +} + String CellDouble::getValueForPrint() { return String() += value; } diff --git a/src/Models/CellDouble.h b/src/Models/CellDouble.h index 508d561..4b6525c 100644 --- a/src/Models/CellDouble.h +++ b/src/Models/CellDouble.h @@ -3,12 +3,15 @@ #include "Cell.h" -class CellDouble : public Cell { +class CellDouble : public Cell<double> { double value; public: CellDouble() = default; + CellDouble(int val); + CellDouble(String str); + double getValue() override; String getValueForPrint() override; void parseAndSetValue(const char* str) override; void readFromFile(std::ifstream& file) override; diff --git a/src/Models/CellFormula.h b/src/Models/CellFormula.h index 3074846..e360278 100644 --- a/src/Models/CellFormula.h +++ b/src/Models/CellFormula.h @@ -5,7 +5,7 @@ #include "../Generic/List/List.hpp" #include "../Generic/Pair/Pair.hpp" -class CellFormula : public Cell { +class CellFormula : public Cell<double> { enum Op { none, plus, @@ -21,6 +21,8 @@ class CellFormula : public Cell { double calculate(unsigned index = 0); + double getValue() override; + public: CellFormula() = default; diff --git a/src/Models/CellInt.cpp b/src/Models/CellInt.cpp index b2e4578..189d515 100644 --- a/src/Models/CellInt.cpp +++ b/src/Models/CellInt.cpp @@ -1,6 +1,10 @@ #include "CellInt.h" #include <cstring> +int CellInt::getValue() { + return value; +} + String CellInt::getValueForPrint() { return String() += value; } diff --git a/src/Models/CellInt.h b/src/Models/CellInt.h index 7256e5b..a14c062 100644 --- a/src/Models/CellInt.h +++ b/src/Models/CellInt.h @@ -3,12 +3,13 @@ #include "Cell.h" -class CellInt : public Cell { - unsigned value; +class CellInt : public Cell<int> { + int value; public: CellInt() = default; + int getValue() override; String getValueForPrint() override; void parseAndSetValue(const char* str) override; void readFromFile(std::ifstream& file) override; diff --git a/src/Models/CellString.cpp b/src/Models/CellString.cpp index d58fcfc..e0c4f2d 100644 --- a/src/Models/CellString.cpp +++ b/src/Models/CellString.cpp @@ -1,5 +1,9 @@ #include "CellString.h" +String CellString::getValue() { + return value; +} + String CellString::getValueForPrint() { return value; } diff --git a/src/Models/CellString.h b/src/Models/CellString.h index 7b5eb04..daa8427 100644 --- a/src/Models/CellString.h +++ b/src/Models/CellString.h @@ -3,12 +3,13 @@ #include "Cell.h" -class CellString : public Cell { +class CellString : public Cell<String> { String value; public: CellString() = default; + String getValue() override; String getValueForPrint() override; void parseAndSetValue(const char* str) override; void readFromFile(std::ifstream& file) override; |
