Created
December 7, 2008 09:44
-
-
Save JakubOboza/33072 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <pcrecpp.h> | |
#include <string> | |
#include <map> | |
#include <fstream> | |
#define LINE_SIZE 256 | |
typedef std::map<std::string,std::string> Hash; | |
int main(int argc,char** argv){ | |
if(argc != 2) | |
{ | |
std::cout<<"Usage: configlol <configfile>"<<std::endl; | |
return -1; | |
} | |
std::string filename(argv[1]); | |
std::fstream file(filename.c_str()); | |
std::string var, val; | |
pcrecpp::RE re("(\\w+):\\s+(.+)"); | |
Hash config; | |
while( !file.eof() ){ | |
char line[LINE_SIZE] = "" ; | |
file.getline(line,LINE_SIZE); | |
re.FullMatch( line , &var, &val); | |
config[var] = val ; | |
} | |
// config["name"] | |
for(Hash::iterator p = config.begin() ; p != config.end(); p++) | |
{ | |
std::cout << p->first << " : " << p->second << std::endl; | |
} | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment