CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
Args Class Reference

Public Member Functions

 Args ()
 
std::vector< std::string > arguments () const
 
std::string command () const
 
void defineOption (const std::string &fOption, const std::string &fComment="")
 
void defineParameter (const std::string &fParameter, const std::string &fComment="")
 
std::string getParameter (const std::string &fKey)
 
bool optionIsSet (const std::string &fOption) const
 
void parse (int nArgs, char *fArgs[])
 
void printOptionsHelp () const
 
 ~Args ()
 

Private Attributes

std::vector< std::string > mArgs
 
std::map< std::string, std::string > mComments
 
std::vector< std::string > mOptions
 
std::vector< std::string > mParameters
 
std::map< std::string, std::string > mParsed
 
std::string mProgramName
 

Detailed Description

Definition at line 31 of file hcalPublishConditions.cc.

Constructor & Destructor Documentation

Args::Args ( )
inline

Definition at line 33 of file hcalPublishConditions.cc.

33 {};
Args::~Args ( )
inline

Member Function Documentation

std::vector< std::string > Args::arguments ( ) const

Definition at line 181 of file hcalInitDb.cc.

References arguments(), and mArgs.

Referenced by arguments(), and ~Args().

181 {return mArgs;}
std::vector< std::string > mArgs
std::string Args::command ( ) const

Definition at line 176 of file hcalInitDb.cc.

References mProgramName, and AlCaHLTBitMon_QueryRunRegistry::string.

176  {
177  int ipos = mProgramName.rfind ('/');
178  return std::string (mProgramName, ipos+1);
179 }
std::string mProgramName
void Args::defineOption ( const std::string &  fOption,
const std::string &  fComment = "" 
)

Definition at line 125 of file hcalInitDb.cc.

References defineOption(), mComments, and mOptions.

Referenced by defineOption(), and ~Args().

125  {
126  mOptions.push_back (fOption);
127  mComments [fOption] = fComment;
128 }
std::vector< std::string > mOptions
std::map< std::string, std::string > mComments
void Args::defineParameter ( const std::string &  fParameter,
const std::string &  fComment = "" 
)

Definition at line 130 of file hcalInitDb.cc.

References defineParameter(), mComments, and mParameters.

Referenced by defineParameter(), and ~Args().

130  {
131  mParameters.push_back (fParameter);
132  mComments [fParameter] = fComment;
133 }
std::vector< std::string > mParameters
std::map< std::string, std::string > mComments
std::string Args::getParameter ( const std::string &  fKey)

Definition at line 187 of file hcalInitDb.cc.

References getParameter(), mParsed, and optionIsSet().

Referenced by getParameter(), Mixins._Parameterizable::hasParameter(), and ~Args().

187  {
188  if (optionIsSet (fKey)) return mParsed [fKey];
189  return "";
190 }
std::map< std::string, std::string > mParsed
bool Args::optionIsSet ( const std::string &  fOption) const

Definition at line 183 of file hcalInitDb.cc.

References mParsed, and optionIsSet().

Referenced by getParameter(), optionIsSet(), and ~Args().

183  {
184  return mParsed.find (fOption) != mParsed.end ();
185 }
std::map< std::string, std::string > mParsed
void Args::parse ( int  nArgs,
char *  fArgs[] 
)

Definition at line 135 of file hcalInitDb.cc.

References MessageLogger_cfi::cerr, spr::find(), mArgs, mOptions, mParameters, mParsed, mProgramName, and AlCaHLTBitMon_QueryRunRegistry::string.

135  {
136  if (nArgs <= 0) return;
137  mProgramName = std::string (fArgs [0]);
138  int iarg = 0;
139  while (++iarg < nArgs) {
140  std::string arg (fArgs [iarg]);
141  if (arg [0] != '-') mArgs.push_back (arg);
142  else {
143  if (std::find (mOptions.begin(), mOptions.end (), arg) != mOptions.end ()) {
144  mParsed [arg] = "";
145  }
146  if (std::find (mParameters.begin(), mParameters.end (), arg) != mParameters.end ()) {
147  if (iarg >= nArgs) {
148  std::cerr << "ERROR: Parameter " << arg << " has no value specified. Ignore parameter." << std::endl;
149  }
150  else {
151  mParsed [arg] = std::string (fArgs [++iarg]);
152  }
153  }
154  }
155  }
156 }
std::string mProgramName
std::map< std::string, std::string > mParsed
std::vector< std::string > mParameters
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< std::string > mArgs
A arg
Definition: Factorize.h:38
std::vector< std::string > mOptions
void Args::printOptionsHelp ( ) const

Definition at line 158 of file hcalInitDb.cc.

References comment, gather_cfg::cout, mps_fire::i, mComments, mOptions, mParameters, printOptionsHelp(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by printOptionsHelp(), and ~Args().

158  {
159  char buffer [1024];
160  std::cout << "Parameters:" << std::endl;
161  for (unsigned i = 0; i < mParameters.size (); i++) {
162  std::map<std::string, std::string>::const_iterator it = mComments.find (mParameters [i]);
163  std::string comment = it != mComments.end () ? it->second : "uncommented";
164  sprintf (buffer, " %-8s <value> : %s", (mParameters [i]).c_str(), comment.c_str());
165  std::cout << buffer << std::endl;
166  }
167  std::cout << "Options:" << std::endl;
168  for (unsigned i = 0; i < mOptions.size (); i++) {
169  std::map<std::string, std::string>::const_iterator it = mComments.find (mOptions [i]);
170  std::string comment = it != mComments.end () ? it->second : "uncommented";
171  sprintf (buffer, " %-8s : %s", (mOptions [i]).c_str(), comment.c_str());
172  std::cout << buffer << std::endl;
173  }
174 }
std::vector< std::string > mParameters
std::vector< std::string > mOptions
std::map< std::string, std::string > mComments
#define comment(par)
Definition: vmac.h:163

Member Data Documentation

std::vector<std::string> Args::mArgs
private

Definition at line 47 of file hcalPublishConditions.cc.

Referenced by arguments(), and parse().

std::map<std::string, std::string> Args::mComments
private

Definition at line 49 of file hcalPublishConditions.cc.

Referenced by defineOption(), defineParameter(), and printOptionsHelp().

std::vector<std::string> Args::mOptions
private

Definition at line 45 of file hcalPublishConditions.cc.

Referenced by defineOption(), parse(), and printOptionsHelp().

std::vector<std::string> Args::mParameters
private

Definition at line 46 of file hcalPublishConditions.cc.

Referenced by defineParameter(), parse(), and printOptionsHelp().

std::map<std::string, std::string> Args::mParsed
private

Definition at line 48 of file hcalPublishConditions.cc.

Referenced by getParameter(), optionIsSet(), and parse().

std::string Args::mProgramName
private

Definition at line 44 of file hcalPublishConditions.cc.

Referenced by command(), and parse().