Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Table.cpp
diff options
context:
space:
mode:
Commit7be7db4f51d2cba12e65ccf61c7ff5834a832e36 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-30 20:48:31 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-30 20:48:31 +0300
Files5896cebc555a1e12d493f53f0f0fda05875dc39e /src/Models/Table.cpp
FMI-OOP-P2_Tables-7be7db4f51d2cba12e65ccf61c7ff5834a832e36.tar
FMI-OOP-P2_Tables-7be7db4f51d2cba12e65ccf61c7ff5834a832e36.tar.gz
FMI-OOP-P2_Tables-7be7db4f51d2cba12e65ccf61c7ff5834a832e36.zip
Parentc9839607652d8b762f4ba7cbd142e4a682ec567e (diff)
Autocommit at 30.05.2022 @ 20:48
1 files changed, 9 insertions, 9 deletions
-rw-r--r--src/Models/Table.cpp18
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp
index dd82b30..6ba20a4 100644
--- a/src/Models/Table.cpp
+++ b/src/Models/Table.cpp
@@ -100,23 +100,23 @@ void Table::readFromFile(std::ifstream& inFile) {
throw std::logic_error(fileLocationExceptionMsg("Error: Could not determine type of value at row ", cells.get_count(), inFile.tellg() % cells.get_count() + 1));
}
}
-
+#include <iostream>
Table::Table(const char* filePath) {
std::ifstream inFile(filePath);
+ std::cout << filePath << std::endl;
if (inFile.is_open())
- throw std::logic_error("Could now open file!");
+ throw std::logic_error("Could not open file!");
cells = List<List<Cell*>>();
readFromFile(inFile);
inFile.close();
}
-Table::Table(unsigned rows, unsigned cols) {
- if (rows == 0 || cols == 0)
- return;
-
- cells = List<List<Cell*>>(rows);
- for (unsigned i = 0; i < rows; i++)
- cells[i] = List<Cell*>(cols);
+Table::~Table() {
+ for (unsigned i = 0; i < cells.get_length(); i++) {
+ for (unsigned j = 0; j < cells.get_length(); j++) {
+ delete cells[i][j];
+ }
+ }
}
unsigned Table::get_rows() const {