Website Summary Files Commits Branches @commit @diff @stats
path: root / src / UserInterface
diff options
context:
space:
mode:
Commit7b141af08628069241ed7d1ac30b5f544e62bc82 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-30 18:32:47 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-30 18:32:47 +0300
Files5ff7f101b2ef5928afe387ff14a6c4eae2994c2b /src/UserInterface
FMI-OOP-P2_Tables-7b141af08628069241ed7d1ac30b5f544e62bc82.tar
FMI-OOP-P2_Tables-7b141af08628069241ed7d1ac30b5f544e62bc82.tar.gz
FMI-OOP-P2_Tables-7b141af08628069241ed7d1ac30b5f544e62bc82.zip
Parent14da4290639763ed79249c90f95e2387025a4764 (diff)
Autocommit at 30.05.2022 @ 18:32
2 files changed, 15 insertions, 0 deletions
-rw-r--r--src/UserInterface/UserInterface.cpp13
-rw-r--r--src/UserInterface/UserInterface.h2
diff --git a/src/UserInterface/UserInterface.cpp b/src/UserInterface/UserInterface.cpp
index 3fd51a7..3272f0d 100644
--- a/src/UserInterface/UserInterface.cpp
+++ b/src/UserInterface/UserInterface.cpp
@@ -7,6 +7,7 @@
/* Private (static) */
Table* UserInterface::table = nullptr;
+String fileName = String();
void UserInterface::com_open(const char* params) {
if (table != nullptr) {
@@ -16,16 +17,28 @@ void UserInterface::com_open(const char* params) {
try {
table = new Table(params);
+ fileName = params;
}
catch (std::logic_error err) {
printLine(err.what());
}
}
void UserInterface::com_close(const char* params) {
+ if (table == nullptr) {
+ printLine("No file has been opened!");
+ return;
+ }
+
+ delete table;
}
void UserInterface::com_save(const char* params) {
+ com_saveas(fileName.get_cstr());
}
void UserInterface::com_saveas(const char* params) {
+ if (table == nullptr) {
+ printLine("No file has been opened!");
+ return;
+ }
}
void UserInterface::com_help(const char* params) {
diff --git a/src/UserInterface/UserInterface.h b/src/UserInterface/UserInterface.h
index 42d323c..2a83580 100644
--- a/src/UserInterface/UserInterface.h
+++ b/src/UserInterface/UserInterface.h
@@ -2,12 +2,14 @@
#define HEADER_USERINTERFACE
#include "../Generic/ConsoleInterface/Menu.h"
+#include "../Generic/String/String.h"
#include "../Models/Table.h"
class UserInterface {
Menu menu;
static Table* table;
+ static String fileName;
static void com_open(const char* params);
static void com_close(const char* params);