first commit, base server
This commit is contained in:
27
config_reader.cpp
Normal file
27
config_reader.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user