37 lines
725 B
C++
37 lines
725 B
C++
|
#include "Config.hpp"
|
||
|
#include <iostream>
|
||
|
|
||
|
Config::Config(const char* filename){
|
||
|
setConfFile(filename);
|
||
|
loadConfig();
|
||
|
}
|
||
|
|
||
|
void Config::setConfFile(const char * filename){
|
||
|
config_file.open(filename);
|
||
|
}
|
||
|
|
||
|
void Config::loadConfig(){
|
||
|
std::string key, value;
|
||
|
while(config_file){
|
||
|
getline(config_file, key,':');
|
||
|
config_file >> value;
|
||
|
config_file >> std::ws;
|
||
|
if(!config_file){
|
||
|
break;
|
||
|
}
|
||
|
config_map[key] = value;
|
||
|
}
|
||
|
config_file.close();
|
||
|
}
|
||
|
|
||
|
void Config::printConfig(){
|
||
|
for(std::map<std::string,std::string>::iterator it = config_map.begin(); it != config_map.end(); it++){
|
||
|
std::cout << it->first << " : " << it->second << std::endl;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
std::string Config::getValue(std::string key){
|
||
|
return config_map[key];
|
||
|
}
|
||
|
|