2025-06-16 23:47:53 +02:00
|
|
|
#include "task.h"
|
|
|
|
|
#include <deque>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
vector<pair<string, string> > readFile(const string &filename) {
|
|
|
|
|
vector<pair<string, string> > instructions;
|
|
|
|
|
ifstream file(filename);
|
2025-06-16 09:17:12 +02:00
|
|
|
if(!file.is_open()) {
|
2025-06-16 23:47:53 +02:00
|
|
|
cerr << "Fehler: Datei " << filename << " konnte nicht geöffnet werden.\n";
|
2025-06-16 09:17:12 +02:00
|
|
|
return instructions;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-16 23:47:53 +02:00
|
|
|
string line;
|
|
|
|
|
while (getline(file, line)) {
|
2025-06-16 09:17:12 +02:00
|
|
|
// Entferne führende oder trailing Whitespace
|
|
|
|
|
if (line.empty()) continue;
|
|
|
|
|
|
2025-06-16 23:47:53 +02:00
|
|
|
istringstream iss(line);
|
|
|
|
|
string command;
|
|
|
|
|
string param;
|
2025-06-16 09:17:12 +02:00
|
|
|
|
|
|
|
|
if (!(iss >> command)) {
|
|
|
|
|
// Keine gültige Eingabe in dieser Zeile
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Optionalen Parameter einlesen, falls vorhanden
|
|
|
|
|
if (!(iss >> param)) {
|
|
|
|
|
// Kein Parameter vorhanden
|
|
|
|
|
param = "";
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-16 23:47:53 +02:00
|
|
|
instructions.push_back(make_pair(command, param));
|
2025-06-16 09:17:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return instructions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Beispiel zur Nutzung
|
|
|
|
|
int main() {
|
|
|
|
|
auto result = readFile("init");
|
|
|
|
|
for (const auto &inst : result) {
|
2025-06-16 23:47:53 +02:00
|
|
|
cout << "Befehl: " << inst.first << " | Parameter: " << inst.second << "\n";
|
2025-06-16 09:17:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|