version 1.2, 2009/05/05 09:01:33
|
version 1.3, 2010/01/25 14:05:23
|
|
|
</ul> | </ul> |
| |
This class provides methods for merging options from both of these | This class provides methods for merging options from both of these |
sources into a single collection. The following example shows how to |
sources into a single collection. The priority of options between the |
|
configuration file and the command line is determined by the order in |
|
which the using program processes the configuration file and command |
|
line. |
|
The following example shows how to |
merge options from a command line into the option manager. | merge options from a command line into the option manager. |
| |
<pre> | <pre> |
|
|
Similarly, the OptionManager::mergeFile() method allows options to be | Similarly, the OptionManager::mergeFile() method allows options to be |
merged from a file. | merged from a file. |
| |
|
Generally options in a configuration file are of the form: |
|
|
|
name="value" |
|
|
|
The value component MUST BE quoted as shown above. Blank lines and |
|
comment lines are allowed in the configuration file. Lines in the |
|
configuration file where the first non-whitespace character is # are |
|
considered comments and bypassed. The name="value" component |
|
may be proceeded by whitespace. |
|
|
Before options are merged into the option manager, information on each | Before options are merged into the option manager, information on each |
option must be registered with the option manager so that the following | option must be registered with the option manager so that the following |
can be resolved: | can be resolved: |
|
|
| |
Boolean Options can easily be tested as follows: | Boolean Options can easily be tested as follows: |
<pre> | <pre> |
|
Boolean debug = om.isTrue("debug"); |
</pre> | </pre> |
| |
|
Similarily Integer values can be automatically converted with the |
|
function lookupIntegerValue. |
|
|
<h4>Command Line Options</h4> | <h4>Command Line Options</h4> |
| |
mergeCommandLine() like this: | mergeCommandLine() like this: |
|
|
| |
<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. |
|
Note that the option manager does not tests for maximum value. |
| |
<LI>(WHOLE_NUMBER) Numeric parameters ATTN: Finish. |
<LI>(WHOLE_NUMBER) Numeric parameters - These are |
|
parameters where a numeric variable follows the parameter defintion. |
|
The value of these numeric parameters where the integer value |
|
must be ge 0 |
| |
<LI> (NATURAL_NUMBER Numieric parameters - (ex ). ATTN: finish |
<LI> (NATURAL_NUMBER Numeric parameters - These are |
|
parameters where a numeric variable follows the parameter defintion. |
|
The value of these numeric parameters where the integer value must be |
|
gt 0 |
| |
<LI>(STRING) String Parameters - (ex. -file abd.log) These are | <LI>(STRING) String Parameters - (ex. -file abd.log) These are |
parameters that are represented by strings following the option | parameters that are represented by strings following the option |