Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

look::LookParameters Class Reference

Manages application parameters. More...

#include <lookparameters.h>

List of all members.

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


Detailed Description

Manages application parameters.

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.


Member Function Documentation

void look::LookParameters::FindParametersNotInList ( const LookStringList & theList,
LookStringList & theReturnList ) [static]
 

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.

Parameters:
theList   Keywords to ignore
theReturnList   This list will receive any keywords not in theList.

LookString look::LookParameters::GetParameter ( const LookString & theKey ) [static]
 

Get the value corresponding to theKey.

Parameters:
theKey   Keyword
Returns:
Value if one exists, otherwise an empty string.

bool look::LookParameters::GetParameterAsBool ( const LookString & theKey,
const LookString & theTrueValue = "TRUE",
bool forceUpper = true ) [static]
 

Get a parameter as a bool.

Eg COUNT_LINES=TRUE

Parameters:
theKey   Keyword
theTrueValue   String used to mean true
forceUpper   true if you want to make this case insensitive
Returns:
true if the value == theTrueValue

long look::LookParameters::GetParameterAsDecode ( const LookString & theKey,
LookStringIntegerMap & theMap,
long theDefault,
bool forceUpper ) [static]
 

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.

Parameters:
theKey   Keyword
theMap   String/Long map
theDefault   Value to return if no parameter exists or it is an invalid value. (use ParameterExists() to tell the difference between these)
forceUpper   true to make the string comparison case-insensitive
Returns:
long corresponding to the value string.

long look::LookParameters::GetParameterAsLong ( const LookString & theKey ) [static]
 

Get a parameter as a long.

Eg LINE_COUNT=30

Parameters:
theKey   Keyword
Returns:
The value converted to a long, or 0 if the parameter doesn't exist.

bool look::LookParameters::ParameterExists ( const LookString & theKey ) [static]
 

Does a parameter exist?

Returns:
true if there exists a parameter (keyword/value pair) for theKey.

bool look::LookParameters::ParseApplicationParameters ( int argc,
char ** argv ) [static]
 

Parse the application parameters.

Call this from main() (or thereabouts) to parse the command line.

Parameters:
argc   Like main()
argv   Like main()
Returns:
true if the parsing succeeded

void look::LookParameters::SetParameter ( const LookString & theKey,
const LookString & theValue ) [static]
 

Set a parameter.

Create or replace a keyword/value pair. You could do this to add implied parameters for example.

Parameters:
theKey   Keyword
theValue   Value


The documentation for this class was generated from the following files:
Generated at Thu Jan 17 12:53:09 2002 for liblookdb by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001