CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
trivialParser Class Reference

#include <trivialParser.h>

Public Member Functions

double getVal (std::string name)
 return the value for that parameter More...
 
 trivialParser (std::string configFile)
 ctor More...
 

Private Member Functions

void eraseSpaces (std::string &word)
 get rid of spaces More...
 
std::string getNextLine (std::ifstream &input)
 returns the next not commented line More...
 
void parse (std::string configFile)
 parse the cfg file More...
 
void print (std::string prefix="")
 print the read params More...
 

Private Attributes

std::map< std::string, double > m_config
 container for the output More...
 

Detailed Description

This parser is really fragile!!

Definition at line 13 of file trivialParser.h.

Constructor & Destructor Documentation

trivialParser::trivialParser ( std::string  configFile)
explicit

ctor

Definition at line 6 of file trivialParser.cc.

References parse(), and print().

7 {
8  parse (configFile) ;
9  print ("[ctor] ") ;
10 }
void print(std::string prefix="")
print the read params
void parse(std::string configFile)
parse the cfg file

Member Function Documentation

void trivialParser::eraseSpaces ( std::string &  word)
private

get rid of spaces

Definition at line 90 of file trivialParser.cc.

References reco::return().

Referenced by parse().

91 {
92  while (word.find (' ',0) != std::string::npos)
93  {
94  word.erase (word.find (' ',0), 1) ;
95  }
96  return ;
97 }
return(e1-e2)*(e1-e2)+dp *dp
std::string trivialParser::getNextLine ( std::ifstream &  input)
private

returns the next not commented line

Definition at line 52 of file trivialParser.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by parse().

53 {
54 // std::cerr << "PG prima cerca " << std::endl ;
55  std::string singleLine ;
56  do {
57  getline (input, singleLine,'\n') ;
58 // std::cerr << "PG guardo " << singleLine << std::endl ;
59  } while ((
60  singleLine.find ('#',0) != std::string::npos ||
61  singleLine.find ('=',0) == std::string::npos ||
62  singleLine.size () < 3
63  ) &&
64  !input.eof ()) ;
65 // std::cerr << "PG trovato " << singleLine << std::endl ;
66  return singleLine ;
67 }
static std::string const input
Definition: EdmProvDump.cc:44
double trivialParser::getVal ( std::string  name)

return the value for that parameter

Definition at line 17 of file trivialParser.cc.

References ecal_dqm_sourceclient-live_cfg::cerr, and m_config.

18 {
19  if (m_config.count (name)) return m_config[name] ;
20  std::cerr << "[trivialParser] no value for "
21  << name
22  << " found\n" ;
23  return -999999. ;
24 }
std::map< std::string, double > m_config
container for the output
Definition: trivialParser.h:25
void trivialParser::parse ( std::string  configFile)
private

parse the cfg file

Definition at line 31 of file trivialParser.cc.

References eraseSpaces(), getNextLine(), input, m_config, mergeVDriftHistosByStation::name, NULL, AlCaHLTBitMon_QueryRunRegistry::string, and relativeConstraints::value.

Referenced by trivialParser().

32 {
33  std::ifstream input (configFile.c_str ()) ;
34  do {
35  std::string linea = getNextLine (input) ;
36  if (linea.empty ()) continue ;
37  std::string name (linea,0,linea.find ('=',0)) ;
38  eraseSpaces (name) ;
39  std::string valuestring (linea,linea.find ('=', 0) + 1,
40  linea.size () - linea.find ('=', 0) - 1) ;
41  eraseSpaces (valuestring) ;
42  double value = strtod ( valuestring.c_str (), NULL ) ;
43  m_config [name] = value ;
44  } while (!input.eof () ) ;
45 }
std::map< std::string, double > m_config
container for the output
Definition: trivialParser.h:25
#define NULL
Definition: scimark2.h:8
static std::string const input
Definition: EdmProvDump.cc:44
std::string getNextLine(std::ifstream &input)
returns the next not commented line
void eraseSpaces(std::string &word)
get rid of spaces
void trivialParser::print ( std::string  prefix = "")
private

print the read params

Definition at line 74 of file trivialParser.cc.

References ecal_dqm_sourceclient-live_cfg::cerr, and m_config.

Referenced by trivialParser().

75 {
76  std::cerr << "read parameters: " << std::endl ;
77  for (std::map<std::string, double>::const_iterator mapIT = m_config.begin () ;
78  mapIT != m_config.end () ;
79  ++mapIT)
80  {
81  std::cerr << prefix << mapIT->first << " = " << mapIT->second << "\n" ;
82  }
83 }
std::map< std::string, double > m_config
container for the output
Definition: trivialParser.h:25

Member Data Documentation

std::map<std::string,double> trivialParser::m_config
private

container for the output

Definition at line 25 of file trivialParser.h.

Referenced by getVal(), parse(), and print().