/** * @file SolidInputParser.hh * @author: Yamiel Abreu * @date 2018 SoLid - University of Antwerp */ #ifndef SOLIDINPUTPARSER_H #define SOLIDINPUTPARSER_H #include #include class SolidInputParser{ public: SolidInputParser (int &arg_count, char **arg_vector){ for (int i=1; i < arg_count; ++i) this->tokens.push_back(std::string(arg_vector[i])); } const std::string& getCmdOption(const std::string &option) const{ std::vector::const_iterator itr; itr = std::find(this->tokens.begin(), this->tokens.end(), option); if (itr != this->tokens.end() && ++itr != this->tokens.end()){ return *itr; } static const std::string empty_string(""); return empty_string; } bool cmdOptionExists(const std::string &option) const{ return std::find(this->tokens.begin(), this->tokens.end(), option) != this->tokens.end(); } bool FindBeamOn(G4String filename, G4String token) { std::string line; std::string ctoken = "#"; bool found = false; std::ifstream filein(filename.data()); //File to read from while (getline(filein, line)) { if (line.find(token) != std::string::npos) { //Search std::cout << "Macro comand found: " << line << std::endl; if (line.find(ctoken) != std::string::npos) { //Check if line is commented found=false; }else { found=true; break; } } } if (filein.is_open()) { filein.close(); } return found; } private: std::vector tokens; }; #endif // SOLIDINPUTPARSER_H