logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

VistaIOdictionary - representation of a keyword/value mapping

Author

       Art Pope <pope@cs.ubc.ca>

       Adaption to vistaio: Gert Wollny <gw.fossdev@gmail.com>

VistaIO Version 1.2.14                            24 April 1993                             VistaIOdictionary(3)

Description

       This  manual  page  documents  a  data  structure,  called a dictionary, for describing a mapping between
       keywords and values. Dictionaries are used by the Vista library to interpret keywords present in  command
       line options and in data files. Library routines are available for locating dictionary entries by keyword
       and by value.

   DataStructuretypedefstruct{VistaIOStringConstkeyword;/*keywordstring*/VistaIOLongivalue;/*value,ifaninteger*/VistaIOStringConstsvalue;/*value,ifastring*/VistaIOBooleanicached;/*whetherintegervaluecached*/VistaIOBooleanfcached;/*whetherfloatvaluecached*/VistaIODoublefvalue;/*cachedfloating-pointvalue*/}VistaIODictEntry;

       The  dictionary  data structure is designed to permit any string or numeric value to be associated with a
       keyword, and to permit the use of statically-initialized dictionaries.

       A dictionary is an array of VistaIODictEntry structures. The last entry in the array has a keyword  field
       of  NULL  while  each  preceding  entry  contains  both  a  keyword  and  a value. When the dictionary is
       initialized each value can be represented either as an integer in the ivalue field (in which case  svalue
       must  be  NULL)  or  as  a  string  pointed  to  by  the  svalue field (in which case the ivalue field is
       irrelevant). A floating point number is incorporated as a string value containing the number in printable
       form. The ``EXAMPLES'' section, below, shows typical code for establishing dictionaries.

       Other fields of the VistaIODictEntry are only used  internally  by  the  VistaIOLookupDictValue  routine,
       which  provides  one  form  of access to dictionaries. The fields are used to cache the results of having
       converted a string value to an integer or a floating-point number. When an entry contains a string  value
       (svalue  is  not  NULL) then icached and fcached indicate whether or not equivalent integer and floating-
       point values are also cached in ivalue and fvalue. When creating a  dictionary,  initialize  icached  and
       fcached  to  zero;  this need not be done explicitly if the dictionary is initialized statically as shown
       under ``EXAMPLES''.

   Routines
       With the following routines a dictionary entry can be  located  either  by  keyword  or  by  value.  Both
       routines  search  a  dictionary sequentially from first entry to last, returning the first matching entry
       encountered.

       VistaIODictEntry*VistaIOLookupDictKeyword(VistaIODictEntry*dict,VistaIOStringConstkeyword)VistaIOLookupDictEntry searches the dictionary dict for an entry whose keyword is  keyword.  It  re‐
            turns a pointer to the entry, if found, or NULL otherwise.

       VistaIODictEntry*VistaIOLookupDictValue(VistaIODictEntry*dict,VistaIORepnKindrepn,typevalue)VistaIOLookupDictValue  searches the dictionary dict for an entry whose value is value. The value to
            be searched for can be specified in any of several representations;  that  chosen  is  indicated  by
            repn.   Then  type is one of VistaIOBit, VistaIOUByte, VistaIOSByte, VistaIOShort, VistaIOLong, Vis‐taIOFloat, VistaIODouble, VistaIOBoolean, or VistaIOString, depending on  repn.   VistaIOLookupDict‐Valuereturnsapointertotheentry,iffound,orNULL otherwise.

   Built-inDictionaries
       The following dictionaries are already included in the library:

       VistaIOBooleanDict
                      maps between the keywords false, true, no, yes, off, and on and the values FALSE and TRUEVistaIONumericRepnDict
                      maps between the keywords bit, ubyte, sbyte, short, long, float,anddoubleandthevaluesVistaIOBitRepnthroughVistaIODoubleRepn.

Examples

       This dictionary describes a mapping between keywords and integers:

              VistaIODictEntryVistaIOBooleanDict[]={{"false",FALSE},{"true",TRUE},{"no",FALSE},{"yes",TRUE},{"off",FALSE},{"on",TRUE},{NULL}};

       This dictionary describes a mapping between keywords and floating point numbers:

              VistaIODictEntryConstantDict[]={{"zero",0},{"one",1},{"pi",0,"3.14159"},{"e",0,"2.7182818"},{NULL}};

       This dictionary describes a mapping between keywords and strings:

              VistaIODictEntryTitleDict[]={{"Clinton",0,"PresidentoftheU.S.A."},{"Major",0,"PrimeMinisterofGreatBritain"},{"Mulroney",0,"PrimeMinisterofCanada"},{NULL}};

Name

       VistaIOdictionary - representation of a keyword/value mapping

Synposis

VistaIODictEntrydictionary[]={{"keyword",integer_value},{"keyword",0,string_value},
              ...
              {NULL}};

See Also