C++ main module for gpm Package  1.0
CORE_CommandLine.h
Go to the documentation of this file.
1 #ifndef CORE_CommandLine_H
2 #define CORE_CommandLine_H
3 
4 #include "CORE_CommandLine.h"
5 #include "CORE_Object.h"
6 
7 #include "CORE_Integer.h"
8 #include "CORE_Real.h"
9 #include "CORE_String.h"
10 
17 class CORE_CommandLine : public CORE_Object {
18  SP_OBJECT(CORE_CommandLine);
19 
20  // ATTRIBUTES
21 
22  private:
23 
24  tString mProgram;
25 
26 
27  // ASSOCIATIONS
28 
29 
30  protected:
31  // METHODS
32 
33  // CONSTRUCTORS
34 
36  CORE_CommandLine(void);
37 
38 
39 
40  // DESTRUCTORS
41 
42 
45  virtual ~CORE_CommandLine(void);
46 
47 
48 
49  public:
50 
51  // NEW
54  inline static SP::CORE_CommandLine New() {
55  SP::CORE_CommandLine p(new CORE_CommandLine(),
57  p->setThis(p);
58  return p;
59  };
60 
61  // SET methods
62 
65  inline void setProgramName(const tString& name) {
66  mProgram=name;
67  };
68  // OTHERS methods
71  inline tString getProgramName() const {
72  return mProgram;
73  };
74 
81  virtual tString interpretCommandLine(const tString& path,
82  const tString& command,
83  const tString& options,
84  tBoolean& succeeds) const;
85 
86  protected:
89  virtual tString help(const tString& path,
90  const tString& options,
91  tBoolean& succeeds) const;
92 
93  public:
98  tBoolean readOption(const tString& options,
99  const tString& attName,
100  tString& attValue) const;
101 
106  inline tBoolean readOption(const tString& options,
107  const tString& attName,
108  int& attValue) const {
109  tString value="";
110  tBoolean succeeds=readOption(options,attName,value);
111  attValue=CORE_Integer::parseInt(value);
112  return succeeds;
113  };
118  inline tBoolean readOption(const tString& options,
119  const tString& attName,
120  tFlag& attValue) const {
121  tString value="";
122  tBoolean succeeds=readOption(options,attName,value);
123  attValue=(tFlag) CORE_Integer::parseInt(value);
124  return succeeds;
125  };
130  inline tBoolean readOption(const tString& options,
131  const tString& attName,
132  tReal& attValue) const {
133  tString value;
134  tBoolean succeeds=readOption(options,attName,value);
135  attValue=CORE_Real::parseReal(value);
136  return succeeds;
137  };
142  inline tBoolean readOption(const tString& options,
143  const tString& attName,
144  tBoolean& attValue) const {
145  tString value;
146  tBoolean succeeds=readOption(options,attName,value);
147  attValue=CORE_String::string2Boolean(value);
148  return succeeds;
149  };
150 
153  tBoolean readArgument(const tString& options,
154  const int& n,
155  tString& value) const;
158  inline tBoolean readFirstArgument(const tString& options,
159  tString& value) const {
160  return readArgument(options,1,value);
161  };
162 
163 
164 
165 
166 
167 };
168 
169 
170 #endif
DEFINE_SPTR(CORE_CommandLine)
void setProgramName(const tString &name)
set program name
Definition: CORE_CommandLine.h:65
tBoolean readOption(const tString &options, const tString &attName, tString &attValue) const
read option attName and return the value of the options in attValue
Definition: CORE_CommandLine.cpp:54
static long int parseInt(tString str)
return the integer associated to the string
Definition: CORE_Integer.cpp:120
static tBoolean string2Boolean(const tString &c)
return the booleazn corresponding to string
Definition: CORE_String.h:376
tBoolean readOption(const tString &options, const tString &attName, tFlag &attValue) const
read option attName and return the value of the options in attValue
Definition: CORE_CommandLine.h:118
#define tBoolean
Definition: types.h:35
static SP::CORE_CommandLine New()
return a New shared pointer associated to CORE_CommandLine class
Definition: CORE_CommandLine.h:54
This class is the class to manage CORE from command line.
Definition: CORE_CommandLine.h:17
tBoolean readArgument(const tString &options, const int &n, tString &value) const
read first value after command
Definition: CORE_CommandLine.cpp:15
virtual ~CORE_CommandLine(void)
destroy an object.
Definition: CORE_CommandLine.cpp:12
tString getProgramName() const
get program name
Definition: CORE_CommandLine.h:71
virtual tString interpretCommandLine(const tString &path, const tString &command, const tString &options, tBoolean &succeeds) const
interprete the command line
Definition: CORE_CommandLine.cpp:109
abstract base class for most classes.
Definition: CORE_Object.h:30
tBoolean readOption(const tString &options, const tString &attName, int &attValue) const
read option attName and return the value of the options in attValue
Definition: CORE_CommandLine.h:106
#define tString
Definition: types.h:36
static long double parseReal(const tString &str)
return the real associated to the string
Definition: CORE_Real.cpp:78
tBoolean readOption(const tString &options, const tString &attName, tBoolean &attValue) const
read option attName and return the value of the options in attValue
Definition: CORE_CommandLine.h:142
CORE_CommandLine(void)
create an object
Definition: CORE_CommandLine.cpp:5
tBoolean readFirstArgument(const tString &options, tString &value) const
read first value after command
Definition: CORE_CommandLine.h:158
#define tReal
Definition: types.h:18
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14
virtual tString help(const tString &path, const tString &options, tBoolean &succeeds) const
return the help result command
Definition: CORE_CommandLine.cpp:87
tBoolean readOption(const tString &options, const tString &attName, tReal &attValue) const
read option attName and return the value of the options in attValue
Definition: CORE_CommandLine.h:130