Website Summary Files Commits Branches @commit @diff @stats
path: root / src
diff options
context:
space:
mode:
Commit5f73abc94a3d518e78225cff7b2ec2dc7838fff7 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-30 20:03:15 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-30 20:03:15 +0300
Files94f7d57b09479310ecd4ac9ac9672cc24911e007 /src
FMI-OOP-P2_Tables-5f73abc94a3d518e78225cff7b2ec2dc7838fff7.tar
FMI-OOP-P2_Tables-5f73abc94a3d518e78225cff7b2ec2dc7838fff7.tar.gz
FMI-OOP-P2_Tables-5f73abc94a3d518e78225cff7b2ec2dc7838fff7.zip
Parent28c22b23863ff82581e934be8c0d26b93f51abbb (diff)
Autocommit at 30.05.2022 @ 20:03
4 files changed, 16 insertions, 2 deletions
-rw-r--r--src/ test.table0
-rw-r--r--src/Generic/List/List.hpp3
-rw-r--r--src/Models/Table.cpp14
-rw-r--r--src/UserInterface/UserInterface.cpp1
diff --git a/src/ test.table b/src/ test.table
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/ test.table
diff --git a/src/Generic/List/List.hpp b/src/Generic/List/List.hpp
index f1919b3..c6fd8a1 100644
--- a/src/Generic/List/List.hpp
+++ b/src/Generic/List/List.hpp
@@ -116,8 +116,7 @@ List<T>::List(const T* elements, unsigned elementsCount) {
template <typename T>
List<T>::List(unsigned length) {
- this->length = length;
- count = 0;
+ this->length = count = length;
this->elements = new T[length];
for (unsigned i = 0; i < count; i++)
this->elements[i] = elements[i];
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();
+}
diff --git a/src/UserInterface/UserInterface.cpp b/src/UserInterface/UserInterface.cpp
index c8b672e..bf92f00 100644
--- a/src/UserInterface/UserInterface.cpp
+++ b/src/UserInterface/UserInterface.cpp
@@ -46,6 +46,7 @@ void UserInterface::com_saveas(const char* params) {
try {
table->saveToFile(params);
saved = true;
+ printLine("Successfully saved to file!");
}
catch (std::logic_error err) {
printLine(err.what());