|
Jpp
18.3.0-rc.1
the software that should make you happy
|
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... | |
| JParser & | join (const JParser &parser) |
| Join parser. More... | |
| void | print (std::ostream &out) const |
| Print the possible command line options. More... | |
| virtual void | terminate (const int status) |
| Terminate. 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.
For a comparison between the parsing of command line options with JParser and boost, see internal note which is accessible for anyone with a KM3NeT account.
Definition at line 1514 of file JParser.hh.
| typedef JLANG::JParserException JPARSER::JParser< JKey_t >::JParserException |
Definition at line 1520 of file JParser.hh.
| typedef JKey_t JPARSER::JParser< JKey_t >::key_type |
Definition at line 1521 of file JParser.hh.
| typedef std::map<key_type, JParserElement> JPARSER::JParser< JKey_t >::map_type |
Definition at line 1522 of file JParser.hh.
| typedef map_type::iterator JPARSER::JParser< JKey_t >::iterator |
Definition at line 1524 of file JParser.hh.
| typedef map_type::const_iterator JPARSER::JParser< JKey_t >::const_iterator |
Definition at line 1525 of file JParser.hh.
|
inline |
|
inline |
Constructor.
| message | message printed with option -h |
| debug | debug level |
Definition at line 1548 of file JParser.hh.
|
inline |
|
inline |
Print the possible command line options.
| out | output stream |
Definition at line 1575 of file JParser.hh.
|
inlinevirtual |
|
inline |
Parse the program's command line options.
| argc | number of arguments |
| argv | argument list |
Definition at line 1625 of file JParser.hh.
|
inline |
Parse the program's command line options.
| args | argument list |
Definition at line 1637 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 1811 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 1826 of file JParser.hh.
|
inline |
Print the current parameter values.
| out | output stream |
Definition at line 1840 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 1868 of file JParser.hh.
|
friend |
Stream output.
| out | output stream |
| parser | parser |
Definition at line 1857 of file JParser.hh.
|
protected |
help message
Definition at line 1882 of file JParser.hh.
|
protected |
process name
Definition at line 1883 of file JParser.hh.
|
staticinherited |
debug level (default is off).
Definition at line 45 of file JMessage.hh.
1.8.5