From 5f73abc94a3d518e78225cff7b2ec2dc7838fff7 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 30 May 2022 20:03:15 +0300 Subject: Autocommit at 30.05.2022 @ 20:03 --- src/Models/Table.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/Models/Table.cpp') 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 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(); +} -- cgit v1.3.1-23-gd82d