Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Table.cpp
diff options
context:
space:
mode:
1 files changed, 14 insertions, 0 deletions
-rw-r--r--src/Models/Table.cpp14
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp
index c0fe315..04fb7b7 100644
--- a/src/Models/Table.cpp
+++ b/src/Models/Table.cpp
@@ -148,3 +148,17 @@ List<String> Table::getAllCells() const {
}
return toRet;
}
+
+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);
+ outFile << ',';
+ }
+ outFile << '\n';
+ }
+ outFile.close();
+}