C++ main module for emicrom 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 {
19 
20  // ATTRIBUTES
21 
22 private:
23 
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  tInteger& 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  tInt& attValue) const {
121  tString value="";
122  tBoolean succeeds=readOption(options,attName,value);
123  attValue=CORE_Integer::parseInt(value);
124  return succeeds;
125  };
130  inline tBoolean readOption(const tString& options,
131  const tString& attName,
132  tFlag& attValue) const {
133  tString value="";
134  tBoolean succeeds=readOption(options,attName,value);
135  attValue=(tFlag) CORE_Integer::parseInt(value);
136  return succeeds;
137  };
142  inline tBoolean readOption(const tString& options,
143  const tString& attName,
144  tReal& attValue) const {
145  tString value;
146  tBoolean succeeds=readOption(options,attName,value);
147  attValue=CORE_Real::parseReal(value);
148  return succeeds;
149  };
154  inline tBoolean readOption(const tString& options,
155  const tString& attName,
156  tBoolean& attValue) const {
157  tString value;
158  tBoolean succeeds=readOption(options,attName,value);
159  attValue=CORE_String::string2Boolean(value);
160  return succeeds;
161  };
162 
165  tBoolean readArgument(const tString& options,
166  const tInteger& n,
167  tString& value) const;
170  inline tBoolean readFirstArgument(const tString& options,
171  tString& value) const {
172  return readArgument(options,1,value);
173  };
174 
175 
176 
177 
178 
179 };
180 
181 
182 #endif
static tLLInt parseInt(const tString &str)
return the integer associated to the string
Definition: CORE_Integer.cpp:102
DEFINE_SPTR(CORE_CommandLine)
void setProgramName(const tString &name)
set program name
Definition: CORE_CommandLine.h:65
virtual tString help(const tString &path, const tString &options, tBoolean &succeeds) const
return the help result command
Definition: CORE_CommandLine.cpp:87
static tBoolean string2Boolean(const tString &c)
return the booleazn corresponding to string
Definition: CORE_String.h:470
tBoolean readArgument(const tString &options, const tInteger &n, tString &value) const
read first value after command
Definition: CORE_CommandLine.cpp:14
virtual tString interpretCommandLine(const tString &path, const tString &command, const tString &options, tBoolean &succeeds) const
interprete the command line
Definition: CORE_CommandLine.cpp:109
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:130
static tLDouble parseReal(const tString &str)
return the real associated to the string
Definition: CORE_Real.h:201
SP_OBJECT(CORE_CommandLine)
tString getProgramName() const
get program name
Definition: CORE_CommandLine.h:71
tBoolean readOption(const tString &options, const tString &attName, tInteger &attValue) const
read option attName and return the value of the options in attValue
Definition: CORE_CommandLine.h:106
#define tBoolean
Definition: types.h:139
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
tString mProgram
Definition: CORE_CommandLine.h:24
tBoolean readOption(const tString &options, const tString &attName, tInt &attValue) const
read option attName and return the value of the options in attValue
Definition: CORE_CommandLine.h:118
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:142
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:154
virtual ~CORE_CommandLine(void)
destroy an object.
Definition: CORE_CommandLine.cpp:11
tBoolean readFirstArgument(const tString &options, tString &value) const
read first value after command
Definition: CORE_CommandLine.h:170
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
abstract base class for most classes.
Definition: CORE_Object.h:53
#define tString
Definition: types.h:135
CORE_CommandLine(void)
create an object
Definition: CORE_CommandLine.cpp:5
#define tInt
Definition: types.h:35
#define tReal
Definition: types.h:118
#define tInteger
Definition: types.h:90
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141
#define tFlag
Definition: types.h:74