feat(config): config class added
At many points in the code we may want configurable options, the Config class usses a yaml file to make this easy. It also allows for namespace references "opac:lowtemp:file" etc...
This commit is contained in:
31
src/config/private/config.cpp
Normal file
31
src/config/private/config.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "yaml-cpp/yaml.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
Config::Config() {}
|
||||
|
||||
Config::~Config() {}
|
||||
|
||||
Config& Config::getInstance() {
|
||||
static Config instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool Config::loadConfig(const std::string& configFile) {
|
||||
configFilePath = configFile;
|
||||
try {
|
||||
yamlRoot = YAML::LoadFile(configFile);
|
||||
} catch (YAML::BadFile& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user