This commit is contained in:
Torsten (PC)
2026-01-14 14:36:57 +01:00
parent cd739fb52e
commit 1fe77c0905
21 changed files with 1267 additions and 0 deletions

39
src/config.cpp Normal file
View File

@@ -0,0 +1,39 @@
#include "config.h"
#include <fstream>
#include <sstream>
#include <stdexcept>
Config::Config(const std::string &filepath)
{
load(filepath);
}
void Config::load(const std::string &filepath)
{
std::ifstream file(filepath);
if (!file)
{
throw std::runtime_error("Konfigurationsdatei konnte nicht geöffnet werden.");
}
std::string line;
while (std::getline(file, line))
{
std::istringstream iss(line);
std::string key, value;
if (std::getline(iss, key, '=') && std::getline(iss, value))
{
config_map[key] = value;
}
}
}
std::string Config::get(const std::string &key) const
{
auto it = config_map.find(key);
if (it != config_map.end())
{
return it->second;
}
throw std::runtime_error("Konfigurationsschlüssel nicht gefunden: " + key);
}