18 using namespace Utils;
22 std::cout <<
"Creating a configuration from file "<<
filename<<
"\n";
33 std::string result =
"";
36 throw std::runtime_error(
"cannot open file");
38 while(std::getline(
stream, line))
44 while(std::getline(
stream, line))
48 if (!line.compare(0, key.length(), key))
50 result = line.substr(key.length());
60 std::vector<std::string> result;
62 char *charList =
new char[list.size()];
64 charList = strcpy(charList, list.c_str());
66 token = strtok(charList,
" ");
69 result.push_back(token);
70 token = strtok(NULL,
" ");
80 return line[0] ==
'[';
85 section =
"[" + section +
"]";
86 int result = line.compare(section);
98 return std::stod(str,
nullptr);
107 int result = std::stoi(str,
nullptr);
115 unsigned long long int result = 0;
116 result = stoull(str);
124 if (!str.compare(
"yes") || !str.compare(
"1") || !str.compare(
"true" ))
126 if (!str.compare(
"no" ) || !str.compare(
"0") || !str.compare(
"false"))
142 while((pos = str.find(
'/')) != std::string::npos)
144 str = str.substr(pos + 1, std::string::npos);
virtual unsigned long long int getUnsignedLongLongIntValue(std::string section, std::string key)
virtual int getIntValue(std::string section, std::string key)
std::string getFilePrefix()
returns the name of the configuration file stripped of any directory
virtual bool getBoolValue(std::string section, std::string key, bool defaultValue)
virtual double getDoubleValue(std::string section, std::string key)
std::string stripDirectories(std::string)
virtual std::vector< std::string > getStringList(std::string section, std::string key)
static bool isMatchingSection(std::string line, std::string section)
virtual std::string getStringValue(std::string section, std::string key)
Configuration(std::string file)
static bool isNewSection(std::string line)