#include <cmdline_parser.hh>
Collaboration diagram for CmdLineParser:
Public Methods | |
CmdLineParser (const string &progName_, PropRegistry &pr_) | |
int | parse (int argc, char *argv[]) throw (CmdLineParseException) |
void | printUsage (ostream &os) |
Specifying command line syntax | |
The methods add a new atom description into the parser's table and return a ref to the parser object in order to allow chained insertions (something like: clParaser.add(atom1).add(atom2).add(...); ). | |
CmdLineParser& | add (const CmdLineAtom &atom) |
CmdLineParser& | add (const string &tag, bool multi, bool optional, const string &sOpt, const string &lOpt, const string &prop, const string &description) |
Private Types | |
typedef struct CmdLineParser::t_CmdLineAtom | CmdLineAtom |
Private Attributes | |
PropRegistry& | pr |
vector<CmdLineAtom> | desc |
string | progName |
Definition at line 98 of file cmdline_parser.hh.
|
A command line atom (or "option" ) is something like "-c" or "-o foo" or "--enable-things". Each atom can contain one or more arguments. furthermore, the same atom can appear more than once. The multi field tells how multiple occurence should be handled. If it is false, each occurence will override the previous one. If true, the argument from each occurence is appended to the property that corresponds to that atom. The tag field (corresponding to the tag field used into the Propregistry) means:
If the optional field is true, the optino is, well, optional :) The description string is a text that indicates the meaning of the option, from the user's point of view. It is used when dumping the command line synopsys. The prop string is the key of the property that will receive the value(s) of the option. Referenced by add().
|
|
Creates a new CmdLineParser that will parse a command line that obeys the given format string and will store the corersponding properties into the given property registry. Definition at line 186 of file cmdline_parser.hh. |
|
Parses the given command line and stores all the properties into the registry. The parsing stops at the first non-option argument (i.e. not starting with - or --).
Definition at line 100 of file cmdline_parser.cc. Referenced by main().
|
|
Definition at line 212 of file cmdline_parser.hh. Referenced by add(), and main().
|
|
Definition at line 218 of file cmdline_parser.hh. |
|
Definition at line 196 of file cmdline_parser.cc. Referenced by main().
|
|
The registry where the parsed roperties will be stored by parse. Definition at line 234 of file cmdline_parser.hh. |
|
The desription of the cmd line. Definition at line 239 of file cmdline_parser.hh. |
|
The name of the executable. Definition at line 244 of file cmdline_parser.hh. |