readHerwigConfigFile.h

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <vector>
00003 #include <string>
00004 #include <iostream>
00005 #include <fstream>
00006 
00007 void  readConfigFile(std::vector< std::string >* inputlines , std::string configfile){
00008     std::string line;
00009     std::ifstream myfile (configfile.c_str());
00010     if (myfile.is_open())
00011         {
00012             // read line by line of the file
00013             while (! myfile.eof() )
00014                 {
00015                     // write read lines into string line
00016                     getline (myfile,line);
00017 
00018                     // check for Comments. Remove everything from the position of the character "#"
00019                     if(line.find("#") != std::string::npos) 
00020                         line.replace(line.find("#"), line.length()-line.find("#"),"");
00021 
00022                     // remove whitespaces from the beginning of the line
00023                     //while(line[0]==std::string(" ")) line.replace(0,1, "");
00024 
00025                     // skip empty lines
00026                     if(line.empty()) continue;
00027 
00028                     // fill lines in vector
00029                     inputlines->push_back(line);
00030                 }
00031 
00032             myfile.close();
00033         }
00034     else std::cout << "Unable to open file " << configfile << std::endl; 
00035 
00036 }
00037 

Generated on Wed Aug 31 09:44:48 2011 for HepMCAnalysis by  doxygen 1.4.7