Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models
diff options
context:
space:
mode:
Commit499a22cf9e6e6ce0cb396a53a25d22a1e63c734f (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-30 20:08:16 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-30 20:08:16 +0300
Files29235d02abc85314a8f95da7d773ba012667afbb /src/Models
FMI-OOP-P2_Tables-499a22cf9e6e6ce0cb396a53a25d22a1e63c734f.tar
FMI-OOP-P2_Tables-499a22cf9e6e6ce0cb396a53a25d22a1e63c734f.tar.gz
FMI-OOP-P2_Tables-499a22cf9e6e6ce0cb396a53a25d22a1e63c734f.zip
Parent5f73abc94a3d518e78225cff7b2ec2dc7838fff7 (diff)
Autocommit at 30.05.2022 @ 20:08
10 files changed, 5 insertions, 24 deletions
-rw-r--r--src/Models/Cell.h1
-rw-r--r--src/Models/CellDouble.cpp4
-rw-r--r--src/Models/CellDouble.h1
-rw-r--r--src/Models/CellFormula.cpp6
-rw-r--r--src/Models/CellFormula.h1
-rw-r--r--src/Models/CellInt.cpp4
-rw-r--r--src/Models/CellInt.h1
-rw-r--r--src/Models/CellString.cpp6
-rw-r--r--src/Models/CellString.h1
-rw-r--r--src/Models/Table.cpp4
diff --git a/src/Models/Cell.h b/src/Models/Cell.h
index 4bed4de..3c2fddc 100644
--- a/src/Models/Cell.h
+++ b/src/Models/Cell.h
@@ -9,7 +9,6 @@ public:
virtual double getNumeralValue() const = 0;
virtual String getValueForPrint() const = 0;
virtual void parseAndSetValue(const char* str) = 0;
- virtual void readFromFile(std::ifstream& file) = 0;
virtual void writeToFile(std::ofstream& file) = 0;
virtual ~Cell() = default;
diff --git a/src/Models/CellDouble.cpp b/src/Models/CellDouble.cpp
index 40aafd5..e0e1740 100644
--- a/src/Models/CellDouble.cpp
+++ b/src/Models/CellDouble.cpp
@@ -17,10 +17,6 @@ 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
index e81c8b2..080f65b 100644
--- a/src/Models/CellDouble.h
+++ b/src/Models/CellDouble.h
@@ -13,7 +13,6 @@ public:
double getNumeralValue() const override;
String getValueForPrint() const override;
void parseAndSetValue(const char* str) override;
- void readFromFile(std::ifstream& file) override;
void writeToFile(std::ofstream& file) override;
};
diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp
index 3c40421..de5202d 100644
--- a/src/Models/CellFormula.cpp
+++ b/src/Models/CellFormula.cpp
@@ -112,10 +112,6 @@ void CellFormula::parseAndSetValue(const char* str) {
}
}
-void CellFormula::readFromFile(std::ifstream& file) {
- file >> rawFormula;
-}
-
void CellFormula::writeToFile(std::ofstream& file) {
- file << rawFormula;
+ file << '"' << rawFormula << '"';
}
diff --git a/src/Models/CellFormula.h b/src/Models/CellFormula.h
index 61867b5..7833426 100644
--- a/src/Models/CellFormula.h
+++ b/src/Models/CellFormula.h
@@ -23,7 +23,6 @@ public:
double getNumeralValue() const override;
String getValueForPrint() const override;
void parseAndSetValue(const char* str) override;
- void readFromFile(std::ifstream& file) override;
void writeToFile(std::ofstream& file) override;
};
diff --git a/src/Models/CellInt.cpp b/src/Models/CellInt.cpp
index 942b5e0..280a3c3 100644
--- a/src/Models/CellInt.cpp
+++ b/src/Models/CellInt.cpp
@@ -17,10 +17,6 @@ void CellInt::parseAndSetValue(const char* str) {
value = atoi(str);
}
-void CellInt::readFromFile(std::ifstream& file) {
- file >> value;
-}
-
void CellInt::writeToFile(std::ofstream& file) {
file << value;
}
diff --git a/src/Models/CellInt.h b/src/Models/CellInt.h
index 8ebec24..cc7dab5 100644
--- a/src/Models/CellInt.h
+++ b/src/Models/CellInt.h
@@ -13,7 +13,6 @@ public:
double getNumeralValue() const override;
String getValueForPrint() const override;
void parseAndSetValue(const char* str) override;
- void readFromFile(std::ifstream& file) override;
void writeToFile(std::ofstream& file) override;
};
diff --git a/src/Models/CellString.cpp b/src/Models/CellString.cpp
index a383c25..9c010c3 100644
--- a/src/Models/CellString.cpp
+++ b/src/Models/CellString.cpp
@@ -17,10 +17,6 @@ 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);
+ file << '"' << value << '"';
}
diff --git a/src/Models/CellString.h b/src/Models/CellString.h
index 74df9d7..071898a 100644
--- a/src/Models/CellString.h
+++ b/src/Models/CellString.h
@@ -13,7 +13,6 @@ public:
double getNumeralValue() const override;
String getValueForPrint() const override;
void parseAndSetValue(const char* str) override;
- void readFromFile(std::ifstream& file) override;
void writeToFile(std::ofstream& file) override;
};
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp
index 04fb7b7..892a05d 100644
--- a/src/Models/Table.cpp
+++ b/src/Models/Table.cpp
@@ -153,9 +153,11 @@ void Table::saveToFile(const char* filePath) const {
std::ofstream outFile(filePath);
if (!outFile.is_open())
throw std::logic_error("Could not open file!");
+
for (unsigned i = 0; i < cells.get_count(); i++) {
for (unsigned j = 0; j < cells.get_count(); j++) {
- cells[i][j]->writeToFile(outFile);
+ if (cells[i][j] != nullptr)
+ cells[i][j]->writeToFile(outFile);
outFile << ',';
}
outFile << '\n';