home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP10-8.ZIP / CLASSSRC.ZIP / DICT.CPP < prev    next >
C/C++ Source or Header  |  1990-09-26  |  4KB  |  151 lines

  1. //
  2. // This file contains proprietary information of Borland International.
  3. // Copying or reproduction without prior written approval is prohibited.
  4. //
  5. // Copyright (c) 1990
  6. // Borland International
  7. // 1800 Scotts Valley Dr.
  8. // Scotts Valley, CA 95066
  9. // (408) 438-8400
  10. //
  11.  
  12. // Contents ----------------------------------------------------------------
  13. //
  14. //         Dictionary::isA
  15. //         Dictionary::nameOf
  16. //         Dictionary::lookup
  17. //         Dictionary::add
  18. //
  19. // Description
  20. //
  21. //         Implementation of member functions for class Dictionary.
  22. //
  23. // End ---------------------------------------------------------------------
  24.  
  25. // Interface Dependencies ---------------------------------------------------
  26.  
  27. #ifndef __OBJECT_H
  28. #include <object.h>
  29. #endif
  30.  
  31. #ifndef __DICT_H
  32. #include <dict.h>
  33. #endif
  34.  
  35. // End Interface Dependencies ------------------------------------------------
  36.  
  37.  
  38. // Implementation Dependencies ----------------------------------------------
  39.  
  40. #ifndef __CONTAIN_H
  41. #include <contain.h>
  42. #endif
  43.  
  44. #ifndef __ASSOC_H
  45. #include <assoc.h>
  46. #endif
  47.  
  48. // End Implementation Dependencies -------------------------------------------
  49.  
  50.  
  51. // Member Function //
  52.  
  53. Dictionary::~Dictionary()
  54.  
  55. // Summary -----------------------------------------------------------------
  56. //
  57. //      Destructor for a Dictionary object.
  58. //
  59. //        We don't do anything here, because the destructor for HashTable
  60. //        will take care of destroying the contained objects.
  61. //
  62. // End ---------------------------------------------------------------------
  63. {
  64. }
  65. // End Destructor //
  66.  
  67.  
  68. // Member Function //
  69.  
  70. classType Dictionary::isA() const
  71.  
  72. // Summary -----------------------------------------------------------------
  73. //
  74. //         Returns the class type of a dictionary.
  75. //
  76. // End ---------------------------------------------------------------------
  77. {
  78.     return dictionaryClass; 
  79. }
  80. // End Member Function Dictionary::isA //
  81.  
  82.  
  83. // Member Function //
  84.  
  85. char *Dictionary::nameOf() const
  86.  
  87. // Summary -----------------------------------------------------------------
  88. //
  89. //         Returns a pointer to the character string "Dictionary."
  90. //
  91. // End ---------------------------------------------------------------------
  92. {
  93.     return "Dictionary";
  94. }
  95. // End Member Function Dictionary::nameOf //
  96.  
  97.  
  98. // Member Function //
  99.  
  100. Association& Dictionary::lookup( const Object& toLookUp ) const
  101.  
  102. // Summary -----------------------------------------------------------------
  103. //
  104. //         Looks up an object in the dictionary.
  105. //
  106. // Parameters
  107. //
  108. //         toLookUp
  109. //
  110. //         The object to be searched for in the dictionary.
  111. //
  112. // End ---------------------------------------------------------------------
  113. {
  114.     Association toFind( (Object&)toLookUp, NOOBJECT );
  115.     // OK to cast to non-const object here, since it doesn't get
  116.     // put into a dictionary, but is only used for comparisons.
  117.  
  118.     Association& found = (Association&)findMember( toFind );
  119.     return found;
  120. }
  121. // End Member Function Dictionary::lookup //
  122.  
  123.  
  124. // Member Function //
  125.  
  126. void Dictionary::add( Object& objectToAdd )
  127.  
  128. // Summary -----------------------------------------------------------------
  129. //
  130. //         Adds an object of type Association to the dictionary.
  131. //
  132. // Parameters
  133. //
  134. //         objectToAdd
  135. //
  136. //         The object to be added to the dictionary.
  137. //
  138. // End ---------------------------------------------------------------------
  139. {
  140.     if( !objectToAdd.isAssociation() )
  141.     {
  142.         cerr << "Error:  Object must be association type.";
  143.         exit( __ENOTASSOC );
  144.     }
  145.     else
  146.     {
  147.         Set::add( objectToAdd );
  148.     }
  149. }
  150. // End Member Function Dictionary::add //
  151.