[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.5.6.4 Arg Type Keyword

arg-type = keyword;

The argument must match a specified list of strings (see section Keyword list). Assuming you have named the option, optn-name, the strings will be converted into an enumeration of type te_Optn_Name with the values OPTN_NAME_KEYWORD.* If you have not specified a default value, the value OPTN_NAME_UNDEFINED will be inserted with the value zero. The option will be initialized to that value. You may now use this in your code as follows:

 
te_Optn_Name opt = OPT_VALUE_OPTN_NAME;
switch (opt) {
case OPTN_NAME_UNDEFINED:  /* undefined things */ break;
case OPTN_NAME_KEYWORD:    /* `keyword' things */ break;
default: /* utterly impossible */ ;
}

AutoOpts produces a special purpose procedure for this option. You may not specify an alternate handling procedure.

If you have need for the string name of the selected keyword, you may obtain this with the macro, OPT_OPTN_NAME_VAL2STR(val). The value you pass would normally be OPT_VALUE_OPTN_NAME, but anything with numeric value that is legal for te_Optn_Name may be passed. Anything out of range will result in the string, ‘"*INVALID*"’ being returned. The strings are read only. It may be used as in:

 
te_Optn_Name opt = OPT_VALUE_OPTN_NAME;
printf( "you selected the %s keyword\n",
        OPT_OPTN_NAME_VAL2STR(opt) );

* Note: you may replace the OPTN_NAME enumeration prefix with another prefix by specifying a prefix-enum attribute.

Finally, users may specify the argument either by name or by number. Since the numeric equivalents change by having new entries inserted into the keyword list, this would not be a recommended practice. However, either -1 or ~0 will always be equivalent to specifying the last keyword.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Bruce Korb on August 21, 2015 using texi2html 1.82.