ProgramLoader corrections
This commit is contained in:
@@ -12,3 +12,8 @@ Manager * Manager::getInstance(const std::string &program_path) {
|
||||
static Manager instance{program_path};
|
||||
return &instance;
|
||||
}
|
||||
|
||||
int Manager::run() {
|
||||
ProgramLoader::getInstance(m_path)->indexFile();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
#define MANAGER_H
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ProgramLoader.h"
|
||||
|
||||
/// Die Manager Instanz sorgt für die Koordination von user input, Datei einlesen, code execution und anderen Aktionen.
|
||||
|
||||
@@ -31,6 +32,8 @@ public:
|
||||
* @return Manager Instanz
|
||||
*/
|
||||
static Manager *getInstance(const std::string &program_path);
|
||||
|
||||
int run();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@ ProgramLoader::ProgramLoader(const std::string &path){
|
||||
m_programFile.open(path);
|
||||
}
|
||||
|
||||
ProgramLoader::~ProgramLoader() {
|
||||
m_programFile.close();
|
||||
}
|
||||
|
||||
ProgramLoader * ProgramLoader::getInstance(const std::string &program_path) {
|
||||
static ProgramLoader instance{program_path};
|
||||
return &instance;
|
||||
@@ -20,16 +24,15 @@ ProgramLoader * ProgramLoader::getInstance(const std::string &program_path) {
|
||||
std::istringstream iss(input);
|
||||
std::string out;
|
||||
do {
|
||||
out.clear();
|
||||
/// Trenne den IStringStream bei jedem Leerzeichen und füge die Befehl(e)/-sargumente dem Output hinzu
|
||||
std::getline(iss, out, ' ');
|
||||
if (out.empty()) break;
|
||||
/// Stoppe, sobald ein Kommentar im Source Code vorkommt
|
||||
if (out.at(0) != '#') {
|
||||
if (out.at(out.length() -1) == ',') {
|
||||
out.erase(out.length() - 1);
|
||||
}
|
||||
if (out.at(out.length() -1) == ':') {
|
||||
break;
|
||||
}
|
||||
output.push_back(out);
|
||||
} else {
|
||||
break;
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
ProgramLoader(const ProgramLoader&&) = delete;
|
||||
ProgramLoader& operator=(const ProgramLoader&) = delete;
|
||||
ProgramLoader& operator=(const ProgramLoader&&) = delete;
|
||||
~ProgramLoader();
|
||||
|
||||
/**
|
||||
* Gibt die Singleton Instanz des ProgramLoaders zurück
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Created by black on 12.06.25.
|
||||
//
|
||||
|
||||
#include "Manager.h"
|
||||
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
||||
return Manager::getInstance("/home/black/Nextcloud/Dokumente/Dokumente/Hochschule/2. Semester/Rechnerarchitektur/Projekt/test.txt")->run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user