Changeset 9141 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 10/13/08 15:54:30 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MArgs.cc
r8930 r9141 31 31 // 32 32 // Arguments beginning with a trailing '-' are called 'options'. 33 // 33 34 // Arguments without a trailing '-' are considered 'arguments' 35 // 36 // All arguments appearing after '--' on the commandline are 37 // also cosidered as 'arguments' 34 38 // 35 39 ////////////////////////////////////////////////////////////////////////////// … … 57 61 // fArgv: A TList containing all other command line arguments 58 62 // 59 // If root==kFALSE all root commandline options are deleted from 60 // the list, namely: -b 61 // 62 MArgs::MArgs(int argc, char **argv, Bool_t root) : fArgc(argc) 63 MArgs::MArgs(int argc, char **argv) : fArgc(argc) 63 64 { 64 65 TString cmdline; … … 76 77 fArgv.Add(new MArgsEntry(argv[i])); 77 78 } 78 79 if (root) 80 return; 81 82 HasOnlyAndRemove("-b"); 79 } 80 81 // -------------------------------------------------------------------------- 82 // 83 // Remove all root commandline options from the list, 84 // namely: -b, -n, -q, -l, -?, -h, --help, -config 85 // 86 // Returns the number of found root options (max 8) 87 // 88 Int_t MArgs::RemoveRootArgs() 89 { 90 Int_t n = 0; 91 92 n += HasOnlyAndRemove("-b"); 93 n += HasOnlyAndRemove("-n"); 94 n += HasOnlyAndRemove("-q"); 95 n += HasOnlyAndRemove("-l"); 96 n += HasOnlyAndRemove("-?"); 97 n += HasOnlyAndRemove("-h"); 98 n += HasOnlyAndRemove("--help"); 99 n += HasOnlyAndRemove("-config"); 100 101 return n; 83 102 } 84 103 … … 109 128 TString *s = NULL; 110 129 while ((s=dynamic_cast<TString*>(Next()))) 111 if ( s->BeginsWith("-"))130 if (*s!="--" && s->BeginsWith("-")) 112 131 gLog << *s << endl; 113 132 return; … … 119 138 TString *s = NULL; 120 139 while ((s=dynamic_cast<TString*>(Next()))) 121 if ( !s->BeginsWith("-"))140 if (*s!="--" && !s->BeginsWith("-")) 122 141 gLog << *s << endl; 123 142 return; … … 283 302 Int_t num = 0; 284 303 285 TIter Next(&fArgv); 286 TString *s = NULL; 287 while ((s=dynamic_cast<TString*>(Next()))) 288 { 289 if (s->BeginsWith("-")) 304 Bool_t allarg = kFALSE; 305 306 TIter Next(&fArgv); 307 TString *s = NULL; 308 while ((s=dynamic_cast<TString*>(Next()))) 309 { 310 if (*s=="--") 311 { 312 allarg = kTRUE; 313 continue; 314 } 315 316 if (s->BeginsWith("-") && !allarg) 290 317 continue; 291 318 … … 305 332 Int_t num = 0; 306 333 307 TIter Next(&fArgv); 308 TString *s = NULL; 309 while ((s=dynamic_cast<TString*>(Next()))) 310 if (!s->BeginsWith("-")) 311 num++; 334 Bool_t allarg = kFALSE; 335 336 TIter Next(&fArgv); 337 TString *s = NULL; 338 while ((s=dynamic_cast<TString*>(Next()))) 339 { 340 if (*s=="--") 341 { 342 allarg = kTRUE; 343 continue; 344 } 345 346 if (s->BeginsWith("-") && !allarg) 347 continue; 348 349 num++; 350 } 312 351 313 352 return num; … … 325 364 TString *s = NULL; 326 365 while ((s=dynamic_cast<TString*>(Next()))) 366 { 367 if (*s=="--") 368 return num; 369 327 370 if (s->BeginsWith("-")) 328 371 num++; 372 } 329 373 330 374 return num; … … 337 381 Int_t MArgs::GetNumEntries() const 338 382 { 339 return fArgv. GetSize();383 return fArgv.FindObject("--") ? fArgv.GetSize()-1 : fArgv.GetSize(); 340 384 } 341 385 -
trunk/MagicSoft/Mars/mbase/MArgs.h
r8930 r9141 31 31 32 32 public: 33 MArgs(int argc, char **argv , Bool_t root=kFALSE);33 MArgs(int argc, char **argv); 34 34 35 35 // TObject … … 40 40 41 41 // MArgs 42 Int_t RemoveRootArgs(); 43 42 44 Int_t GetInt(const TString name) const; 43 45 Double_t GetFloat(const TString name) const;
Note:
See TracChangeset
for help on using the changeset viewer.