您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

47 行
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;
}
}