9 #ifndef anna_core_util_CommandLine_hpp 10 #define anna_core_util_CommandLine_hpp 21 class RuntimeException;
36 static int removeLeadingHyphens(std::string &argv) ;
50 const char**
getArgv()
const {
return a_argv; }
73 void initialize(
const char** argv,
const int argc,
int positionalArguments = 0) noexcept(
false);
85 void add(
const char* argumentExpression,
Argument::Type type,
const char* comment,
const bool needValue =
true) ;
95 const char *result = NULL;
96 if ((position > 0) && (position <= a_positionalArguments)) result = a_argv[position];
114 const char* getValue(
const char* argumentExpression,
const bool exitOnFault =
true) ;
124 int getIntegerValue(
const char* argumentExpression) {
return atoi(getValue(argumentExpression)); }
134 bool exists(
const char* argumentExpression) {
return (getValue(argumentExpression,
false) != NULL) ? true :
false; }
149 void verify() noexcept(
false);
156 std::string asString()
const ;
172 Variable(
const std::string &name1,
const std::string &name2,
const Argument::Type type,
const char* comment,
const bool needValue =
true) :
173 a_name1(name1), a_name2(name2), a_type(type), a_comment(comment), a_needValue(needValue), a_isOn(
false), a_value(NULL) {
175 virtual ~Variable() {
if(a_value) free(a_value); }
178 const std::string& getName1()
const {
return a_name1; }
179 const std::string& getName2()
const {
return a_name2; }
180 std::string getHelpExpression()
const ;
181 const char* getValue()
const {
return a_value; }
182 const char* getComment()
const {
return a_comment; }
183 bool getNeedValue()
const {
return a_needValue; }
184 bool getIsOn()
const {
return a_isOn; }
188 void setValue(
const char* value) { a_value = (value == NULL) ? NULL : strdup(value); }
189 void setIsOn(
const bool isOn) { a_isOn = isOn; }
192 std::string asString()
const ;
195 std::string a_name1, a_name2;
197 const char* a_comment;
206 std::vector <Variable*> a_arguments;
207 int a_positionalArguments;
209 CommandLine() : a_argv(NULL), a_argc(0), a_positionalArguments(0) {;}
212 const Variable* search(
const char *argumentExpression)
const ;
213 void printUsage()
const ;
const char * getPositional(int position) const
Definition: CommandLine.hpp:94
Definition: CommandLine.hpp:33
Definition: Singleton.hpp:76
Type
Definition: CommandLine.hpp:43
int getArgc() const
Definition: CommandLine.hpp:55
xml::Node Node
Definition: Node.hpp:21
bool exists(const char *argumentExpression)
Definition: CommandLine.hpp:134
Definition: CommandLine.hpp:43
const char ** getArgv() const
Definition: CommandLine.hpp:50
int getIntegerValue(const char *argumentExpression)
Definition: CommandLine.hpp:124