#include <Calibration/Tools/bin/trivialParser.h>
Public Member Functions | |
double | getVal (std::string name) |
return the value for that parameter | |
trivialParser (std::string configFile) | |
ctor | |
Private Member Functions | |
void | eraseSpaces (std::string &word) |
get rid of spaces | |
std::string | getNextLine (std::ifstream &input) |
returns the next not commented line | |
void | parse (std::string configFile) |
parse the cfg file | |
void | print (std::string prefix="") |
print the read params | |
Private Attributes | |
std::map< std::string, double > | m_config |
container for the output |
Definition at line 13 of file trivialParser.h.
trivialParser::trivialParser | ( | std::string | configFile | ) | [explicit] |
void trivialParser::eraseSpaces | ( | std::string & | word | ) | [private] |
get rid of spaces
Definition at line 90 of file trivialParser.cc.
Referenced by parse().
00091 { 00092 while (word.find (' ',0) != std::string::npos) 00093 { 00094 word.erase (word.find (' ',0), 1) ; 00095 } 00096 return ; 00097 }
std::string trivialParser::getNextLine | ( | std::ifstream & | input | ) | [private] |
returns the next not commented line
Definition at line 52 of file trivialParser.cc.
Referenced by parse().
00053 { 00054 // std::cerr << "PG prima cerca " << std::endl ; 00055 std::string singleLine ; 00056 do { 00057 getline (input, singleLine,'\n') ; 00058 // std::cerr << "PG guardo " << singleLine << std::endl ; 00059 } while (( 00060 singleLine.find ('#',0) != std::string::npos || 00061 singleLine.find ('=',0) == std::string::npos || 00062 singleLine.size () < 3 00063 ) && 00064 !input.eof ()) ; 00065 // std::cerr << "PG trovato " << singleLine << std::endl ; 00066 return singleLine ; 00067 }
double trivialParser::getVal | ( | std::string | name | ) |
return the value for that parameter
Definition at line 17 of file trivialParser.cc.
References TestMuL1L2Filter_cff::cerr, and m_config.
00018 { 00019 if (m_config.count (name)) return m_config[name] ; 00020 std::cerr << "[trivialParser] no value for " 00021 << name 00022 << " found\n" ; 00023 return -999999. ; 00024 }
void trivialParser::parse | ( | std::string | configFile | ) | [private] |
parse the cfg file
Definition at line 31 of file trivialParser.cc.
References eraseSpaces(), getNextLine(), iggi_31X_cfg::input, m_config, name, NULL, and value.
Referenced by trivialParser().
00032 { 00033 std::ifstream input (configFile.c_str ()) ; 00034 do { 00035 std::string linea = getNextLine (input) ; 00036 if (linea.empty ()) continue ; 00037 std::string name (linea,0,linea.find ('=',0)) ; 00038 eraseSpaces (name) ; 00039 std::string valuestring (linea,linea.find ('=', 0) + 1, 00040 linea.size () - linea.find ('=', 0) - 1) ; 00041 eraseSpaces (valuestring) ; 00042 double value = strtod ( valuestring.c_str (), NULL ) ; 00043 m_config [name] = value ; 00044 } while (!input.eof () ) ; 00045 }
void trivialParser::print | ( | std::string | prefix = "" |
) | [private] |
print the read params
Definition at line 74 of file trivialParser.cc.
References TestMuL1L2Filter_cff::cerr, lat::endl(), and m_config.
Referenced by trivialParser().
00075 { 00076 std::cerr << "read parameters: " << std::endl ; 00077 for (std::map<std::string, double>::const_iterator mapIT = m_config.begin () ; 00078 mapIT != m_config.end () ; 00079 ++mapIT) 00080 { 00081 std::cerr << prefix << mapIT->first << " = " << mapIT->second << "\n" ; 00082 } 00083 }
std::map<std::string,double> trivialParser::m_config [private] |