Remove unused libraries
This commit is contained in:
parent
8ee0d38888
commit
08fcd825a7
|
@ -1,70 +0,0 @@
|
||||||
// A Test to read Config files
|
|
||||||
// This is a modified version
|
|
||||||
// The Config File Should be a text file
|
|
||||||
// and the content as follows
|
|
||||||
// key=value
|
|
||||||
|
|
||||||
#include "cfgfile.hh"
|
|
||||||
|
|
||||||
static void Trim(std::string &str){
|
|
||||||
if(str.empty()){//String is empty
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t i,start_pos,end_pos;
|
|
||||||
|
|
||||||
for(i=0;i<str.size();i++){//Get Start Position
|
|
||||||
if(!isspace(str[i])){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i==str.size()){//Only Space and Tabs in string
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_pos=i;
|
|
||||||
|
|
||||||
for(i=str.size()-1;i>=0;i--){//Get End Position
|
|
||||||
if(!isspace(str[i])){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
end_pos=i;
|
|
||||||
|
|
||||||
str=str.substr(start_pos,end_pos+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool readCfgFile(const char * cfgfilePath,const std::string &key,std::string &value){
|
|
||||||
//Open The Config File
|
|
||||||
std::fstream cfgfile;
|
|
||||||
cfgfile.open(cfgfilePath);
|
|
||||||
if(!cfgfile.is_open()){
|
|
||||||
std::cout<<"Failed to open the file!"<<std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Read each line of config file and get value
|
|
||||||
char tmp[1000];
|
|
||||||
while(!cfgfile.eof()){
|
|
||||||
cfgfile.getline(tmp,1000);
|
|
||||||
std::string line(tmp);
|
|
||||||
std::size_t pos = line.find('=');//Get the position of '='
|
|
||||||
|
|
||||||
if(pos == std::string::npos){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string tmpkey=line.substr(0,pos);
|
|
||||||
if(tmpkey == key){
|
|
||||||
value=line.substr(pos+1);
|
|
||||||
Trim(value);
|
|
||||||
cfgfile.close();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cfgfile.close();
|
|
||||||
return false;
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
bool readCfgFile(const char * cfgfilePath,const std::string &key,std::string &value);
|
|
Loading…
Reference in New Issue