cmdargs

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

NAME

cmdargs - predefined command argument types for CmdLine(3)  

SYNOPSIS

#include <cmdargs.h>

class  CmdArgDummy : public CmdArg ;
class  CmdArgUsage : public CmdArg ;

class  CmdArgIntCompiler : public CmdArg ;
class  CmdArgInt     : public CmdArgIntCompiler ;
class  CmdArgIntList : public CmdArgIntCompiler ;

class  CmdArgFloatCompiler : public CmdArg ;
class  CmdArgFloat     : public CmdArgFloatCompiler ;
class  CmdArgFloatList : public CmdArgFloatCompiler ;

class  CmdArgCharCompiler : public CmdArg ;
class  CmdArgChar : public CmdArgCharCompiler ;

class  CmdArgStrCompiler : public CmdArg ;
class  CmdArgStr     : public CmdArgStrCompiler ;
class  CmdArgStrList : public CmdArgStrCompiler ;

class  CmdArgBoolCompiler : public CmdArg ;
class  CmdArgBool : public CmdArgBoolCompiler ;
class  CmdArgClear  : public CmdArgBool ;
class  CmdArgToggle : public CmdArgBool ;

class  CmdArgBoolRef   : public CmdArg ;
class  CmdArgClearRef  : public CmdArg ;
class  CmdArgToggleRef : public CmdArg ;

 

DESCRIPTION

cmdargs(3) is the portion of the CmdLine(3) library that contains the predefined argument types to use in conjunction with one or more CmdLine objects. The include file <cmdargs.h> defines classes derived from class CmdArg (which is defined in <cmdline.h>) for the most commonly used types of command-line arguments. Most command-line arguments are either boolean-flags, a number, a character, or a string (or a list of numbers or strings). In each of these cases, the call operator (operator()) of the argument just compiles the value given into some internal value and waits for the programmer to query the value at some later time.

These types of arguments are referred to as "ArgCompilers". For each of the most common argument types, a corresponding abstract ArgCompiler class is declared. All that this class does is to add a member function named "compile" to the class. The compile() function looks exactly like the call operator but it takes an additional parameter: a reference to the value to be modified by compiling the argument value. In all other respects, the compile() member function behaves exactly like the call operator. In fact, most of the call operator member functions simply call the ArgCompiler's compile() member function with the appropriate value and return whatever the compile function returned.

Once all of these ArgCompilers are declared, it is a simple matter to declare a class that holds a single item, or a list of items, by deriving it from the corresponding ArgCompiler type.

For derived classes of these ArgCompilers that hold a single item, The derived class implements some operators (such as operator= and an appropriate cast operator) to treat the argument as if it were simply an item (instead of an argument that contains an item). The output operator (ostream & operator<<) is also defined.

For derived classes of ArgCompilers that hold a list of items, the subscript operator (operator[]) is defined in order to treat the argument as if it were simply an array of items and not an argument that contains a list of items.

Note:
It is important to remember that each subclass of CmdArg MUST be able to handle NULL as the first argument to the call-operator (and it should NOT be considered an error). This is because NULL will be passed if the argument takes no value, or if it takes an optional value that was NOT provided on the command-line. Whenever an argument is correctly specified on the command-line, its call operator is always invoked (regardless of whether or not there is a corresponding value from the command-line).

man2html: unable to open or read file ../example.man
man2html: unable to open or read file ../classes.man
man2html: unable to open or read file ../files.man
 

SEE ALSO

CmdLine(3), cmdparse(1)
<cmdline.h>, <cmdargs.h>  

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