Gromacs
2016.6
|
#include <gromacs/commandline/cmdlineparser.h>
Implements command-line parsing for Options objects.
Typical usage (without error checking):
Classes | |
class | Impl |
Private implementation class for CommandLineParser. More... | |
Public Member Functions | |
CommandLineParser (Options *options) | |
Creates a command-line parser that sets values for options. More... | |
CommandLineParser & | skipUnknown (bool bEnabled) |
Makes the parser skip unknown options and keep them in argv . More... | |
void | parse (int *argc, char *argv[]) |
Parses the command line. More... | |
|
explicit |
Creates a command-line parser that sets values for options.
[in] | options | Options object whose options should be set. |
std::bad_alloc | if out of memory. |
void gmx::CommandLineParser::parse | ( | int * | argc, |
char * | argv[] | ||
) |
Parses the command line.
std::bad_alloc | if out of memory. |
InvalidInputError | if any errors were detected in the input. |
All command-line arguments are parsed, and an aggregate exception with all the detected errors is thrown in the end.
If skipUnknown() is false, the input parameters are not modified. If skipUnknown() is true, recognized options and their values are removed from the argument list. argv
[0] is never modified.
CommandLineParser & gmx::CommandLineParser::skipUnknown | ( | bool | bEnabled | ) |
Makes the parser skip unknown options and keep them in argv
.
[in] | bEnabled | Whether to skip and keep unknown options. |
Setting this option to true has dual effect: unknown options are silently skipped, and all recognized options are removed from argc
and argv
in parse(). These effects should be easy to separate into different flags if there is need for it.
The default is false: unknown options result in exceptions and argc
and argv
are not modified.
Does not throw.