diff options
Autocommit at 28.05.2022 @ 15:38
5 files changed, 48 insertions, 4 deletions
| -rw-r--r-- | src/Models/Cell.h | 4 | ||||
| -rw-r--r-- | src/Models/CellInt.cpp | 18 | ||||
| -rw-r--r-- | src/Models/CellInt.h | 18 | ||||
| -rw-r--r-- | src/Models/CellString.cpp | 8 | ||||
| -rw-r--r-- | src/Models/CellString.h | 4 |
diff --git a/src/Models/Cell.h b/src/Models/Cell.h index 4bf26bd..14f8be5 100644 --- a/src/Models/Cell.h +++ b/src/Models/Cell.h @@ -8,8 +8,8 @@ class Cell { public: virtual String getValueForPrint() = 0; virtual void parseAndSetValue(const char* str) = 0; - virtual void readFromFile(std::ifstream& filePath) = 0; - virtual void saveToFile(const char* filePath) = 0; + virtual void readFromFile(std::ifstream& file) = 0; + virtual void writeToFile(std::ofstream& file) = 0; virtual ~Cell() = default; }; diff --git a/src/Models/CellInt.cpp b/src/Models/CellInt.cpp new file mode 100644 index 0000000..01b262b --- /dev/null +++ b/src/Models/CellInt.cpp @@ -0,0 +1,18 @@ +#include "CellInt.h" +#include <cstring> + +String CellInt::getValueForPrint() { + return value; +} + +void CellInt::parseAndSetValue(const char* str) { + value = String(str); +} + +void CellInt::readFromFile(std::ifstream& file) { + value.read(file); +} + +void CellInt::writeToFile(std::ofstream& file) { + value.write(file); +} diff --git a/src/Models/CellInt.h b/src/Models/CellInt.h new file mode 100644 index 0000000..7256e5b --- /dev/null +++ b/src/Models/CellInt.h @@ -0,0 +1,18 @@ +#ifndef HEADER_CELLINT +#define HEADER_CELLINT + +#include "Cell.h" + +class CellInt : public Cell { + unsigned value; + +public: + CellInt() = 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/CellString.cpp b/src/Models/CellString.cpp index 82f7b29..d58fcfc 100644 --- a/src/Models/CellString.cpp +++ b/src/Models/CellString.cpp @@ -7,3 +7,11 @@ String CellString::getValueForPrint() { void CellString::parseAndSetValue(const char* str) { value = String(str); } + +void CellString::readFromFile(std::ifstream& file) { + value.read(file); +} + +void CellString::writeToFile(std::ofstream& file) { + value.write(file); +} diff --git a/src/Models/CellString.h b/src/Models/CellString.h index 1f311da..7b5eb04 100644 --- a/src/Models/CellString.h +++ b/src/Models/CellString.h @@ -11,8 +11,8 @@ public: String getValueForPrint() override; void parseAndSetValue(const char* str) override; - void readFromFile(const char* filePath) override; - void saveToFile(const char* filePath) override; + void readFromFile(std::ifstream& file) override; + void writeToFile(std::ofstream& file) override; }; #endif |
