Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

MCGetOpt Class Reference

Class supporting simplified command line option processing. More...

#include <mcllib/MCGetOpt.h>

Inheritance diagram for MCGetOpt:

MCBase List of all members.

Public Member Functions

MCVariantType get (const MCString &optStr) const
 Get the value of an option.
mcintn getArgc () const
 Get the unused arguments of the argv array passed to the constructor.
bool has (const MCString &optStr) const
 Check to see if an option was present in the command line.
 MCGetOpt (mcintn argc, const char **argv, const MCString &optSpec)
 Create a new GetOpt command line processor.

Detailed Description

Class supporting simplified command line option processing.

The options that are to be supported are passed in a string using the getopt(3) convention. The command line options made available to the application in argc/argv are presented to a GetOpt object to parse. Options can be tested for their presence using the has() method. The value of an option can be obtained using the get() method.


Constructor & Destructor Documentation

MCGetOpt mcintn  argc,
const char **  argv,
const MCString optSpec
 

Create a new GetOpt command line processor.

If the command line specified by the arguments cannot be parsed, an exception is thrown. This should prompt the application to issue a "usage:" message.

Parameters:
argc the size of the argv array.
argv an array of command line parameters (e.g. as passed to main).
optSpec a command line option string using the getopt(3) convetion. For instance to specify that -a without a parameter is acceptable add the letter "a" to optSpec. To specify that -a with a parameter is acceptable, add the letter "a" followed by colon to optSpec, i.e. "a:".


Member Function Documentation

MCVariantType get const MCString optStr  )  const
 

Get the value of an option.

Parameters:
optStr the option letter to get a value for.
Returns:
a variant type containing the value for the option. If the the command line arguments did not contain the option then the returned variant type will be undefined (null).

mcintn getArgc  )  const
 

Get the unused arguments of the argv array passed to the constructor.

Returns:
count of the number of arguments remaining in argv.

bool has const MCString optStr  )  const
 

Check to see if an option was present in the command line.

Returns:
true if the corresponding option letter was in the command line arguments passed to the constructor.


Generated on Wed Jan 12 19:05:49 2005 for MCLLIB by  doxygen 1.3.9.1