Antiprism 0.23
Public Member Functions

prog_opts Class Reference

Command line processing. More...

#include <utils.h>

Inherits ultra_getopt.

Inherited by view_opts.

List of all members.

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.

Detailed Description

Command line processing.


Constructor & Destructor Documentation

prog_opts::prog_opts ( string  prog_name) [inline]

Constructor.

Parameters:
prog_namethe name of the program.

Member Function Documentation

bool prog_opts::common_opts ( char  c,
char  opt 
)

Process common options.

Parameters:
cthe character returned by getopt.
optthe option character being considered by getopt.
Returns:
whether the option was handled.
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).

Parameters:
msgthe message to print.
optthe option letter or argument name.
exit_numThe 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).

Parameters:
msgthe message to print.
optthe option letter.
exit_numThe 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.

Parameters:
argthe option argument
mapsa set of maps from argument strings to identifiers separated by '|', e.g. 'string1=id1|sting2=id2|string3=id3'
match_flagsthe 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.
errmsgerror message
Returns:
The identifier corresponding to the matched string, or if the argument is not matched "" is returned and the error message is copied to errmsg.
void prog_opts::handle_long_opts ( int  argc,
char *  argv[] 
)

Process long options.

Parameters:
argcthe number of arguments.
argvpointers 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).

Parameters:
msgthe message to print.
msg_typethe message type (e.g. 'warning').
optthe 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.

Returns:
a pointer to 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).

Parameters:
msgthe message to print.
optthe 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).

Parameters:
msgthe message to print.
optthe option letter.

The documentation for this class was generated from the following files: