#include <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 |
This parser is really fragile!!
Definition at line 13 of file trivialParser.h.
trivialParser::trivialParser | ( | std::string | configFile | ) | [explicit] |
ctor
Definition at line 6 of file trivialParser.cc.
References parse(), and print().
{ parse (configFile) ; print ("[ctor] ") ; }
void trivialParser::eraseSpaces | ( | std::string & | word | ) | [private] |
get rid of spaces
Definition at line 90 of file trivialParser.cc.
Referenced by parse().
{ while (word.find (' ',0) != std::string::npos) { word.erase (word.find (' ',0), 1) ; } return ; }
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().
{ // std::cerr << "PG prima cerca " << std::endl ; std::string singleLine ; do { getline (input, singleLine,'\n') ; // std::cerr << "PG guardo " << singleLine << std::endl ; } while (( singleLine.find ('#',0) != std::string::npos || singleLine.find ('=',0) == std::string::npos || singleLine.size () < 3 ) && !input.eof ()) ; // std::cerr << "PG trovato " << singleLine << std::endl ; return singleLine ; }
double trivialParser::getVal | ( | std::string | name | ) |
return the value for that parameter
Definition at line 17 of file trivialParser.cc.
References dtNoiseDBValidation_cfg::cerr, and m_config.
void trivialParser::parse | ( | std::string | configFile | ) | [private] |
parse the cfg file
Definition at line 31 of file trivialParser.cc.
References eraseSpaces(), getNextLine(), collect_tpl::input, m_config, mergeVDriftHistosByStation::name, NULL, and relativeConstraints::value.
Referenced by trivialParser().
{ std::ifstream input (configFile.c_str ()) ; do { std::string linea = getNextLine (input) ; if (linea.empty ()) continue ; std::string name (linea,0,linea.find ('=',0)) ; eraseSpaces (name) ; std::string valuestring (linea,linea.find ('=', 0) + 1, linea.size () - linea.find ('=', 0) - 1) ; eraseSpaces (valuestring) ; double value = strtod ( valuestring.c_str (), NULL ) ; m_config [name] = value ; } while (!input.eof () ) ; }
void trivialParser::print | ( | std::string | prefix = "" | ) | [private] |
print the read params
Definition at line 74 of file trivialParser.cc.
References dtNoiseDBValidation_cfg::cerr, and m_config.
Referenced by trivialParser().
std::map<std::string,double> trivialParser::m_config [private] |
container for the output
Definition at line 25 of file trivialParser.h.