#include <DbmCmdOptions.h>
Public Member Functions | |
| DbmCmdOptions (const std::string &validOpts="", JobCommand *jcmd=0, const std::list< std::string > *defaultOpts=0) | |
| virtual | ~DbmCmdOptions () |
| void | GetOptIntList (const std::string &opt, std::list< int > &nos) const |
| Int_t | GetOptInt (const std::string &opt) const |
| std::string | GetOptString (const std::string &opt) const |
| std::string | GetOpts () const |
| Bool_t | IsValid () const |
| Bool_t | IsValid (const std::string &opt) const |
| UInt_t | NumOpts () const |
| Bool_t | TestOpt (const std::string &opt) const |
| Bool_t | AddOpt (const std::string &opt, JobCommand &jcmd) |
| Bool_t | AddOpt (const std::string &opt, const std::string &val) |
| Bool_t | ProcessCmd (JobCommand &jcmd, const std::list< std::string > *defaultOpts=0) |
Public Attributes | |
| Bool_t | fIsValid |
| std::string | fValidOpts |
| std::map< std::string, std::string > | fOptsMap |
Definition at line 28 of file DbmCmdOptions.h.
| DbmCmdOptions::DbmCmdOptions | ( | const std::string & | validOpts = "", |
|
| JobCommand * | jcmd = 0, |
|||
| const std::list< std::string > * | defaultOpts = 0 | |||
| ) |
| DbmCmdOptions::~DbmCmdOptions | ( | ) | [virtual] |
Definition at line 87 of file DbmCmdOptions.cxx.
References Msg::kVerbose, LEA_DTOR, and MSG.
00087 { 00088 // 00089 // 00090 // Purpose: Destructor 00091 // 00092 // Arguments: 00093 // None. 00094 // 00095 // Return: n/a 00096 // 00097 // Contact: N. West 00098 // 00099 // Specification:- 00100 // ============= 00101 // 00102 // o Destroy DbmCmdOptions. 00103 00104 00105 // Program Notes:- 00106 // ============= 00107 00108 // None. 00109 00110 LEA_DTOR //Leak Checker 00111 00112 MSG("Dbm", Msg::kVerbose) << "Destroying DbmCmdOptions" << endl; 00113 00114 }
| Bool_t DbmCmdOptions::AddOpt | ( | const std::string & | opt, | |
| const std::string & | val | |||
| ) |
| Bool_t DbmCmdOptions::AddOpt | ( | const std::string & | opt, | |
| JobCommand & | jcmd | |||
| ) |
Referenced by ProcessCmd().
| Int_t DbmCmdOptions::GetOptInt | ( | const std::string & | opt | ) | const |
Referenced by DbmModule::Import(), DbmModule::LogEntry(), and DbmModule::Query().
| void DbmCmdOptions::GetOptIntList | ( | const std::string & | opt, | |
| std::list< int > & | nos | |||
| ) | const |
Definition at line 216 of file DbmCmdOptions.cxx.
References GetOptString(), UtilString::IsInt(), and UtilString::StringTok().
Referenced by DbmModule::ExportTables().
00216 { 00217 // 00218 // 00219 // Purpose: Parse and return a comma separated list. 00220 // 00221 // Arguments: 00222 // opt in The option whose value is the comma separated list. 00223 // nos in The initial list 00224 // out Updated to include the list of numbers. 00225 // If any error, the list will be cleared to zero 00226 // (including anything that pre-existed the call to this function). 00228 // Contact: N. West 00229 // 00230 // Specification:- 00231 // ============= 00232 // 00233 // o Treat option value associated with supplied option as a comma separated 00234 // list of integers and stored them in the supplied list. 00235 00236 string optValue = this->GetOptString(opt); 00237 bool fail = (opt == "no"); 00238 00239 if ( ! fail ) { 00240 std::vector<std::string> ls; 00241 UtilString::StringTok(ls,optValue,","); 00242 if ( ls.size() == 0 ) fail = true; 00243 else { 00244 std::vector<std::string>::iterator itr = ls.begin(); 00245 std::vector<std::string>::iterator itrEnd = ls.end(); 00246 while ( itr != itrEnd ) { 00247 if ( UtilString::IsInt(itr->c_str()) ) nos.push_back(atoi(itr->c_str())); 00248 else fail = true; 00249 ++itr; 00250 } 00251 } 00252 } 00253 00254 if ( fail ) nos.clear(); 00255 00256 }
| string DbmCmdOptions::GetOpts | ( | ) | const |
Definition at line 318 of file DbmCmdOptions.cxx.
References fOptsMap.
Referenced by DbmLogFile::LogCmd().
00318 { 00319 // 00320 // 00321 // Purpose: Return string containing all options. 00322 // 00323 // Arguments: None. 00324 // 00325 // Return: String containing all options. 00326 // 00327 // Contact: N. West 00328 // 00329 // Specification:- 00330 // ============= 00331 // 00332 // o Return string containing all options. 00333 00334 // Program Notes:- 00335 // ============= 00336 00337 // None. 00338 00339 string opts; 00340 for ( map<string,string>::const_iterator itr = fOptsMap.begin(); 00341 itr != fOptsMap.end(); 00342 ++itr ) { 00343 opts += (*itr).first + " " + (*itr).second + " "; 00344 } 00345 return opts; 00346 00347 }
| std::string DbmCmdOptions::GetOptString | ( | const std::string & | opt | ) | const |
| Bool_t DbmCmdOptions::IsValid | ( | const std::string & | opt | ) | const |
| Bool_t DbmCmdOptions::IsValid | ( | ) | const [inline] |
Definition at line 45 of file DbmCmdOptions.h.
References fIsValid.
Referenced by DbmModule::CheckMemory(), DbmModule::ExportTables(), DbmModule::GlobaliseSeqNo(), DbmModule::Import(), DbmModule::LogEntry(), ProcessCmd(), and DbmModule::Query().
00045 { return fIsValid; }
| UInt_t DbmCmdOptions::NumOpts | ( | ) | const [inline] |
Definition at line 47 of file DbmCmdOptions.h.
References fOptsMap.
00047 { return fOptsMap.size(); }
| Bool_t DbmCmdOptions::ProcessCmd | ( | JobCommand & | jcmd, | |
| const std::list< std::string > * | defaultOpts = 0 | |||
| ) |
Definition at line 380 of file DbmCmdOptions.cxx.
References AddOpt(), fIsValid, IsValid(), Msg::kWarning, MSG, option, JobCommand::PopOpt(), and TestOpt().
00381 { 00382 // 00383 // 00384 // Purpose: Process JobCommand storing all options. 00385 // 00386 // Arguments: 00387 // jcmd in JobCommand to be processed. 00388 // out Exhausted JobCommand. 00389 // defaultOpts in Ordered list of default options. 00390 // If none supplied, use --Table --File 00391 // 00392 // Return: 00393 // 00394 // Contact: N. West 00395 // 00396 // Specification:- 00397 // ============= 00398 // 00399 // o Process JobCommand storing all options. 00400 // 00401 // o Supply default options to the first parameters 00402 // i.e. options that do not start "-" and are permitted. 00403 00404 00405 // Program Notes:- 00406 // ============= 00407 00408 // None. 00409 00410 // Provide a default for the default! 00411 std::list<std::string> defDefOPts; 00412 defDefOPts.push_back("--Table"); 00413 defDefOPts.push_back("--File"); 00414 00415 if ( defaultOpts == 0 ) defaultOpts = &defDefOPts; 00416 00417 std::list<std::string>::const_iterator 00418 defOptsItr = defaultOpts->begin(); 00419 std::list<std::string>::const_iterator 00420 defOptsItrEnd = defaultOpts->end(); 00421 00422 const char* opt = jcmd.PopOpt(); 00423 while (opt) { 00424 00425 // Deal with option. 00426 if ( opt[0] == '-' ) { 00427 00428 string option = opt; 00429 AddOpt(opt, jcmd); 00430 } 00431 00432 // Deal with parameter. 00433 else { 00434 00435 // Pick up next default option, if any. 00436 std::string defaultOpt = ""; 00437 if ( defOptsItr != defOptsItrEnd ) { 00438 defaultOpt = *defOptsItr; 00439 ++defOptsItr; 00440 } 00441 00442 // Permit default if defined, not yet used and is valid. 00443 if ( defaultOpt != "" && ! TestOpt(defaultOpt) && IsValid(defaultOpt) 00444 ) AddOpt(defaultOpt, opt); 00445 00446 else { 00447 MSG("Dbm",Msg::kWarning) << "Unknown parameter " << opt << endl; 00448 fIsValid = kFALSE; 00449 } 00450 } 00451 00452 opt = jcmd.PopOpt(); 00453 } // loop over options 00454 00455 return fIsValid; 00456 00457 }
| Bool_t DbmCmdOptions::TestOpt | ( | const std::string & | opt | ) | const |
| Bool_t DbmCmdOptions::fIsValid |
| std::map<std::string,std::string> DbmCmdOptions::fOptsMap |
| std::string DbmCmdOptions::fValidOpts |
Definition at line 60 of file DbmCmdOptions.h.
1.4.7