Use configfilemanager to get the real command
All checks were successful
Build / build (push) Successful in 11s

This commit is contained in:
2025-06-07 09:26:15 +02:00
parent ed068875c3
commit 31ec926793
5 changed files with 54 additions and 26 deletions

48
src/configfilemanager.h Normal file
View File

@@ -0,0 +1,48 @@
#ifndef _CONFIGFILEMANAGER_H
#define _CONFIGFILEMANAGER_H
#include <map>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include "definitions.h"
class configfilemanager{
private:
std::map<std::string, std::string> configs;
public:
configfilemanager(std::string filepath = "./ncsambawatcher.config")
{
std::ifstream is(filepath);
std::string tmp;
while(std::getline(is, tmp))
{
if (tmp.at(0) == '#') // ignore comments
continue;
std::vector<std::string> splited = splitString(tmp, '=');
if (splited.size() != 2)
{
std::cerr << "Invalid line: " << tmp << std::endl;
continue;
}
configs.insert(std::make_pair(splited.at(0), splited.at(1)));
}
}
std::string at(const std::string &config)
{
return configs.at(config);
}
std::string at(const char* config)
{
return at(std::string(config));
}
};
#endif // _CONFIGFILEMANAGER_H