scaffold some common services

This commit is contained in:
2026-07-16 22:58:57 -05:00
parent 13bfbd3479
commit 3a3f67c4ef
22 changed files with 427 additions and 22 deletions

View File

@@ -0,0 +1,35 @@
#include "ConfigService.hpp"
#include <exception>
ConfigService::ConfigService(const std::string& filePath) {
if(!loadFromFile(filePath)) {
std::cout << "Error loading file " << filePath << std::endl;
}
}
bool ConfigService::loadFromFile(const std::string& filePath) {
try {
config_.clear();
config_.readFile(filePath.c_str());
lastError_.clear();
return true;
} catch (const libconfig::FileIOException&) {
lastError_ = "Unable to read config file: " + filePath;
} catch (const libconfig::ParseException& error) {
lastError_ = std::string("Parse error in ") + error.getFile() + ":" +
std::to_string(error.getLine()) + " - " + error.getError();
} catch (const std::exception& error) {
lastError_ = error.what();
}
return false;
}
const std::string& ConfigService::lastError() const {
return lastError_;
}