PROFASI
Version 1.5
|
One option that a program may handle. More...
#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 | 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. | |
int | max_args () const |
Retrieve number of expected arguments. | |
![]() | |
void | Name (std::string st) |
Set a name for an option created with the default constructor. | |
std::string | Name () const |
Retrieve the option name. | |
std::string | LongName () const |
Retrieve long name. | |
void | LongName (std::string st) |
Set a long name. | |
std::string | short_help () const |
Retrieve short help-text/info. | |
void | short_help (std::string st) |
Set short help text. | |
std::string | help () const |
Help text. | |
void | set_help_text (std::string st) |
Set help text. | |
void | append_help_text (std::string st) |
Append to existing help text. | |
void | set_given () |
Activate the option. | |
bool | state () const |
Is the option active ? | |
This class is mostly intended to be used along with ProgArgs. It represents one of the many options which might be handled by ProgArgs.
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.