00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef TABLES_H
00032 #define TABLES_H
00033
00034
00035 #include "filestrm.h"
00036 #include "umemstrm.h"
00037 #include "unicode/unistr.h"
00038 #include "unicode/ustring.h"
00039
00044 class EntryPair
00045 {
00046 public:
00050 EntryPair();
00051 EntryPair(const UChar *name, int32_t nameLen, int32_t aValue, UBool aFwd = TRUE);
00052 ~EntryPair();
00053
00054 inline UBool equalTo(const UChar *aName, int32_t aLen);
00055 inline const UnicodeString& getEntryName();
00056
00057 int32_t value;
00058 UBool fwd;
00059
00067 void streamOut(FileStream* os) const;
00068 void streamIn(FileStream* is);
00069
00070 void streamOut(UMemoryStream* os) const;
00071 void streamIn(UMemoryStream* is);
00072
00076 EntryPair(const UnicodeString& str, int32_t aValue, UBool aFwd = TRUE);
00077 private:
00078 UnicodeString *storage;
00079 const UChar *nameChars;
00080 int32_t nameLen;
00081 };
00082
00083
00089 class VectorOfInt {
00090
00091 public:
00096 enum EGrowthRate { GROWTH_RATE = 4 };
00101 VectorOfInt(int32_t initialSize = 0);
00105 VectorOfInt(const VectorOfInt& that);
00109 ~VectorOfInt();
00110
00114 const VectorOfInt& operator=(const VectorOfInt& that);
00115
00116
00120 UBool operator==(const VectorOfInt& that);
00121 UBool operator!=(const VectorOfInt& that);
00122
00128 int32_t operator[](int32_t index) const;
00129 int32_t at(int32_t index) const;
00130
00136 int32_t& operator[](int32_t index);
00137 int32_t& at(int32_t index);
00138
00144 void atPut( int32_t index,
00145 const int32_t& value);
00152 void atInsert( int32_t index,
00153 const int32_t& value);
00154
00159 int32_t size(void) const;
00160
00170 void setSize(int32_t newSize);
00171
00176 UBool isBogus(void) const;
00177
00185 void streamOut(FileStream* os) const;
00186 void streamIn(FileStream* is);
00187
00188 void streamOut(UMemoryStream* os) const;
00189 void streamIn(UMemoryStream* is);
00190
00191 private:
00196 void resize(int32_t newSize);
00197
00198 int32_t fSize;
00199 int32_t fCapacity;
00200 int32_t* fElements;
00201 UBool fBogus;
00202 };
00203
00221 class VectorOfPointer {
00222 public:
00227 enum EGrowthRate { GROWTH_RATE = 4 };
00232 VectorOfPointer(int32_t initialSize = 0);
00236 VectorOfPointer(const VectorOfPointer& that);
00240 ~VectorOfPointer();
00244 const VectorOfPointer& operator=(const VectorOfPointer& that);
00245
00249 UBool operator==(const VectorOfPointer& that);
00250 UBool operator!=(const VectorOfPointer& that);
00251
00257 void* operator[](int32_t index) const;
00258 void* at(int32_t index) const;
00259
00265 void*& operator[](int32_t index);
00266 void*& at(int32_t index);
00267
00273 void atPut( int32_t index,
00274 const void*& value);
00275
00282 void atInsert( int32_t index,
00283 const void*& value);
00288 int32_t size(void) const;
00289
00294 UBool isBogus(void) const;
00295
00296 private:
00301 void resize(int32_t newSize);
00302
00303 int32_t fSize;
00304 int32_t fCapacity;
00305 void** fElements;
00306 UBool fBogus;
00307 };
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340 class VectorOfPToExpandTable;
00341
00352 class PToExpandTable {
00353 public:
00354
00358 ~PToExpandTable();
00359
00364 const PToExpandTable& operator=(VectorOfInt* newValue);
00365 const PToExpandTable& operator=(const PToExpandTable& pointerToNewValue);
00366
00370 operator VectorOfInt*() const;
00371
00372 private:
00376 PToExpandTable(VectorOfInt*& value);
00380 PToExpandTable(const PToExpandTable& that);
00381
00382 VectorOfInt*& fValue;
00383
00384 friend class VectorOfPToExpandTable;
00385 };
00386
00405 class VectorOfPToExpandTable {
00406 public:
00407
00412 enum EGrowthRate { GROWTH_RATE = 4 };
00417 VectorOfPToExpandTable(int32_t initialSize = 0);
00421 VectorOfPToExpandTable(const VectorOfPToExpandTable& that);
00422
00426 ~VectorOfPToExpandTable();
00427
00431 const VectorOfPToExpandTable&
00432 operator=(const VectorOfPToExpandTable& that);
00433
00442 PToExpandTable at(int32_t index);
00443 PToExpandTable operator[](int32_t index);
00444
00456 VectorOfInt* at(int32_t index) const;
00457 VectorOfInt* operator[](int32_t index) const;
00458
00465 void atPut( int32_t index,
00466 VectorOfInt* value);
00467
00473 VectorOfInt* orphanAt(int32_t index);
00474
00479 int32_t size(void) const;
00480
00485 UBool isBogus(void) const;
00486
00494 void streamOut(FileStream* os) const;
00495 void streamIn(FileStream* is);
00496
00497 void streamOut(UMemoryStream* os) const;
00498 void streamIn(UMemoryStream* is);
00499
00500 private:
00505 void resize(int32_t newSize);
00506
00507 int32_t fSize;
00508 int32_t fCapacity;
00509 VectorOfInt** fElements;
00510 UBool fBogus;
00511 };
00512
00513 class VectorOfPToContractElement;
00514
00525 class PToContractElement {
00526 public:
00530 ~PToContractElement();
00531
00536 const PToContractElement& operator=(EntryPair* newValue);
00537 const PToContractElement& operator=(const PToContractElement& pointerToNewValue);
00538
00542 operator EntryPair*() const;
00543
00544 private:
00548 PToContractElement(EntryPair*& value);
00552 PToContractElement(const PToContractElement& that);
00553
00554 EntryPair*& fValue;
00555
00556 friend class VectorOfPToContractElement;
00557 };
00558
00576 class VectorOfPToContractElement {
00577 public:
00582 enum EGrowthRate { GROWTH_RATE = 4 };
00587 VectorOfPToContractElement(int32_t initialSize = 0);
00591 VectorOfPToContractElement(const VectorOfPToContractElement& that);
00592
00596 ~VectorOfPToContractElement();
00597
00601 const VectorOfPToContractElement&
00602 operator=(const VectorOfPToContractElement& that);
00603
00614 PToContractElement operator[](int32_t index);
00615 PToContractElement at(int32_t index);
00616
00628 EntryPair* operator[](int32_t index) const;
00629 EntryPair* at(int32_t index) const;
00630
00637 void atPut( int32_t index,
00638 EntryPair* value);
00645 void atInsert( int32_t index,
00646 EntryPair* value);
00652 EntryPair* orphanAt(int32_t index);
00653
00658 int32_t size(void) const;
00659
00664 UBool isBogus(void) const;
00665
00673 void streamOut(FileStream* os) const;
00674 void streamIn(FileStream* is);
00675 void streamOut(UMemoryStream* os) const;
00676 void streamIn(UMemoryStream* is);
00677
00678 private:
00683 void resize(int32_t newSize);
00684
00685 int32_t fSize;
00686 int32_t fCapacity;
00687 EntryPair** fElements;
00688 UBool fBogus;
00689 };
00690
00691 class VectorOfPToContractTable;
00692
00696 class PToContractTable {
00697 public:
00701 ~PToContractTable();
00702
00709 const PToContractTable& operator=(VectorOfPToContractElement* newValue);
00710 const PToContractTable& operator=(const PToContractTable& pointerToNewValue);
00711
00715 operator VectorOfPToContractElement*() const;
00716
00717 private:
00721 PToContractTable(VectorOfPToContractElement*& value);
00725 PToContractTable(const PToContractTable& that);
00726
00727 VectorOfPToContractElement*& fValue;
00728
00729 friend class VectorOfPToContractTable;
00730 };
00731
00749 class VectorOfPToContractTable {
00750 public:
00755 enum EGrowthRate { GROWTH_RATE = 4 };
00760 VectorOfPToContractTable(int32_t initialSize = 0);
00764 VectorOfPToContractTable(const VectorOfPToContractTable& that);
00765
00766 ~VectorOfPToContractTable();
00767
00771 const VectorOfPToContractTable&
00772 operator=(const VectorOfPToContractTable& that);
00773
00784 PToContractTable operator[](int32_t index);
00785 PToContractTable at(int32_t index);
00786
00798 VectorOfPToContractElement* operator[](int32_t index) const;
00799 VectorOfPToContractElement* at(int32_t index) const;
00800
00807 void atPut( int32_t index,
00808 VectorOfPToContractElement* value);
00814 VectorOfPToContractElement* orphanAt(int32_t index);
00815
00820 int32_t size(void) const;
00821
00826 UBool isBogus(void) const;
00834 void streamOut(FileStream* os) const;
00835 void streamIn(FileStream* is);
00836
00837 void streamOut(UMemoryStream* os) const;
00838 void streamIn(UMemoryStream* is);
00839
00840 private:
00845 void resize(int32_t newSize);
00846
00847 int32_t fSize;
00848 int32_t fCapacity;
00849 VectorOfPToContractElement** fElements;
00850 UBool fBogus;
00851 };
00852
00853 class PatternEntry;
00854 class VectorOfPointersToPatternEntry;
00855
00866 class PointerToPatternEntry {
00867 public:
00871 ~PointerToPatternEntry();
00872
00877 const PointerToPatternEntry& operator=(PatternEntry* newValue);
00878 const PointerToPatternEntry& operator=(const PointerToPatternEntry& pointerToNewValue);
00879
00883 operator PatternEntry*() const;
00884
00885 private:
00889 PointerToPatternEntry(PatternEntry*& value);
00893 PointerToPatternEntry(const PointerToPatternEntry& that);
00894
00895 PatternEntry*& fValue;
00896
00897 friend class VectorOfPointersToPatternEntry;
00898 };
00899
00917 class VectorOfPointersToPatternEntry {
00918 public:
00923 enum EGrowthRate { GROWTH_RATE = 4 };
00928 VectorOfPointersToPatternEntry(int32_t initialSize = 0);
00932 VectorOfPointersToPatternEntry(const VectorOfPointersToPatternEntry& that);
00933
00937 ~VectorOfPointersToPatternEntry();
00938
00942 const VectorOfPointersToPatternEntry& operator=(const VectorOfPointersToPatternEntry& that);
00943
00954 PointerToPatternEntry operator[](int32_t index);
00955 inline PointerToPatternEntry at(int32_t index) { return (*this)[index]; }
00956
00968 PatternEntry* operator[](int32_t index) const;
00969 inline PatternEntry* at(int32_t index) const { return (*this)[index]; }
00970
00977 void atPut( int32_t index,
00978 PatternEntry* value);
00985 void atInsert( int32_t index,
00986 PatternEntry* value);
00992 PatternEntry* orphanAt(int32_t index);
00993
00997 void clear(void);
00998
01003 int32_t size(void) const;
01004
01009 int32_t indexOf(const PatternEntry* value) const;
01010
01015 int32_t lastIndexOf(const PatternEntry* value) const;
01016
01021 UBool isBogus(void) const;
01022 private:
01027 void resize(int32_t newSize);
01028
01029 int32_t fSize;
01030 int32_t fCapacity;
01031 PatternEntry** fElements;
01032 UBool fBogus;
01033 };
01034
01035 inline
01036 EntryPair::EntryPair(const UnicodeString& str, int32_t aValue, UBool aFwd)
01037 : value(aValue), fwd(aFwd), storage(new UnicodeString(str))
01038 {
01039 nameChars = storage->getUChars();
01040 nameLen = storage->size();
01041 }
01042
01043 inline
01044 EntryPair::EntryPair()
01045 : nameChars(NULL), nameLen(0), value(0xffffffff), fwd(TRUE), storage(NULL)
01046 {
01047 }
01048
01049 inline
01050 EntryPair::EntryPair(const UChar *name, int32_t nameLen, int32_t aValue, UBool aFwd)
01051 : nameChars(name), nameLen(nameLen), value(aValue), fwd(aFwd), storage(NULL)
01052 {
01053 }
01054
01055 inline
01056 EntryPair::~EntryPair()
01057 {
01058 if(storage) {
01059 delete(storage);
01060 storage = NULL;
01061 }
01062 }
01063
01064 inline UBool EntryPair::equalTo(const UChar *aName, int32_t aLen)
01065 {
01066 return( (aLen==nameLen)?!(u_strncmp(aName,nameChars,aLen)):0 );
01067 }
01068
01069 inline const UnicodeString&
01070 EntryPair::getEntryName()
01071 {
01072 if(storage != NULL) {
01073 return *storage;
01074 } else {
01075 return *(storage = new UnicodeString(nameChars, nameLen));
01076 }
01077 }
01078
01079
01080
01081
01082 inline int32_t
01083 VectorOfInt::operator[](int32_t index) const
01084 {
01085 return (index < fCapacity) ? fElements[index] : 0;
01086 }
01087
01088
01089 inline int32_t
01090 VectorOfInt::at(int32_t index) const
01091 {
01092 return (*this)[index];
01093 }
01094
01095 inline int32_t&
01096 VectorOfInt::at(int32_t index)
01097 {
01098 return (*this)[index];
01099 }
01100
01101 inline int32_t
01102 VectorOfInt::size() const
01103 {
01104 return fSize;
01105 }
01106
01107
01108
01109
01110
01111 inline void*
01112 VectorOfPointer::operator[](int32_t index) const
01113 {
01114 return (index < fCapacity) ? fElements[index] : 0;
01115 }
01116
01117
01118 inline void*
01119 VectorOfPointer::at(int32_t index) const
01120 {
01121 return (*this)[index];
01122 }
01123
01124 inline void*&
01125 VectorOfPointer::at(int32_t index)
01126 {
01127 return (*this)[index];
01128 }
01129
01130 inline int32_t
01131 VectorOfPointer::size() const
01132 {
01133 return fSize;
01134 }
01135
01136
01137
01138
01139 inline
01140 PToExpandTable::operator VectorOfInt*() const
01141 {
01142 return fValue;
01143 }
01144
01145 inline
01146 PToExpandTable::PToExpandTable(VectorOfInt*& value)
01147 : fValue(value)
01148 {
01149 }
01150
01151 inline
01152 PToExpandTable::PToExpandTable(const PToExpandTable& that)
01153 : fValue(that.fValue)
01154 {
01155 }
01156
01157 inline
01158 PToExpandTable::~PToExpandTable()
01159 {
01160 }
01161
01162 inline const PToExpandTable&
01163 PToExpandTable::operator=(VectorOfInt* newValue)
01164 {
01165 delete fValue;
01166 fValue = newValue;
01167 return *this;
01168 }
01169
01170 inline const PToExpandTable&
01171 PToExpandTable::operator=(const PToExpandTable& pointerToNewValue)
01172 {
01173 delete fValue;
01174 fValue = (VectorOfInt*)(pointerToNewValue);
01175 return *this;
01176 }
01177
01178
01179
01180
01181 inline VectorOfInt*
01182 VectorOfPToExpandTable::operator[](int32_t index) const
01183 {
01184 return (index < fCapacity) ? fElements[index] : 0;
01185 }
01186
01187 inline VectorOfInt*
01188 VectorOfPToExpandTable::at(int32_t index) const
01189 {
01190 return (*this)[index];
01191 }
01192
01193 inline PToExpandTable
01194 VectorOfPToExpandTable::at(int32_t index)
01195 {
01196 return (*this)[index];
01197 }
01198
01199 inline int32_t
01200 VectorOfPToExpandTable::size() const
01201 {
01202 return fSize;
01203 }
01204
01205
01206
01207
01208
01209 inline
01210 PToContractElement::operator EntryPair*() const
01211 {
01212 return fValue;
01213 }
01214
01215 inline
01216 PToContractElement::PToContractElement(EntryPair*& value)
01217 : fValue(value)
01218 {
01219 }
01220
01221 inline
01222 PToContractElement::PToContractElement(const PToContractElement& that)
01223 : fValue(that.fValue)
01224 {
01225 }
01226
01227 inline
01228 PToContractElement::~PToContractElement()
01229 {
01230 }
01231
01232 inline const PToContractElement&
01233 PToContractElement::operator=(EntryPair* newValue)
01234 {
01235 delete fValue;
01236 fValue = newValue;
01237 return *this;
01238 }
01239
01240 inline const PToContractElement&
01241 PToContractElement::operator=(const PToContractElement& pointerToNewValue)
01242 {
01243 delete fValue;
01244 fValue = (EntryPair*)(pointerToNewValue);
01245 return *this;
01246 }
01247
01248
01249
01250
01251
01252 inline EntryPair*
01253 VectorOfPToContractElement::operator[](int32_t index) const
01254 {
01255 return (index < fCapacity) ? fElements[index] : 0;
01256 }
01257
01258 inline EntryPair*
01259 VectorOfPToContractElement::at(int32_t index) const
01260 {
01261 return (*this)[index];
01262 }
01263
01264 inline PToContractElement
01265 VectorOfPToContractElement::at(int32_t index)
01266 {
01267 return (*this)[index];
01268 }
01269
01270 inline int32_t
01271 VectorOfPToContractElement::size() const
01272 {
01273 return fSize;
01274 }
01275
01276
01277
01278
01279
01280 inline
01281 PToContractTable::operator VectorOfPToContractElement*() const
01282 {
01283 return fValue;
01284 }
01285
01286 inline
01287 PToContractTable::PToContractTable(VectorOfPToContractElement*& value)
01288 : fValue(value)
01289 {
01290 }
01291
01292 inline
01293 PToContractTable::PToContractTable(const PToContractTable& that)
01294 : fValue(that.fValue)
01295 {
01296 }
01297
01298 inline
01299 PToContractTable::~PToContractTable()
01300 {
01301 }
01302
01303 inline const PToContractTable&
01304 PToContractTable::operator=(VectorOfPToContractElement* newValue)
01305 {
01306 delete fValue;
01307 fValue = newValue;
01308 return *this;
01309 }
01310
01311 inline const PToContractTable&
01312 PToContractTable::operator=(const PToContractTable& pointerToNewValue)
01313 {
01314 delete fValue;
01315 fValue = (VectorOfPToContractElement*)(pointerToNewValue);
01316 return *this;
01317 }
01318
01319
01320
01321
01322
01323 inline VectorOfPToContractElement*
01324 VectorOfPToContractTable::operator[](int32_t index) const
01325 {
01326 return (index < fCapacity) ? fElements[index] : 0;
01327 }
01328
01329 inline VectorOfPToContractElement*
01330 VectorOfPToContractTable::at(int32_t index) const
01331 {
01332 return (*this)[index];
01333 }
01334
01335 inline PToContractTable
01336 VectorOfPToContractTable::at(int32_t index)
01337 {
01338 return (*this)[index];
01339 }
01340
01341 inline int32_t
01342 VectorOfPToContractTable::size() const
01343 {
01344 return fSize;
01345 }
01346
01347 #endif