version 1.46, 2006/06/19 19:37:29
|
version 1.47, 2006/11/10 18:14:58
|
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Mike Brasher (mbrasher@bmc.com) |
|
// |
|
// Modified By: Karl Schopmyer(k.schopmeyer@opengroup.org) |
|
// David Dillard, VERITAS Software Corp. |
|
// (david.dillard@veritas.com) |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
////////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////////// |
|
|
The option manager allows for several types of options including: | The option manager allows for several types of options including: |
<UL> | <UL> |
<LI> (BOOLEAN)Simple keyword parameters (ex. -t or -h on the command | <LI> (BOOLEAN)Simple keyword parameters (ex. -t or -h on the command |
line). These are Boolean parameters and there are no additional parameters |
line). These are Boolean parameters and there are no additional |
after the keyword. |
parameters after the keyword. |
| |
<LI> (INTEGER) Numeric parameters - (ex -port 5988). These are | <LI> (INTEGER) Numeric parameters - (ex -port 5988). These are |
parameters where a numeric variable follows the parameter defintion. | parameters where a numeric variable follows the parameter defintion. |
|
|
be resolvable to a single string. | be resolvable to a single string. |
| |
<LI> (STRING) Domain Parameters - These are parameters where there is | <LI> (STRING) Domain Parameters - These are parameters where there is |
a choice of keywords from a domain of keywords. The input parameter may be any |
a choice of keywords from a domain of keywords. The input parameter |
one of these keywords. Thus, the domain (red blue green) for the |
may be any one of these keywords. Thus, the domain (red blue green) |
parameter "color" (-c) could be entered as -c red. The difference |
for the parameter "color" (-c) could be entered as -c red. The |
between String interpretation and domain interpretation is the use of the |
difference between String interpretation and domain interpretation |
domain fields in the option definition. |
is the use of the domain fields in the option definition. |
| |
<LI> Mask parameters - These are parameters that define an internal | <LI> Mask parameters - These are parameters that define an internal |
bit mask from a set of keywords input. | bit mask from a set of keywords input. |
|
|
must have the form -option. If they are present, then they are | must have the form -option. If they are present, then they are |
taken to be true. | taken to be true. |
| |
¶m argc number of argument on the command line. |
@param argc number of argument on the command line. |
¶m argv list of command line arguments. |
@param argv list of command line arguments. |
¶m abortOnErr - Optional Boolean that if true causes exception if there is |
@param abortOnErr - Optional Boolean that if true causes exception |
a parameter found that is not in the table. Defaults to true |
if there is a parameter found that is not in the table. Defaults to |
&exception InvalidOptionValue if validation fails. |
true |
&exception OMMissingCommandLineOptionArgument |
@exception InvalidOptionValue if validation fails. |
|
@exception OMMissingCommandLineOptionArgument |
*/ | */ |
void mergeCommandLine(int& argc, char**& argv, Boolean abortOnErr=true); | void mergeCommandLine(int& argc, char**& argv, Boolean abortOnErr=true); |
| |
|
|
Option::isValid(). Valid option values are set by calling | Option::isValid(). Valid option values are set by calling |
Option::setValue(). | Option::setValue(). |
| |
¶m fileName name of file to be merged. |
@param fileName name of file to be merged. |
&exception NoSuchFile if file cannot be opened. |
@exception NoSuchFile if file cannot be opened. |
&exception BadConfigFileOption |
@exception BadConfigFileOption |
*/ | */ |
void mergeFile(const String& fileName); | void mergeFile(const String& fileName); |
| |
/** After merging, this method is called to check for required options | /** After merging, this method is called to check for required options |
that were not merged (specified). | that were not merged (specified). |
| |
&exception OMMissingRequiredRequiredOption |
@exception OMMissingRequiredRequiredOption |
*/ | */ |
void checkRequiredOptions() const; | void checkRequiredOptions() const; |
| |
|
|
*/ | */ |
void printOptionsHelp() const; | void printOptionsHelp() const; |
| |
/** Print Complete Help Text message including header before the options help |
/** Print Complete Help Text message including header before the options |
and trailer after the options help |
help and trailer after the options help |
*/ | */ |
void printOptionsHelpTxt(const String& header, const String& trailer) const; | void printOptionsHelpTxt(const String& header, const String& trailer) const; |
| |
|
|
*/ | */ |
| |
/** Exception class */ | /** Exception class */ |
class PEGASUS_COMMON_LINKAGE OMMissingCommandLineOptionArgument : public Exception |
class PEGASUS_COMMON_LINKAGE OMMissingCommandLineOptionArgument |
|
: public Exception |
{ | { |
public: | public: |
| |
//l10n |
|
//OMMissingCommandLineOptionArgument(const String& optionName) |
|
//: Exception("Missing command line option argument: " + optionName) { } |
|
OMMissingCommandLineOptionArgument(const String& optionName) | OMMissingCommandLineOptionArgument(const String& optionName) |
: Exception(MessageLoaderParms("Common.OptionManager.MISSING_CMD_LINE_OPTION", |
: Exception(MessageLoaderParms( |
|
"Common.OptionManager.MISSING_CMD_LINE_OPTION", |
"Missing command line option argument: $0", | "Missing command line option argument: $0", |
optionName)) { } |
optionName)) |
|
{ |
|
} |
}; | }; |
| |
/** Exception class */ | /** Exception class */ |
|
|
{ | { |
public: | public: |
| |
//l10n |
|
//OMInvalidOptionValue(const String& name, const String& value) |
|
//: Exception("Invalid option value: " + name + "=\"" + value + "\"") { } |
|
OMInvalidOptionValue(const String& name, const String& value) | OMInvalidOptionValue(const String& name, const String& value) |
: Exception(MessageLoaderParms("Common.OptionManager.INVALID_OPTION_VALUE", |
: Exception(MessageLoaderParms( |
|
"Common.OptionManager.INVALID_OPTION_VALUE", |
"Invalid option value: $0=\"$1\"", | "Invalid option value: $0=\"$1\"", |
name, | name, |
value)) { } |
value)) |
|
{ |
|
} |
}; | }; |
| |
/** Exception class */ | /** Exception class */ |
class PEGASUS_COMMON_LINKAGE OMDuplicateOption : public Exception | class PEGASUS_COMMON_LINKAGE OMDuplicateOption : public Exception |
{ | { |
public: | public: |
//l10n |
|
//OMDuplicateOption(const String& name) |
|
//: Exception("Duplicate option: " + name) { } |
|
OMDuplicateOption(const String& name) | OMDuplicateOption(const String& name) |
: Exception(MessageLoaderParms("Common.OptionManager.DUPLICATE_OPTION", |
: Exception(MessageLoaderParms( |
|
"Common.OptionManager.DUPLICATE_OPTION", |
"Duplicate option: $0", | "Duplicate option: $0", |
name)) { } |
name)) |
|
{ |
|
} |
}; | }; |
| |
/** Exception class */ | /** Exception class */ |
|
|
class PEGASUS_COMMON_LINKAGE OMUnrecognizedConfigFileOption : public Exception | class PEGASUS_COMMON_LINKAGE OMUnrecognizedConfigFileOption : public Exception |
{ | { |
public: | public: |
//l10n |
|
//OMUnrecognizedConfigFileOption(const String& name) |
|
//: Exception("Unrecognized config file option: " + name) { } |
|
OMUnrecognizedConfigFileOption(const String& name) | OMUnrecognizedConfigFileOption(const String& name) |
: Exception(MessageLoaderParms("Common.OptionManager.UNRECOGNIZED_CONFIG_FILE_OPTION", |
: Exception(MessageLoaderParms( |
|
"Common.OptionManager.UNRECOGNIZED_CONFIG_FILE_OPTION", |
"Unrecognized config file option: $0", | "Unrecognized config file option: $0", |
name)) { } |
name)) |
|
{ |
|
} |
}; | }; |
| |
/** Exception class */ | /** Exception class */ |
class PEGASUS_COMMON_LINKAGE OMMissingRequiredOptionValue : public Exception | class PEGASUS_COMMON_LINKAGE OMMissingRequiredOptionValue : public Exception |
{ | { |
public: | public: |
//l10n |
|
//OMMissingRequiredOptionValue(const String& name) |
|
//: Exception("Missing required option value: " + name) { } |
|
OMMissingRequiredOptionValue(const String& name) | OMMissingRequiredOptionValue(const String& name) |
: Exception(MessageLoaderParms("Common.OptionManager.MISSING_REQUIRED_OPTION", |
: Exception(MessageLoaderParms( |
|
"Common.OptionManager.MISSING_REQUIRED_OPTION", |
"Missing required option value: $0", | "Missing required option value: $0", |
name)) { } |
name)) |
|
{ |
|
} |
}; | }; |
| |
/** Exception class */ | /** Exception class */ |
class PEGASUS_COMMON_LINKAGE OMMBadCmdLineOption : public Exception | class PEGASUS_COMMON_LINKAGE OMMBadCmdLineOption : public Exception |
{ | { |
public: | public: |
//l10n |
|
// OMMBadCmdLineOption(const String& name) |
|
//: Exception("Parameter not Valid: " + name) { } |
|
OMMBadCmdLineOption(const String& name) | OMMBadCmdLineOption(const String& name) |
: Exception(MessageLoaderParms("Common.OptionManager.PARAMETER_NOT_VALID", |
: Exception(MessageLoaderParms( |
|
"Common.OptionManager.PARAMETER_NOT_VALID", |
"Parameter not Valid: $0", | "Parameter not Valid: $0", |
name)) { } |
name)) |
|
{ |
|
} |
}; | }; |
| |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |
#endif /* Pegasus_OM_h */ | #endif /* Pegasus_OM_h */ |