|
Pakman
|
#include <Arguments.h>
Public Member Functions | |
| Arguments (const LongOptions &long_options, int argc, char *argv[]) | |
| ~Arguments ()=default | |
| bool | isOptionalArgumentSet (const std::string &option_name) const |
| std::string | optionalArgument (const std::string &option_name) const |
| int | numberOfPositionalArguments () const |
| std::string | positionalArgument (int index) const |
A class for representing command-line arguments.
An Arguments object takes a LongOptions instance and uses it to parse the command-line arguments, as given by argc and argv. The class uses getopt_long() to parse the command-line arguments.
The optional and positional arguments can then be accessed with the methods optionalArgument() and positionalArgument(), respectively.
Definition at line 20 of file Arguments.h.
| Arguments::Arguments | ( | const LongOptions & | long_options, |
| int | argc, | ||
| char * | argv[] | ||
| ) |
Construct from LongOptions instance, argc and argv.
The constructor uses getopt_long() internally, starting from the current value of optind. After construction, the value of optind is equal to argc.
| long_options | instance of LongOptions to determine valid options. |
| argc | number of command-line arguments. |
| argv | array of command-line arguments. |
Definition at line 9 of file Arguments.cc.
|
default |
Default destructor does nothing.
| bool Arguments::isOptionalArgumentSet | ( | const std::string & | option_name | ) | const |
Check whether optional argument was set.
| option_name | name of optional argument. |
Definition at line 38 of file Arguments.cc.
| int Arguments::numberOfPositionalArguments | ( | ) | const |
Definition at line 51 of file Arguments.cc.
| std::string Arguments::optionalArgument | ( | const std::string & | option_name | ) | const |
Return value of optional argument.
| option_name | name of optional argument. |
Definition at line 45 of file Arguments.cc.
| std::string Arguments::positionalArgument | ( | int | index | ) | const |
Get positional argument from index.
| index | index of positional argument |
Definition at line 57 of file Arguments.cc.