CmdLine

Section: Misc. Reference Manual Pages (3\*(C+)
Index Return to Main Contents
 

NAME

CmdLine - A class library for parsing command-line arguments  

SYNOPSIS

#include <cmdline.h>

class  CmdArg ;  // An abstract command-argument

class  CmdLineArgIter ;  // abstract iterator for command-line-arguments
class  CmdArgvIter    : public CmdLineArgIter ;
class  CmdStrTokIter  : public CmdLineArgIter ;
class  CmdIstreamIter : public CmdLineArgIter ;

class  CmdLine ;  // A command-line object
class  CmdLineCmdArgIter ;  // iterator for a CmdLine's CmdArgs

 

DESCRIPTION

CmdLine is a set of classes to parse command-line arguments. Unlike getopt(3C) and its variants, CmdLine does more than just split up the command-line into some canonical form. CmdLine will actually parse the command-line, assigning the appropriate command-line values to the corresponding variables, and will verify the command-line syntax (and print a usage message if necessary) all in one member function call. Furthermore, many features of CmdLine's parsing behavior are configurable at run-time. These features include the following:

*
Prompting the user for missing arguments.
*
Allowing keywords (-count=4) and/or options (-c4).
*
Ignoring bad syntax instead of terminating.
*
Ignoring upper/lower case on the command-line.
*
Suppressing the printing of syntax error messages.
*
Controlling the verboseness of usage messages.
*
Controlling whether or not options may be processed after positional parameters have been seen.

CmdLine also allows for options that take an optional argument, options that take a (possibly optional) list of one or more arguments, options whose argument must reside in the same token as the option itself, and options whose argument must reside in a separate token from the option itself.

CmdLine consists of a set of classes to parse arguments from an input source called a CmdLineArgIter (which is a base class for iterating over arguments from an arbitrary input source). Argument iterators are defined for an argv[] array (with or without a corresponding argc), for a string of tokens that are separated by a given set of delimiters, and for an input-stream. Users can easily extend CmdLine to parse arguments from other input sources simply by creating their own argument iterator classes derived from the CmdLineArgIter class defined in <cmdline.h>.

Command-line arguments are themselves objects that contain a specific command-line interface, and a function that performs the desired actions when its corresponding argument is seen on the command line. Predefined command-line argument types (derived from the abstract class CmdArg in <cmdline.h>) exist for boolean, integer, floating-point, character, and string arguments, and for lists of integers, floats, and strings. These predefined subclasses of CmdArg may be found in <cmdargs.h>. Users can also create their own command-argument types on the fly by defining and implementing an appropriate subclass of the CmdArg class.

Note:
The CmdLine library does not check for any freestore allocation errors. It is assumed that any desired freestore allocation checking will be performed by the user by including the file <new.h> and using the set_new_handler function to set up a freestore exception handler.
man2html: unable to open or read file ../example.man
man2html: unable to open or read file ../parsing.man
man2html: unable to open or read file ../environ.man
man2html: unable to open or read file ../classes.man
man2html: unable to open or read file ../files.man
 

SEE ALSO

cmdargs(3), cmdparse(1)
<cmdline.h>, <cmdargs.h>
man2html: unable to open or read file ../caveats.man
man2html: unable to open or read file ../bugs.man
 

AUTHOR

Brad Appleton, Harris Computer Systems, <brad@ssd.csd.harris.com>.


 

Index

NAME
SYNOPSIS
DESCRIPTION
SEE ALSO
AUTHOR

This document was created by man2html, using the manual pages.
Time: 20:35:01 GMT, July 24, 2024