#include <lookparameters.h>
Static Public Methods | |
LookString | GetParameter (const LookString &theKey) |
Get the value corresponding to theKey. More... | |
void | SetParameter (const LookString &theKey, const LookString &theValue) |
Set a parameter. More... | |
bool | ParameterExists (const LookString &theKey) |
Does a parameter exist? More... | |
void | FindParametersNotInList (const LookStringList &theList, LookStringList &theReturnList) |
Tell me of any parameters not in a list. More... | |
bool | ParseApplicationParameters (int argc, char **argv) |
Parse the application parameters. More... | |
bool | ParseParameter (LookString theParameter) |
bool | ParseParameterFile (const LookString &theFilename) |
long | GetParameterAsLong (const LookString &theKey) |
Get a parameter as a long. More... | |
bool | GetParameterAsBool (const LookString &theKey, const LookString &theTrueValue="TRUE", bool forceUpper=true) |
Get a parameter as a bool. More... | |
long | GetParameterAsDecode (const LookString &theKey, LookStringIntegerMap &theMap, long theDefault, bool forceUpper) |
Get a parameter as a decode. More... | |
void | SetCaseSensitive (bool isCaseSensitive=true) |
Sey keyword case-sensitivity. | |
Static Protected Attributes | |
LookStringStringMap | itsParameters |
bool | itIsCaseSensitive = false |
You can use this to parse application parameters in your program, provided you want to use its style!
Parameters are like the export and import utilities in Oracle - they are of the form 'KEYWORD=VALUE'.
For command line args, depending on your environment (shell) this could well be USER="fred jones" or USER=fred\ jones or USER='fred jones' - they all appear to the program as USER=fred jones, ie one parameter. The first one works under windows and unix though
For file-based args, there is no such idea - one line = one arg, so long as it has an = sign it will work. (ie spare whitespace is ok)
KEYWORDs may be case-insensitive, but VALUEs aren't.
It also understands 'PARFILE=filename' to store parameters in a file. The parameter file contains more 'KEYWORD=VALUE' lines, 'comments' and it can contain more 'PARFILE=filename' lines if you want. (However it will not let you recurse).
If you do use this, call ParseApplicationParameters() in or near main(), then you can access the parameters anywhere you want.
|
Tell me of any parameters not in a list. Eg if you want to reject any invalid parameters, make a list of the valid keywords, then this will return any invalid keys.
|
|
Get the value corresponding to theKey.
|
|
Get a parameter as a bool. Eg COUNT_LINES=TRUE
|
|
Get a parameter as a decode. Eg ACTION_ON_ERROR=FAIL|REPORT|CRASH Pass in a map of strings and longs (obviously you could put enums in there) and this will return the long corresponding to the string found.
|
|
Get a parameter as a long. Eg LINE_COUNT=30
|
|
Does a parameter exist?
|
|
Parse the application parameters. Call this from main() (or thereabouts) to parse the command line.
|
|
Set a parameter. Create or replace a keyword/value pair. You could do this to add implied parameters for example.
|