You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

47 lines
809 B

#pragma once
#include <fstream>
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
namespace config
{
inline std::string get_value(const std::string& source)
{
std::string ret = source;
try
{
std::ifstream config_file("/home/archivist/.rigidparadise/rp.cfg");
if(!config_file.good())
{
std::cerr << "Unable to read configuration"<<std::endl;
}
while(config_file.good())
{
std::string str;
getline (config_file, str);
if(str.size()>1 && str[0] != '#')
{
auto end = std::find_if(str.begin(), str.end(), isspace);
size_t pos = end-str.begin();
std::string_view name{str.data(), pos};
if(name == source)
{
ret = std::string{end+1, str.end()};
}
}
}
}
catch(...)
{}
return ret;
}
}