|
Jpp
|
Utility class to parse command line options. More...
#include <JParser.hh>
Public Types | |
| typedef JLANG::JParserException | JParserException |
| typedef JKey_t | key_type |
| typedef std::map< key_type, JParserElement > | map_type |
| typedef map_type::iterator | iterator |
| typedef map_type::const_iterator | const_iterator |
Public Member Functions | |
| JParser (const int debug=0) | |
| Default constructor. More... | |
| JParser (const std::string &message, const int debug=0) | |
| Constructor. More... | |
| void | print (std::ostream &out) const |
| Print the possible command line options. More... | |
| JArgs | operator() (const int argc, const char *const argv[]) |
| Parse the program's command line options. More... | |
| JArgs | operator() (const JArgs &args) |
| Parse the program's command line options. More... | |
| int | read (const int argc, const char *const argv[]) |
| Parse the program's command line options. More... | |
| int | read (const JArgs &args) |
| Parse the program's command line options. More... | |
| std::ostream & | write (std::ostream &out) const |
| Print the current parameter values. More... | |
Static Public Attributes | |
| static int | debug = 0 |
| debug level (default is off). More... | |
Protected Member Functions | |
| void | check_status () const |
| Check if all required options have been set. More... | |
Protected Attributes | |
| std::string | help |
| help message More... | |
| std::string | pid |
| process name More... | |
Friends | |
| std::ostream & | operator<< (std::ostream &out, const JParser< key_type > &parser) |
| Stream output. More... | |
Utility class to parse command line options.
The mapping between a parameter (of any type) and a unique option has to be defined in the user's application, e.g.
The behaviour of the parser is different for parameters of type bool. By default, its value is set to false; it is set to true when the corresponding option is parsed. This implies that no data are read and that several options can be parsed in sequence without repeating the '-' symbol.
The syntax for the command line is:
program [-<option> <value> [-<option> <value>]]
program -h
will print the usage specification including all existing options.
program --!
will terminate the parsing of options and print the actual setting of all options.
After the command line has been parsed, it is checked whether each parameter has been assigned a value by default or at run time. If not, an exception is thrown.
Definition at line 1410 of file JParser.hh.
| typedef JLANG::JParserException JPARSER::JParser< JKey_t >::JParserException |
Definition at line 1416 of file JParser.hh.
| typedef JKey_t JPARSER::JParser< JKey_t >::key_type |
Definition at line 1417 of file JParser.hh.
| typedef std::map<key_type, JParserElement> JPARSER::JParser< JKey_t >::map_type |
Definition at line 1418 of file JParser.hh.
| typedef map_type::iterator JPARSER::JParser< JKey_t >::iterator |
Definition at line 1420 of file JParser.hh.
| typedef map_type::const_iterator JPARSER::JParser< JKey_t >::const_iterator |
Definition at line 1421 of file JParser.hh.
|
inline |
|
inline |
Constructor.
| message | message printed with option -h |
| debug | debug level |
Definition at line 1444 of file JParser.hh.
|
inline |
Print the possible command line options.
| out | output stream |
Definition at line 1458 of file JParser.hh.
|
inline |
Parse the program's command line options.
| argc | number of arguments |
| argv | argument list |
Definition at line 1492 of file JParser.hh.
|
inline |
Parse the program's command line options.
| args | argument list |
Definition at line 1504 of file JParser.hh.
|
inline |
Parse the program's command line options.
This method is maintained for backward compatibility and will be deprecated.
| argc | number of arguments |
| argv | argument list |
Definition at line 1673 of file JParser.hh.
|
inline |
Parse the program's command line options.
This method is maintained for backward compatibility and will be deprecated.
| args | argument list |
Definition at line 1688 of file JParser.hh.
|
inline |
Print the current parameter values.
| out | output stream |
Definition at line 1702 of file JParser.hh.
|
inlineprotected |
Check if all required options have been set.
This method throws an exception in case of a non-compliance.
Definition at line 1730 of file JParser.hh.
|
friend |
Stream output.
| out | output stream |
| parser | parser |
Definition at line 1719 of file JParser.hh.
|
protected |
help message
Definition at line 1744 of file JParser.hh.
|
protected |
process name
Definition at line 1745 of file JParser.hh.
|
staticinherited |
debug level (default is off).
Definition at line 43 of file JMessage.hh.
1.8.5