Game Accessibility Library logo SourceForge.net Logo
Game Accessibility Suite: CATCmdLine Class Reference

CATCmdLine Class Reference
[Common Accessibility Technology [CAT] library]

#include <CATCmdLine.h>

List of all members.


Detailed Description

Generic command line parser.

CATCmdLine takes the command line (in argc/argvw format - using Wide Characters!) and parses it out into switches, arguments, and operands based on the passed-in table.

You can query it after parsing, or just set it up to call your callback functions during the parse.

To use:

  1. First call Initialize(), passing the table and app information in.
  2. Call Parse() with the command information to parse.
  3. Check the return value from Parse(). If all is good, it will be 0.
  4. Query the parsed data if desired.
  5. Optionally, call RunParsedCallbacks() to execute any callbacks for commands received on the command line. If a callback returns an error, no other callbacks will be called and RunParsedCallbacks() will return that error.
  6. You may go back to step 1 or 2 if desired to parse additional command lines.
  7. Call Uninitialize (optional - will be called on initialized objects during destructor)

See for the format of the table.

Definition at line 126 of file CATCmdLine.h.


Public Member Functions

 CATCmdLine ()
virtual ~CATCmdLine ()
CATResult Initialize (CATResult prefaceId, const CATCMDLINEARG *cmdTable, CATStringTable *stringTable, CATLangId languageId=CATLANG_EN)
 Initialize the command parser.
void Uninitialize ()
CATResult Parse (CATInt32 argc, CATWChar **argvw)
 Parse a command line. Parsed data will overwrite previously parsed information.
CATResult RunParsedCallbacks (void *cbParam=0)
 Execute any callbacks specified by the table on the most recently parsed data.
CATResult PrintUsage (CATInt32 maxColumns=80)
 Prints the usage information for the app based on the table provided during initialization.
CATBool IsSwitchSet (CATWChar cmdSwitch)
 Returns true if the switch was present on the command line.
const CATWCharGetArgument (CATWChar cmdSwitch)
 Returns the argument (if any) for the switch specified on the command line.
CATUInt32 GetArgUInt (CATWChar cmdSwitch)
 Returns the argument (if any) for the switch specified on the command line after converting to an unsigned integer.
CATInt32 GetArgInt (CATWChar cmdSwitch)
 Returns the argument (if any) for the switch specified on the command line after converting to a signed integer.
CATUInt32 GetNumOps ()
 Retrieves the number of operands received on the command line.
const CATWCharGetOpByIndex (CATUInt32 index)
 Retrieves an operand's string value by index.
const CATWCharGetOpByDescId (CATResult descId)
 Retrieves an operand's string value by it's DescriptionId in the command table.
CATUInt32 GetSwitchFlags ()
 Retrieves the flags set by switches/operands that are present.

Protected Member Functions

CATInt32 GetCmdLength (CATUInt32 index)
 Internal function to get the printed length of a command while printing usage information.
CATInt32 PrintCmdEntry (CATUInt32 index)
 Internal function to print a command from the command table.
CATBool IsCmdInGroup (CATUInt32 index, CATBool &isFirst, CATBool &isLast)
 Internal function to determine if a command is in a mutually exclusive command group, and if so - if it is the first or last in the group.

Protected Attributes

CATUInt32 fSwitchFlags
 OR'd combination of all switch flags found during parse.
CATBool fInitialized
 Has Initialize() been called?
CATStringTablefStringTable
 String table to get strings from.
CATLangId fLangId
 Language Id (CATLANG_EN default).
CATResult fPrefaceId
 String id of preface for PrintUsage().
std::vector< CATCMDLINEARGfCmdTable
 List of commands.
std::vector< CATCmdArg * > fArguments
 List of parsed arguments.
std::vector< CATWChar * > fOperands
 List of parsed operands.

The documentation for this class was generated from the following files:
Generated on Mon Feb 11 04:10:16 2008 for Game Accessibility Suite by doxygen 1.5.4