home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / common / rbdata.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-19  |  3.6 KB  |  140 lines

  1. /*
  2. *******************************************************************************
  3. *                                                                             *
  4. * COPYRIGHT:                                                                  *
  5. *   (C) Copyright International Business Machines Corporation, 1998, 1999     *
  6. *   Licensed Material - Program-Property of IBM - All Rights Reserved.        *
  7. *   US Government Users Restricted Rights - Use, duplication, or disclosure   *
  8. *   restricted by GSA ADP Schedule Contract with IBM Corp.                    *
  9. *                                                                             *
  10. *******************************************************************************
  11. *
  12. * File rbdata.cpp
  13. *
  14. * Modification History:
  15. *
  16. *   Date        Name        Description
  17. *   06/11/99    stephen     Creation. (Moved here from resbund.cpp)
  18. *******************************************************************************
  19. */
  20.  
  21. #include "rbdata.h"
  22.  
  23. UClassID StringList::fgClassID = 0; // Value is irrelevant
  24. UClassID String2dList::fgClassID = 0; // Value is irrelevant
  25. UClassID TaggedList::fgClassID = 0; // Value is irrelevant
  26.  
  27. //-----------------------------------------------------------------------------
  28.  
  29. StringList::StringList()
  30.   : fStrings(0), fCount(0) 
  31. {}
  32.  
  33. StringList::StringList(UnicodeString *adopted, 
  34.                int32_t count) 
  35.   : fStrings(adopted), fCount(count) 
  36. {}
  37.  
  38. StringList::~StringList() 
  39. { delete [] fStrings; }
  40.   
  41. const UnicodeString& 
  42. StringList::operator[](int32_t i) const 
  43. { return fStrings[i]; }
  44.  
  45. UClassID 
  46. StringList::getDynamicClassID() const 
  47. { return getStaticClassID(); }
  48.  
  49. UClassID 
  50. StringList::getStaticClassID() 
  51. { return (UClassID)&fgClassID; }
  52.  
  53. //-----------------------------------------------------------------------------
  54.  
  55. String2dList::String2dList() 
  56.   : fStrings(0), fRowCount(0), fColCount(0) 
  57. {}
  58.   
  59. String2dList::String2dList(UnicodeString **adopted, 
  60.                int32_t rowCount, 
  61.                int32_t colCount) 
  62.   : fStrings(adopted), fRowCount(rowCount), fColCount(colCount) 
  63. {}
  64.  
  65. String2dList::~String2dList() 
  66.   for(int32_t i = 0; i < fRowCount; ++i) {
  67.     delete[] fStrings[i]; 
  68.   }
  69. }
  70.   
  71. const UnicodeString& 
  72. String2dList::getString(int32_t rowIndex, 
  73.             int32_t colIndex) 
  74. { return fStrings[rowIndex][colIndex]; }
  75.   
  76. UClassID 
  77. String2dList::getDynamicClassID() const 
  78. { return getStaticClassID(); }
  79.  
  80. UClassID 
  81. String2dList::getStaticClassID() 
  82. { return (UClassID)&fgClassID; }
  83.  
  84. //-----------------------------------------------------------------------------
  85.  
  86. TaggedList::TaggedList()
  87. {
  88.   UErrorCode err = U_ZERO_ERROR;
  89.   fHashtableValues = uhash_open((UHashFunction)uhash_hashUString, &err);
  90.   uhash_setValueDeleter(fHashtableValues, deleteValue);
  91.   
  92.   fHashtableKeys = uhash_open((UHashFunction)uhash_hashUString, &err);
  93. }
  94.   
  95. TaggedList::~TaggedList()
  96. {
  97.   uhash_close(fHashtableValues);
  98.   uhash_close(fHashtableKeys);
  99. }
  100.  
  101. void 
  102. TaggedList::put(const UnicodeString& tag, 
  103.         const UnicodeString& data)
  104. {
  105.   UErrorCode err = U_ZERO_ERROR;
  106.   
  107.   uhash_putKey(fHashtableValues, 
  108.            tag.hashCode() & 0x7FFFFFFF,
  109.            (new UnicodeString(data)),
  110.            &err);
  111.   
  112.   uhash_putKey(fHashtableKeys,
  113.            uhash_size(fHashtableValues),
  114.            (new UnicodeString(tag)),
  115.            &err);
  116. }
  117.  
  118. const UnicodeString* 
  119. TaggedList::get(const UnicodeString& tag) const
  120. {
  121.   return (const UnicodeString*)
  122.     uhash_get(fHashtableValues, tag.hashCode() & 0x7FFFFFFF);
  123. }
  124.  
  125. void
  126. TaggedList::deleteValue(void *value)
  127. {
  128.   delete (UnicodeString*)value;
  129. }
  130.  
  131.   
  132. UClassID 
  133. TaggedList::getDynamicClassID() const 
  134. { return getStaticClassID(); }
  135.  
  136. UClassID 
  137. TaggedList::getStaticClassID() 
  138. { return (UClassID)&fgClassID; }
  139.