home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c063 / 3.ddi / CLASSEXM.ZIP / LOOKUP.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-18  |  3.1 KB  |  103 lines

  1. #if !defined( __ASSOC_H )
  2. #include <Assoc.h>
  3. #endif    // __ASSOC_H
  4.  
  5. #if !defined( __DICT_H )
  6. #include <Dict.h>
  7. #endif    // __DICT_H
  8.  
  9. #if !defined( __STRNG_H )
  10. #include <Strng.h>
  11. #endif    // __STRNG_H
  12.  
  13. #ifndef __IOSTREAM_H
  14. #include <iostream.h>    
  15. #endif
  16.  
  17. #define CLASSDEFINITIONS 23
  18.  
  19. static char *classNames[CLASSDEFINITIONS] =
  20.     {
  21.         "Object",
  22.         "Error",
  23.         "Sortable",
  24.         "Association",
  25.         "String",
  26.         "Container",
  27.         "Stack",
  28.         "Queue",
  29.         "Deque",
  30.         "Collection",
  31.         "HashTable",
  32.         "Bag",
  33.         "Set",
  34.         "Dictionary",
  35.         "AbstractArray",
  36.         "Array",
  37.         "SortedArray",
  38.         "List",
  39.         "DoubleList",
  40.         "ContainerIterator",
  41.         "ArrayIterator",
  42.         "ListIterator",
  43.         "DoubleListIterator"
  44.     };
  45.  
  46. static char *classDefs[CLASSDEFINITIONS] =
  47.     {
  48.         "The abstract base class of the hierarchy.\n",
  49.         "Used to indicate the presence of no object reference.\n",
  50.         "Used in ordered collections.\n",
  51.         "A key/value pair, used by the class Dictionary.\n",
  52.         "An example of an instance class, derived from class Sortable.\n",
  53.         "An abstract base class for all classes which contain other objects.\n",
  54.         "A LIFO container class.\n",
  55.         "A FIFO container class.\n",
  56.         "A double-ended container class, allowing both FIFO and LIFO access.\n",
  57.         "An abstract base class for classes which may be tested for membership.\n",
  58.         "A fast lookup implementation of a collection.\n",
  59.         "A collection class implemented by a hash table.\n",
  60.         "A collection in which there may be only one copy of each member.\n",
  61.         "A set of association object, with a lookup function.\n",
  62.         "An abstract base class for arrays.\n",
  63.         "A fixed or expandable array.\n",
  64.         "An array in which objects at successive indices are in order.\n",
  65.         "A collection class in which objects are linked together.\n",
  66.         "A collection of objects which are part of two lists.\n",
  67.         "A class which, when instantiated, is used to iterate over a collection.\n",
  68.         "An iterator which is used on array objects.\n",
  69.         "An iterator which is used on list objects.\n",
  70.         "An iterator which is used on double list objects.\n"
  71.     };
  72.  
  73. int main( int argc, char *argv[] )
  74. {
  75.     if( argc != 2 )
  76.         {
  77.         cerr << "Usage:  lookup classname\n";
  78.         return 1;
  79.         }
  80.  
  81.     Dictionary classDefinitions;
  82.  
  83.     for( int i = 0; i < CLASSDEFINITIONS; i++ )
  84.         {
  85.         String *className = new String( classNames[i] );
  86.         String *classDef = new String( classDefs[i] );
  87.         Association *entry = new Association( *className, *classDef );
  88.         classDefinitions.add( *entry );
  89.         }
  90.  
  91.     Association& definition =
  92.                     classDefinitions.lookup ( *new String ( argv[1] ) );
  93.     if( definition == NOOBJECT )
  94.         {
  95.         cout << "A definition for " << argv[1] << " was not found in the dictionary.\n";
  96.         }
  97.     else
  98.         {
  99.         cout << definition;
  100.     }
  101.     return 0;
  102. }
  103.