|
|
- #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;
- }
- }
|