clockUtils
1.1
|
Namespaces | |
clockUtils | |
Macros | |
#define | CLOCK_ARGPARSER_API |
#define | PARSE_ARGUMENTS(buffer, length) |
parses given list with given length use this method without filename More... | |
#define | PARSE_COMMANDLINE() |
parses command line Use this to parse the normal command line in the main function. It is identical to PARSE_ARGUMENTS(++argv, –argc) More... | |
#define | GETLASTPARSERERROR() |
returns the last error message if some appeared More... | |
#define | REGISTER_VARIABLE_INTERNAL(type, longname, shortname, value, description, required, multiple) |
registers a variable with a type, the variable and argument name, a default value and a description text for –help longname is also the variable name, shortname can be set to "" for no shortname variable will be initialized with default value right away More... | |
#define | REGISTER_VARIABLE(type, longname, shortname, value, description) |
registers a variable with a type, the variable and argument name, a default value and a description text for –help being optional longname is also the variable name, shortname can be set to "" for no shortname variable will be initialized with default value right away More... | |
#define | REGISTER_VARIABLE_REQUIRED(type, longname, shortname, value, description) |
registers a variable with a type, the variable and argument name, a default value and a description text for –help being required longname is also the variable name, shortname can be set to "" for no shortname variable will be initialized with default value right away if this variable isn't set, ClockError::INVALID_USAGE is returned More... | |
#define | REGISTER_VARIABLE_MULTIPLE(type, longname, shortname, value, description) |
registers a variable with a type, the variable and argument name, a default value and a description text for –help longname is also the variable name, shortname can be set to "" for no shortname variable will be initialized with default value right away this variable can be set multiple times, so the registered variable is a list More... | |
#define | REGISTER_VARIABLE_MULTIPLE_REQUIRED(type, longname, shortname, value, description) |
registers a variable with a type, the variable and argument name, a default value and a description text for –help being required longname is also the variable name, shortname can be set to "" for no shortname variable will be initialized with default value right away this variable can be set multiple times, so the registered variable is a list if this variable isn't set, ClockError::INVALID_USAGE is returned More... | |
#define | REGISTER_VARIABLE_ARGUMENTS(name) |
registers a variable where the arguments at the end are parsed into More... | |
#define | HELPSET() |
returns true if –help was set More... | |
#define | GETHELPTEXT() |
returns the help text More... | |
The Argument Parser can be used to easily parse lists of strings for commands and values
The first line will give you a std::string variable with the name myStr being initialized with "english". The two possibilities in a command line to change this variable are:
The boolean option can be change by passing "true" or "false" as the value. Additionally for the case of bool, only the name is sufficient to set it to true.
The second step is to parse your list. Therefor, two macros exist:
PARSE_COMMANDLINE() parses the arguments of the main method implicitly assuming (argc and argv)
PARSE_ARGUMENTS(buffer, length) parses an own list
Two options are automatically available for a help output.
The macro HELPSET() says whether the help optioon was given and the text output can be retrieved using GETHELPTEXT()
Example Usage:
In some cases you want to ignore additional entries at the end of the commandline or you want to support more than one parameter e.g. multiple files. Therefore you can register a std::vector<std::string> using REGISTER_VARIABLE_ARGUMENTS(name) where name is the name of the variable. All additional entries are pushed into this vector.
Example:
When executing the program as follows ...
... the files vector contains three values.
#define CLOCK_ARGPARSER_API |
Definition at line 41 of file argParserParameters.h.
#define GETHELPTEXT | ( | ) |
returns the help text
Definition at line 137 of file ArgumentParser.h.
#define GETLASTPARSERERROR | ( | ) |
returns the last error message if some appeared
Definition at line 54 of file ArgumentParser.h.
#define HELPSET | ( | ) |
returns true if –help was set
Definition at line 131 of file ArgumentParser.h.
#define PARSE_ARGUMENTS | ( | buffer, | |
length | |||
) |
parses given list with given length use this method without filename
Definition at line 40 of file ArgumentParser.h.
#define PARSE_COMMANDLINE | ( | ) |
parses command line Use this to parse the normal command line in the main function. It is identical to PARSE_ARGUMENTS(++argv, –argc)
Definition at line 48 of file ArgumentParser.h.
#define REGISTER_VARIABLE | ( | type, | |
longname, | |||
shortname, | |||
value, | |||
description | |||
) |
registers a variable with a type, the variable and argument name, a default value and a description text for –help being optional longname is also the variable name, shortname can be set to "" for no shortname variable will be initialized with default value right away
Definition at line 92 of file ArgumentParser.h.
#define REGISTER_VARIABLE_ARGUMENTS | ( | name | ) |
registers a variable where the arguments at the end are parsed into
Definition at line 125 of file ArgumentParser.h.
#define REGISTER_VARIABLE_INTERNAL | ( | type, | |
longname, | |||
shortname, | |||
value, | |||
description, | |||
required, | |||
multiple | |||
) |
registers a variable with a type, the variable and argument name, a default value and a description text for –help longname is also the variable name, shortname can be set to "" for no shortname variable will be initialized with default value right away
Definition at line 63 of file ArgumentParser.h.
#define REGISTER_VARIABLE_MULTIPLE | ( | type, | |
longname, | |||
shortname, | |||
value, | |||
description | |||
) |
registers a variable with a type, the variable and argument name, a default value and a description text for –help longname is also the variable name, shortname can be set to "" for no shortname variable will be initialized with default value right away this variable can be set multiple times, so the registered variable is a list
Definition at line 110 of file ArgumentParser.h.
#define REGISTER_VARIABLE_MULTIPLE_REQUIRED | ( | type, | |
longname, | |||
shortname, | |||
value, | |||
description | |||
) |
registers a variable with a type, the variable and argument name, a default value and a description text for –help being required longname is also the variable name, shortname can be set to "" for no shortname variable will be initialized with default value right away this variable can be set multiple times, so the registered variable is a list if this variable isn't set, ClockError::INVALID_USAGE is returned
Definition at line 120 of file ArgumentParser.h.
#define REGISTER_VARIABLE_REQUIRED | ( | type, | |
longname, | |||
shortname, | |||
value, | |||
description | |||
) |
registers a variable with a type, the variable and argument name, a default value and a description text for –help being required longname is also the variable name, shortname can be set to "" for no shortname variable will be initialized with default value right away if this variable isn't set, ClockError::INVALID_USAGE is returned
Definition at line 101 of file ArgumentParser.h.