A leading hyphen character identifies keywords. Anything without a leading hyphen is a value argument. A keyword picks up the following argument if it is not another keyword. This example shows how IArgumentDictionary parses the command line input to create the key/value pairs.
Command-line input:This table lists the options defined for the example:-parm -n sample1 Sue Tom -ccc 84 85
Key Value Description --- ----- ----------- -parm The value associated with -parm is an empty IText, not NIL. -n sample1 The -n argument picks up the following argument. 1 Sue There is no associated key so "1" is assigned. 2 Tom There is no associated key so "2" is assigned. -ccc 84 The -ccc argument picks up the value "84". 3 85 There is no associated key so "3" is assigned.
The command line input arguments should be parsed and handled in the setup member function.
Class constructors and destructors.
![]() |
public:
virtual ~IArgumentDictionary()
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
IArgumentDictionary( ITest& theTest, const IString& nakedOptions = IArgumentDictionary::kEmptyText )
This unique constructor uses the outputTextStream() of the ITest object for its own error message output. When this constructor is used within an ITest, a failure to parse a number (which typically causes the test to fail) produces an error message in the diagnostic output of the ITest. If a different constructor is used, the error message appears but is lost thereafter. It can then be difficult to determine what caused the test to fail.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
IArgumentDictionary( const IString& argumentString, const IString& nakedOptions = IArgumentDictionary::kEmptyText )
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
IArgumentDictionary(const IArgumentDictionary& source)
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
IArgumentDictionary( const int argc, const char * const* argv, const IString& nakedOptions = IArgumentDictionary::kEmptyText )
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
IArgumentDictionary()
Windows | OS/2 | AIX |
Yes | Yes | Yes |
Standard assignment operators.
![]() |
public:
IArgumentDictionary& operator =( const IArgumentDictionary& rhs )
Windows | OS/2 | AIX |
Yes | Yes | Yes |
Member functions used to do general lookup of IArgumentDictionary values.
![]() |
public:
unsigned long countOfArguments() const
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
bool findSimilarKey( const IString& keyToMatch, IString& newKey ) const
Note: key is considered to match if it is of equal length or longer than the match key, and if all characters in the match key are equal (case insensitive) to those in the key. Call lookupSimilarKeys(true) to always have the dictionary look for similar keys.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
bool nthValue(const short index, IString& value)
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
void removeOnLookup(bool)
If removeOnLookup is called with argument true, then keys and values will be removed from the dictionary (keys will also be deleted) as they are looked up. This is useful if you want to make sure that all arguments are parsed by:
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
bool textAt(const IString& key, IString& value)
If the value was numeric, textAt returns it as a string. If no value was given, an empty IString object is returned.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
Member functions used to import and export information to and from the IArugmentDictionary.
![]() |
public:
void exportTextArguments(IString& argumentString)
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
It places the key/value pairs from the input arguments in the dictionary. Arguments are added to any existing dictionary entries. Options are recognized by a leading '-' character. IArgumentDictionary tries to recognize negative numbers so you can not have input options that could be confused with negative numbers. For example, "-2ab" is a valid option; "-123" is not.
public:
void importTextArguments(const IString& argumentString)
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
void importTextArguments( const int argc, const char * const* argv )
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
void importTextArguments(ITest& theTest)
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
void lookupSimilarKeys(bool)
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
void specifyNakedOptions(const IString& nakedOptions)
Call these methods *before* calling ImportTextArguments to change the way input arguments are handled.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
Member functions used to lookup values in the IArgumentDictionary based on a given key or index.
![]() |
public:
bool nthNumber( const short index, long& value, long minAllowed = LONG_MIN, long maxAllowed = LONG_MAX )
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
bool nthNumber( const short index, double& value, double minAllowed = - DBL_MAX, double maxAllowed = DBL_MAX )
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
bool numberAt( const IString& key, double& value, double minAllowed = - DBL_MAX, double maxAllowed = DBL_MAX )
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
bool numberAt( const IString& key, long& value, long minAllowed = LONG_MIN, long maxAllowed = LONG_MAX )
Windows | OS/2 | AIX |
Yes | Yes | Yes |
Public constants
![]() |
public:
static const IString & _Import kEmptyText
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
static const IString& kEmptyText
Windows | OS/2 | AIX |
Yes | Yes | Yes |