Class to encapsulate command line options and parse them. More...
#include <DwmOptArgs.hh>
Public Member Functions | |
| void | AddOptArg (const OptArg &optarg) |
| Adds an optional argument. | |
| void | AddOptArg (const std::string &name, const std::string &longName, bool isRequired=false, const std::string &def="", const std::string &help="") |
| Adds an optional argument. | |
| void | AddNormalArg (const std::string &name, bool required) |
| template<typename T > | |
| T | Get (int c) |
| Fetches the value of an optional argument by its short name. | |
| template<typename T > | |
| T | Get (const std::string &s) |
| Fetches the value of an optional argument by its long name. | |
| int | Parse (int argc, const std::string argv[]) |
| Parses all optional arguments. | |
| int | Parse (int argc, char *argv[]) |
| Parses all optional arguments. | |
| void | Usage (const std::string &argv0) const |
| Prints the usage statement. | |
Protected Attributes | |
| std::map< int, OptArg > | _args |
| std::map< std::string, OptArg * > | _longArgs |
| std::vector< std::pair< std::string, bool > > | _normalArgs |
Class to encapsulate command line options and parse them.
| int Dwm::OptArgs::Parse | ( | int | argc, |
| char * | argv[] ) |
Parses all optional arguments.
Returns the next argument index, which the caller should compare against argc. If parsing fails, will emit a usage statement and exit.
| int Dwm::OptArgs::Parse | ( | int | argc, |
| const std::string | argv[] ) |
Parses all optional arguments.
Returns the next argument index, which the caller should compare against argc. If parsing fails, will emit a usage statement and exit.