|
const Burger::StaticRTTI * | get_StaticRTTI (void) const noexcept override |
| Get the description to the class.
|
|
uint_t | IsHelpAvailable (void) const noexcept |
| Determine if help is available.
|
|
const char * | GetHelp (void) const noexcept |
| Return the help string.
|
|
virtual int | Action (int argc, const char **argv)=0 |
| Process the parameters for a command.
|
|
const char * | get_class_name (void) const noexcept |
| Get the name of the class.
|
|
virtual | ~Base () noexcept=default |
| Destructor.
|
|
Base class for command line parameters.
For ease of parsing command lines for tools, derived classes for each data type are created and then pooled to handle most parsing needs. It is modeled after the argparse class found in python.
"Playback frequency","f",44100,400,100000);
"Length to dump","l",UINTPTR_MAX);
&ShowAsm,
&ShowC,
&Frequency,
&Length
};
"Dump's the contents of a file to stdout.\n"
"Copyright by Rebecca Ann Heineman\n",2);
if (argc<0) {
} else {
if (ShowAsm.GetValue()) {
ShowAsmCode();
}
if (ShowC.GetValue()) {
ShowCCode();
}
PlaySound(Frequency.GetValue(),Length.GetValue());
}
#define BURGER_ARRAYSIZE(x)
Define to return the number of elements in an array.
Definition burger.h:1433
Class for a boolean command line parameters.
Definition burger.h:23669
Base class for command line parameters.
Definition burger.h:23630
static int Process(int argc, const char **argv, const CommandParameter **ppParms, uintptr_t uParmCount, const char *pUsage=nullptr, int iMin=0, int iMax=0) noexcept
Process an array of command parameters.
Definition brcommandparameter.cpp:211
Class for a numeric string command line parameter.
Definition burger.h:23694
static void SetErrorCode(eError iNewError) noexcept
Set the current error code.
Definition burger.h:15619
virtual int Burger::CommandParameter::Action |
( |
int | argc, |
|
|
const char ** | argv ) |
|
pure virtual |
Process the parameters for a command.
Process the parameters and return the number of parameters used including the parameter that invoked this command.
Example: If "-a", then return 1, if "-length 2000", return 2
If there was a parsing error, return -1
- Note
- Do not attempt to manually remove parameters from the input. It will be performed by the caller with the returned value (Number of parameters processed)
- Parameters
-
argc | Number of entries remaining in the parameter array (Can be zero) |
argv | Pointer to an array of "C" string pointers. |
- Returns
- Number of parameters processed or -1 on error or 1 for no parameters needed.
- See also
- RemoveParms() or Process()
Implemented in Burger::CommandParameterBooleanTrue, Burger::CommandParameterString, and Burger::CommandParameterWordPtr.
int BURGER_API Burger::CommandParameter::Process |
( |
int | argc, |
|
|
const char ** | argv, |
|
|
const CommandParameter ** | ppParms, |
|
|
uintptr_t | uParmCount, |
|
|
const char * | pUsage = nullptr, |
|
|
int | iMin = 0, |
|
|
int | iMax = 0 ) |
|
staticnoexcept |
Process an array of command parameters.
Given a list of command table parsers, scan the parameter list for matches and invoke their functions to calculate the values.
Each parameter is checked for a prefix of '-' and then it's matched to the command strings found in each CommandParameter and if processed, the entry will be removed from the list. When this function is complete, only the unprocessed entries will remain
- Note
- On Windows and MSDOS platforms, the prefix '/' is accepted as well as '-'
- Parameters
-
argc | Number of parameters in the argv list. |
argv | Pointer to an array of "C" strings to parse a command line from. |
ppParms | Array of pointers to CommandParameter objects |
uParmCount | Number of entries in the ppParms array |
pUsage | Pointer to a "C" string with copyright and usage, or nullptr if no usage is present |
iMin | Minimum number of allowable parameters or zero if no min/max test is to be performed |
iMax | Maximum number of allowable parameters or if it must match iMin |
- Returns
- -1 on error (Or help printed) or the number of unprocessed command line entries.
- See also
- Burger::CommandParameter