28 lines
796 B
C++
28 lines
796 B
C++
|
#include "config_reader.h"
|
||
|
#include <iostream>
|
||
|
config_reader::config_reader(std::string dir)
|
||
|
{
|
||
|
this->file.open(dir, std::ios::in);
|
||
|
std::string prueba;
|
||
|
std::getline(file, prueba);
|
||
|
}
|
||
|
|
||
|
bool config_reader::get_param(std::string variable, std::string &value){
|
||
|
this->file.clear();
|
||
|
this->file.seekg(0, file.beg);
|
||
|
std::string line;
|
||
|
while(std::getline(file, line)){
|
||
|
std::string no_coment=line.substr(0,line.find("#"));
|
||
|
std::size_t found=no_coment.find(variable);
|
||
|
if(found!=std::string::npos){
|
||
|
no_coment=no_coment.substr(found+variable.length(), no_coment.length());
|
||
|
found=no_coment.find("=");
|
||
|
if(found!=std::string::npos){
|
||
|
value=no_coment.substr(found+1, no_coment.length());
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|