source: trunk/MagicSoft/Mars/mbase/MArgs.h@ 9492

Last change on this file since 9492 was 9482, checked in by tbretz, 15 years ago
*** empty log message ***
File size: 2.0 KB
Line 
1#ifndef MARS_MArgs
2#define MARS_MArgs
3
4#ifndef ROOT_TNamed
5#include <TNamed.h>
6#endif
7
8#ifndef ROOT_TList
9#include <TList.h>
10#endif
11
12class MArgsEntry : public TString, public TObject
13{
14public:
15 MArgsEntry(const char *c) : TString(c), TObject()
16 {
17 ReplaceAll("\015", "");
18 dynamic_cast<TString&>(*this) = Strip(TString::kBoth);
19 }
20
21 void Print(const Option_t *o) const;
22
23 ClassDef(MArgsEntry, 0)
24};
25
26class MArgs : public TNamed
27{
28private:
29 Int_t fArgc; //!
30 TList fArgv; //!
31
32 MArgsEntry *GetArgument(Int_t i) const;
33 MArgsEntry *GeOption(Int_t i) const;
34
35public:
36 MArgs(int argc, char **argv);
37
38 // TObject
39 void Print(const Option_t *o="") const;
40
41 // FIXME: Add max, min option
42 // FIXME: Add default option
43
44 // MArgs
45 Int_t RemoveRootArgs();
46
47 Int_t GetInt(const TString name) const;
48 Double_t GetFloat(const TString name) const;
49 TString GetString(const TString name) const;
50
51 Int_t GetIntAndRemove(const TString name);
52 Double_t GetFloatAndRemove(const TString name);
53 TString GetStringAndRemove(const TString name);
54
55 Int_t GetIntAndRemove(const TString name, Int_t def);
56 Double_t GetFloatAndRemove(const TString name, Double_t def);
57 TString GetStringAndRemove(const TString name, const TString def);
58
59 Bool_t Has(const TString name) const;
60 Bool_t HasOnly(const TString name) const;
61 Bool_t HasOption(const TString name) const;
62 Bool_t HasOnlyAndRemove(const TString name);
63
64 TString GetArgumentStr(Int_t i) const;
65 Int_t GetArgumentInt(Int_t i) const;
66 Float_t GetArgumentFloat(Int_t i) const;
67 Int_t GetNumArguments() const;
68 Int_t GetNumOptions() const;
69 Int_t GetNumEntries() const;
70
71 Bool_t RemoveArgument(Int_t i);
72
73 TString GetCommandLine() const;
74
75 static TString GetCommandLine(int argc, char **argv) { return MArgs(argc, argv).GetCommandLine(); }
76
77 ClassDef(MArgs, 0) //Class to parse command line arguments
78};
79
80#endif
Note: See TracBrowser for help on using the repository browser.