Command line parser. More...
#include <Valuable/CmdParser.hpp>
Public Member Functions | |
| bool | isParsed (const QString &name) |
| Query the CmdParser if a certain command line parameter has been parsed. More... | |
| QStringList | parseAndStore (int &argc, char *argv[], Valuable::Node &opts) |
| Parses command line arguments to given Node object. More... | |
| QStringList | parseAndStore (const QStringList &argv, Valuable::Node &opts) |
Static Public Member Functions | |
| static QStringList | parse (int &argc, char *argv[], Valuable::Node &opts) |
| Parses command line arguments to given Node object. More... | |
| static QStringList | parse (const QStringList &argv, Valuable::Node &opts) |
Command line parser.
| bool Valuable::CmdParser::isParsed | ( | const QString & | name | ) |
Query the CmdParser if a certain command line parameter has been parsed.
| name | The name of the parameter to query |
Example:
|
static |
Parses command line arguments to given Node object.
| argc | Number of arguments in argv |
| argv | Array of arguments |
| opts | The target object where the Attributes are stored |
If there is a Attribute named "foo" in opts, it can be set in command line like this: –foo param where param will be parsed with deserialize().
If the Attribute name is only one letter, then the parser also recognizes the command like argument that begins with one dash, like -o dir
Boolean arguments (AttributeBool objects) don't use distinct parameter, but they will be switched on by –name and off by –no-name.
String lists are separated by semicolon (;) that can be escaped with backslash: –css style1.css;style2.css
Example:
Example input: -v –limit 12 –no-recursive –target out file1.txt file2.txt
| QStringList Valuable::CmdParser::parseAndStore | ( | int & | argc, |
| char * | argv[], | ||
| Valuable::Node & | opts | ||
| ) |
Parses command line arguments to given Node object.
| argc | Number of arguments in argv |
| argv | Array of arguments |
| opts | The target object where the Attributes are stored |
This is the non-static version of the parse function. This version stores all parsed command line arguments in an internal set, which can be queried by the is_parsed function.