#include <ProgUtils.hh>
Public Member Functions | |
| ProgOpt (std::string longname, std::string shortname, int numargus=1, std::string somedesc="") | |
| Construct with name, number of arguments and a description. | |
| ProgOpt (const ProgOpt &) | |
| Copy constructor. | |
| void | Name (std::string st) |
| Set a name for an option created with the default constructor. | |
| void | nargs (int i) |
| Set/change the number of expected arguments. | |
| std::string | value (int i) |
| The i'th value passed to this option. | |
| void | value (int i, std::string st) |
| Set the i'th value for this option. | |
| std::string | Name () const |
| Retrieve the option name. | |
| std::string | LongName () const |
| Retrieve long name. | |
| std::string | short_help () const |
| Retrieve short help-text/info. | |
| void | short_help (std::string st) |
| Set short help text. | |
| int | max_args () const |
| Retrieve number of expected arguments. | |
| void | switch_on () |
| Activate the option. | |
| bool | state () const |
| Is the option active ? | |
| prf_utils::ProgOpt::ProgOpt | ( | std::string | longname, | |
| std::string | shortname, | |||
| int | numargus = 1, |
|||
| std::string | somedesc = "" | |||
| ) |
This is likely the most useful way of constructing these. A long name is a descriptive full name of the option. On the command line one would specify an option with the long name by preceding it with two hyphens. Like, for an option with a long name "output_file", one would write, for example,
a.out --output_file somefile.dat
Short name is the abbreviation for the same option, specified on hte command line with a single hyphen. The integer argument numargus specifies how many values are passed to this option. Like, one value for the output_file option above. The somedesc argument is a some short information about the option. It could, for instance, specify that an integer argument actually can take only 3 legitimate values.
| void prf_utils::ProgOpt::switch_on | ( | ) | [inline] |
Just because a program accepts 15 options does not mean that one would need to specify all of them every time one runs it! So, an option is created inactive. Only when the user specifies it on the command line does one "activate" it. Activated or not- activated describes states of an option. But the flag is not used in this class for any internal purpose.