#include <optparse.h>
Public Types | |
| typedef bool(*) | option_validator (const String &) |
| Callback used to impose constraints on options. | |
| typedef int(*) | generic_callback (int, const String &) |
| Generic callback type. | |
Public Member Functions | |
| int | addOption (const String &p_short, const String &p_long, const String &p_help, int p_flags, option_validator p_validator=NULL) |
| String | asString (const String &p_opt) |
| bool | isSet (const String &p_opt) |
| void | setErrorCallback (generic_callback p_callback) |
| void | setHelpCallback (help_callback p_callback) |
| void | reset () |
Friends | |
| class | Parser |
| int Options::addOption | ( | const String & | p_short, | |
| const String & | p_long, | |||
| const String & | p_help, | |||
| int | p_flags, | |||
| option_validator | p_validator = NULL | |||
| ) |
| p_short | String describing the short form of this option, e.g "-s" | |
| p_long | String describing the long form of this option, e.g. "--start" | |
| p_help | Documentation for this parameter, e.g. "Start the server" | |
| p_flags | Flags for this option | |
| p_validator | Callback used to validate the value of the argument (NULL if no validation required or no argument for this opt) |
E_INVALID if both option strings are empty or the option was given a validator even if not needed
E_OPT_DUPLICATE if there was another option by this name
E_OK if everything went ok
| String Options::asString | ( | const String & | p_opt | ) |
| p_opt | String containing the option whose argument is to be retrieved |
Empty string in case the option is invalid or missing or no argument was found
| bool Options::isSet | ( | const String & | p_opt | ) |
Example: bool b = isOptionSet("-s");
| p_opt | String containing the option to look for. |
false Otherwise
| void Options::setErrorCallback | ( | generic_callback | p_callback | ) |
Sets callback for invalid command line options encountered
| p_callback | Pointer to function to call on invalid opts |
| void Options::setHelpCallback | ( | help_callback | p_callback | ) |
Sets callback for help generation (invoked when encountered) -h or --help. If not set, default will be used
| p_callback | Pointer to function to call on help generation. |
| void Options::reset | ( | ) |
Reset the options object
1.5.1-p1