Aargh

The IntOpt Element

The IntOpt element defines a integer option, i.e. an option that takes a non-negative integer as an argument. For example:
<IntOpt letter="i" name="sample_int">
	<Range min="1" max="6"/>
	<Required/>
</IntOpt>

Attributes

In addition to the letter and name attributes, an IntOpt element may also carry a default attribute. For example:
<IntOpt letter="u" name="universe" default="42"/>

If the option is not present on the command line, the generated code will store the value of the default attribute as the argument of the option. If no default attribute is supplied, the default default is zero. The default attribute has no effect if the <Required/> or <Multiples/> element is present.

Enclosed Elements

The IntOpt element may enclose any combination of three optional elements, of which each may occur no more than once within a given IntOpt aggregate:

Generated Members

For C, the generated code will provide two members related to an IntOpt: For C++, the generated code will provide two private data members corresponding to the C members described above, plus two const member functions to access them: When multiple occurrences are allowed, the generated code C defines a struct similar to the following to serve as a node in a linked list:
struct optionname_node
{
        struct optionname_node * pNext;
        unsigned long value;
};
...where optionname is the name of the option. The nodes are linked in the order in which the options occur. The first node represents the first occurrence, the second represents the second, and so on.

Deallocating Multiples

If any option allows multiple occurrences, the generated C code provides a function that clears all the linked lists and deallocates the nodes. The name of this function is "clear_Opts", or "clear_X" where "X" is the struct name specified by the Structure element. For example:
void clear_Opts( struct Opts * pOpts );
For C++ no such function is necessary. The list of values is stored in an STL vector, which is automatically cleared by the destructor.

Home