@param argv Conjunto de cadenas que se reciben de la linea de comandos.
@param argc Numero de cadenas recibidas.
+ @param positionalArguments Enables positional arguments. An offset will be applied to start command-line interpretation.
+ These positional arguments are mandatory, and the user could retrieve their values through #getPositional. By default no
+ positional arguments are specified.
*/
- void initialize(const char** argv, const int argc) throw() {
- a_argv = argv;
- a_argc = argc;
- a_wasParsed = false;
- }
+ void initialize(const char** argv, const int argc, int positionalArguments = 0) throw(RuntimeException);
/**
Register an argument name in our application
*/
void add(const char* argumentExpression, Argument::Type type, const char* comment, const bool needValue = true) throw();
+ /**
+ Gets a positional argument. There must be registered or NULL will be returned.
+
+ @param position Argument position from 1 to N
+
+ @return Value of mandatory positional argument with position provided
+ */
+ const char *getPositional(int position) const throw() {
+ const char *result = NULL;
+ if ((position > 0) && (position <= a_positionalArguments)) result = a_argv[position];
+ return result;
+ }
+
/**
Obtiene el valor asociado al argumento recibido como parametro.
El valor devuelto puede ser NULL en caso de que el argumento no sea
int a_argc;
bool a_wasParsed;
std::vector <Variable*> a_arguments;
+ int a_positionalArguments;
- CommandLine() : a_argv(NULL), a_argc(0) {;}
+ CommandLine() : a_argv(NULL), a_argc(0), a_positionalArguments(0) {;}
bool analize() throw();
const Variable* search(const char *argumentExpression) const throw();