added task-class
This commit is contained in:
parent
469ad9bb65
commit
efd4e8fdf5
5 changed files with 113 additions and 17 deletions
32
einlesen.cpp
32
einlesen.cpp
|
|
@ -1,26 +1,24 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <sstream>
|
||||
#include "task.h"
|
||||
#include <deque>
|
||||
|
||||
std::vector<std::pair<std::string, std::string> > readFile(const std::string &filename) {
|
||||
std::vector<std::pair<std::string, std::string> > instructions;
|
||||
std::ifstream file(filename);
|
||||
using namespace std;
|
||||
|
||||
vector<pair<string, string> > readFile(const string &filename) {
|
||||
vector<pair<string, string> > instructions;
|
||||
ifstream file(filename);
|
||||
if(!file.is_open()) {
|
||||
std::cerr << "Fehler: Datei " << filename << " konnte nicht geöffnet werden.\n";
|
||||
cerr << "Fehler: Datei " << filename << " konnte nicht geöffnet werden.\n";
|
||||
return instructions;
|
||||
}
|
||||
|
||||
std::string line;
|
||||
while (std::getline(file, line)) {
|
||||
string line;
|
||||
while (getline(file, line)) {
|
||||
// Entferne führende oder trailing Whitespace
|
||||
if (line.empty()) continue;
|
||||
|
||||
std::istringstream iss(line);
|
||||
std::string command;
|
||||
std::string param;
|
||||
istringstream iss(line);
|
||||
string command;
|
||||
string param;
|
||||
|
||||
if (!(iss >> command)) {
|
||||
// Keine gültige Eingabe in dieser Zeile
|
||||
|
|
@ -33,7 +31,7 @@ std::vector<std::pair<std::string, std::string> > readFile(const std::string &fi
|
|||
param = "";
|
||||
}
|
||||
|
||||
instructions.push_back(std::make_pair(command, param));
|
||||
instructions.push_back(make_pair(command, param));
|
||||
}
|
||||
|
||||
return instructions;
|
||||
|
|
@ -43,7 +41,7 @@ std::vector<std::pair<std::string, std::string> > readFile(const std::string &fi
|
|||
int main() {
|
||||
auto result = readFile("init");
|
||||
for (const auto &inst : result) {
|
||||
std::cout << "Befehl: " << inst.first << " | Parameter: " << inst.second << "\n";
|
||||
cout << "Befehl: " << inst.first << " | Parameter: " << inst.second << "\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue