Skip to content
Snippets Groups Projects
Commit d56b4843 authored by Anna Wellmann's avatar Anna Wellmann
Browse files

Add helper function for loading the config

parent 2616ec88
No related branches found
No related tags found
1 merge request!219Add helper function for creating configReader
#ifndef BASICS_CONFIGURATIONFILE_H
#define BASICS_CONFIGURATIONFILE_H
#include "Logger.h"
#include <filesystem>
#include <map>
#include <vector>
#include <sstream>
......@@ -68,6 +70,26 @@ public:
template<class T>
T getValue(const std::string& key, T defaultValue) const;
static ConfigurationFile loadConfig(int argc, char *argv[], std::filesystem::path configPath, std::string defaultConfigName = "config.txt")
{
// the config file's default name can be replaced by passing a command line argument
std::string configName = defaultConfigName;
if (argc > 1)
{
configName = argv[1];
VF_LOG_INFO("Using configFile command line argument: {}", configName);
} else {
VF_LOG_INFO("Using default config name: {}", configName);
}
configPath.replace_filename(configName);
vf::basics::ConfigurationFile config;
config.load(configPath.string());
return config;
}
private:
//! the container
std::map<std::string, std::string> data;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment