#include <CATCmdLine.h>
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:
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 CATWChar * | GetArgument (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 CATWChar * | GetOpByIndex (CATUInt32 index) |
Retrieves an operand's string value by index. | |
const CATWChar * | GetOpByDescId (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? | |
CATStringTable * | fStringTable |
String table to get strings from. | |
CATLangId | fLangId |
Language Id (CATLANG_EN default). | |
CATResult | fPrefaceId |
String id of preface for PrintUsage(). | |
std::vector< CATCMDLINEARG > | fCmdTable |
List of commands. | |
std::vector< CATCmdArg * > | fArguments |
List of parsed arguments. | |
std::vector< CATWChar * > | fOperands |
List of parsed operands. |