Antiprism 0.23
|
Command line processing. More...
#include <utils.h>
Inherits ultra_getopt.
Inherited by view_opts.
Public Member Functions | |
prog_opts (string prog_name) | |
Constructor. | |
virtual | ~prog_opts () |
Destructor. | |
virtual void | process_command_line (int, char **) |
Process the command line. | |
virtual void | usage () |
Usage message. | |
void | version () |
Usage message. | |
const char * | prog_name () const |
Get the program name. | |
void | message (string msg, const char *msg_type=0, string opt="") const |
Print a message (to standard error). | |
void | error (string msg, string opt="", int exit_num=1) const |
Print an error message (to standard error) and exit. | |
void | error (string msg, char opt, int exit_num=1) const |
Print an error message (to standard error) and exit. | |
void | warning (string msg, string opt="") const |
Print a warning message (to standard error). | |
void | warning (string msg, char opt) const |
Print a warning message (to standard error). | |
void | handle_long_opts (int argc, char *argv[]) |
Process long options. | |
bool | common_opts (char c, char opt) |
Process common options. | |
string | get_arg_id (const char *arg, const char *maps, unsigned int match_flags=argmatch_default, char *errmsg=0) |
Map option arguments to identifiers using matching. |
Command line processing.
prog_opts::prog_opts | ( | string | prog_name | ) | [inline] |
Constructor.
prog_name | the name of the program. |
bool prog_opts::common_opts | ( | char | c, |
char | opt | ||
) |
Process common options.
c | the character returned by getopt. |
opt | the option character being considered by getopt. |
void prog_opts::error | ( | string | msg, |
string | opt = "" , |
||
int | exit_num = 1 |
||
) | const [inline] |
Print an error message (to standard error) and exit.
The message will be preceded by the program name, and the option letter or argument name (if given).
msg | the message to print. |
opt | the option letter or argument name. |
exit_num | The value to return when the program exits. |
void prog_opts::error | ( | string | msg, |
char | opt, | ||
int | exit_num = 1 |
||
) | const [inline] |
Print an error message (to standard error) and exit.
The message will be preceded by the program name, and the option letter (if given).
msg | the message to print. |
opt | the option letter. |
exit_num | The value to return when the program exits. |
string prog_opts::get_arg_id | ( | const char * | arg, |
const char * | maps, | ||
unsigned int | match_flags = argmatch_default , |
||
char * | errmsg = 0 |
||
) |
Map option arguments to identifiers using matching.
arg | the option argument |
maps | a set of maps from argument strings to identifiers separated by '|', e.g. 'string1=id1|sting2=id2|string3=id3' |
match_flags | the default is a icase insesetive match of arg to a string or failing that to the start of exactly one string. argmatch_case_sensitive distinguishes case, argmatch_no_partial disallows partial matches, argmatch_add_id_maps add extra maps so each identifiers maps to itself. |
errmsg | error message |
void prog_opts::handle_long_opts | ( | int | argc, |
char * | argv[] | ||
) |
Process long options.
argc | the number of arguments. |
argv | pointers to the argument strings. |
void prog_opts::message | ( | string | msg, |
const char * | msg_type = 0 , |
||
string | opt = "" |
||
) | const |
Print a message (to standard error).
The message will be preceded by the program name, the message type (if given), and the option letter or argument name (if given).
msg | the message to print. |
msg_type | the message type (e.g. 'warning'). |
opt | the option letter or argument name. |
virtual void prog_opts::process_command_line | ( | int | , |
char ** | |||
) | [inline, virtual] |
Process the command line.
In the derived class this will process the program options and arguments, probably using getopt
.
const char* prog_opts::prog_name | ( | ) | const [inline] |
Get the program name.
virtual void prog_opts::usage | ( | ) | [inline, virtual] |
Usage message.
In the derived class this will print a program usage help message
void prog_opts::version | ( | ) |
Usage message.
print a version message
void prog_opts::warning | ( | string | msg, |
string | opt = "" |
||
) | const [inline] |
Print a warning message (to standard error).
The message will be preceded by the program name, and the option letter or argument name (if given).
msg | the message to print. |
opt | the option letter or argument name. |
void prog_opts::warning | ( | string | msg, |
char | opt | ||
) | const [inline] |
Print a warning message (to standard error).
The message will be preceded by the program name, and the option letter (if given).
msg | the message to print. |
opt | the option letter. |