ANNA Suite
2020b
Multipurpose development suite for Telco applications
|
#include <CommandLine.hpp>
Classes | |
struct | Argument |
Public Member Functions | |
const char ** | getArgv () const |
int | getArgc () const |
void | initialize (const char **argv, const int argc, int positionalArguments=0) noexcept(false) |
void | add (const char *argumentExpression, Argument::Type type, const char *comment, const bool needValue=true) |
const char * | getPositional (int position) const |
const char * | getValue (const char *argumentExpression, const bool exitOnFault=true) |
int | getIntegerValue (const char *argumentExpression) |
bool | exists (const char *argumentExpression) |
void | verify () noexcept(false) |
std::string | asString () const |
xml::Node * | asXML (xml::Node *parent) const |
Friends | |
class | Singleton< CommandLine > |
Additional Inherited Members | |
Static Public Member Functions inherited from anna::Singleton< T > | |
static T & | instantiate () |
static void | release () |
Command line parser helper for our application. It's close to GNU-style, supporting single letter (single hyphen) and long argument names (double hyphen). No bare hyphen or double-dash end of parsing separator are supported. No positional arguments are supported.
void anna::CommandLine::add | ( | const char * | argumentExpression, |
Argument::Type | type, | ||
const char * | comment, | ||
const bool | needValue = true |
||
) |
Register an argument name in our application
argumentExpression | Argument name, or comma-separated set with both short and long argument names. For example 'v,version', 'h,help', or simply 'f' or 'file'. If both, provided, one of them shall be a single letter and the other will be a word. In other case, nothing will be registered. Command line arguments stands for -<single letter="" option>=""> and –<word option>=""> when proceed. If NULL provided, nothing is done. |
type | Argument type. See Variable::Type. |
comment | Argument explanation. |
needValue | If our argument has an additional associated value, this will be true. False in other case (flags). |
std::string anna::CommandLine::asString | ( | ) | const |
Class string representation
Class xml representation
parent | Parent XML node on which hold this instance information. |
|
inline |
Comprueba si el argumento recibido como parametro estña presente en la linea de comandos.
argumentExpression | You should look for the registered expression (add), internally tokenized if needed. |
|
inline |
|
inline |
|
inline |
Obtiene el valor asociado al argumento recibido, pero convirtiendo a numero el valor obtenido por getValue.
argumentExpression | You should look for the registered expression (add), internally tokenized if needed. |
|
inline |
Gets a positional argument. There must be registered or NULL will be returned.
position | Argument position from 1 to N |
const char* anna::CommandLine::getValue | ( | const char * | argumentExpression, |
const bool | exitOnFault = true |
||
) |
Obtiene el valor asociado al argumento recibido como parametro. El valor devuelto puede ser NULL en caso de que el argumento no sea obligatorio y no este en la linea de comandos. Si el argumento es obligatorio y no este en la linea de comandos o no tiene valor asociado la ejecucion del programa TERMINA inmediatamente.
argumentExpression | You should look for the registered expression (add), internally tokenized if needed. |
exitOnFault | Indica el funcionamiento del metodo en caso de que el argumento solicitado no halla sido indicado. Si el parametro no existe si vale true la aplicacion terminara, si vale false devolvera NULL. |
|
noexcept |
Establece la informacion necesaria para analizar la linea de comandos indicada por el usuario. Debe invocarse antes que cualquier otro metodo relacionado con la obtencion/comprobacion de valor de la linea de comandos.
Recibe una copia de los parametros que los recibidos por el metodo 'main'.
argv | Conjunto de cadenas que se reciben de la linea de comandos. |
argc | Numero de cadenas recibidas. |
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. |
|
noexcept |
Comprueba la linea de comandos del programa para verificar que coincide con los argumentos registrados por nuestra aplicacion:
Si hay algun fallo en la linea de comandos establecida al ejecutar el programa visualiza un resumen con los parametros soportados y la ejecucion del programa finaliza.
|
friend |