ICU 4.8.1.1
4.8.1.1
|
00001 /* 00002 ********************************************************************** 00003 * Copyright (C) 2003-2008, International Business Machines 00004 * Corporation and others. All Rights Reserved. 00005 ********************************************************************** 00006 */ 00007 00008 #ifndef __RUNARRAYS_H 00009 00010 #define __RUNARRAYS_H 00011 00012 #include "layout/LETypes.h" 00013 #include "layout/LEFontInstance.h" 00014 00015 #include "unicode/utypes.h" 00016 #include "unicode/locid.h" 00017 00023 U_NAMESPACE_BEGIN 00024 00030 #define INITIAL_CAPACITY 16 00031 00038 #define CAPACITY_GROW_LIMIT 128 00039 00048 class U_LAYOUTEX_API RunArray : public UObject 00049 { 00050 public: 00062 inline RunArray(const le_int32 *limits, le_int32 count); 00063 00075 RunArray(le_int32 initialCapacity); 00076 00082 virtual ~RunArray(); 00083 00091 inline le_int32 getCount() const; 00092 00101 inline void reset(); 00102 00111 inline le_int32 getLimit() const; 00112 00122 inline le_int32 getLimit(le_int32 run) const; 00123 00148 le_int32 add(le_int32 limit); 00149 00155 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } 00156 00162 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } 00163 00164 protected: 00177 virtual void init(le_int32 capacity); 00178 00191 virtual void grow(le_int32 capacity); 00192 00202 le_bool fClientArrays; 00203 00204 private: 00209 static const char fgClassID; 00210 00211 le_int32 ensureCapacity(); 00212 00213 inline RunArray(); 00214 inline RunArray(const RunArray & /*other*/); 00215 inline RunArray &operator=(const RunArray & /*other*/) { return *this; }; 00216 00217 const le_int32 *fLimits; 00218 le_int32 fCount; 00219 le_int32 fCapacity; 00220 }; 00221 00222 inline RunArray::RunArray() 00223 : UObject(), fClientArrays(FALSE), fLimits(NULL), fCount(0), fCapacity(0) 00224 { 00225 // nothing else to do... 00226 } 00227 00228 inline RunArray::RunArray(const RunArray & /*other*/) 00229 : UObject(), fClientArrays(FALSE), fLimits(NULL), fCount(0), fCapacity(0) 00230 { 00231 // nothing else to do... 00232 } 00233 00234 inline RunArray::RunArray(const le_int32 *limits, le_int32 count) 00235 : UObject(), fClientArrays(TRUE), fLimits(limits), fCount(count), fCapacity(count) 00236 { 00237 // nothing else to do... 00238 } 00239 00240 inline le_int32 RunArray::getCount() const 00241 { 00242 return fCount; 00243 } 00244 00245 inline void RunArray::reset() 00246 { 00247 fCount = 0; 00248 } 00249 00250 inline le_int32 RunArray::getLimit(le_int32 run) const 00251 { 00252 if (run < 0 || run >= fCount) { 00253 return -1; 00254 } 00255 00256 return fLimits[run]; 00257 } 00258 00259 inline le_int32 RunArray::getLimit() const 00260 { 00261 return getLimit(fCount - 1); 00262 } 00263 00270 class U_LAYOUTEX_API FontRuns : public RunArray 00271 { 00272 public: 00288 inline FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count); 00289 00301 FontRuns(le_int32 initialCapacity); 00302 00308 virtual ~FontRuns(); 00309 00323 const LEFontInstance *getFont(le_int32 run) const; 00324 00325 00348 le_int32 add(const LEFontInstance *font, le_int32 limit); 00349 00355 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } 00356 00362 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } 00363 00364 protected: 00365 virtual void init(le_int32 capacity); 00366 virtual void grow(le_int32 capacity); 00367 00368 private: 00369 00370 inline FontRuns(); 00371 inline FontRuns(const FontRuns &other); 00372 inline FontRuns &operator=(const FontRuns & /*other*/) { return *this; }; 00373 00378 static const char fgClassID; 00379 00380 const LEFontInstance **fFonts; 00381 }; 00382 00383 inline FontRuns::FontRuns() 00384 : RunArray(0), fFonts(NULL) 00385 { 00386 // nothing else to do... 00387 } 00388 00389 inline FontRuns::FontRuns(const FontRuns & /*other*/) 00390 : RunArray(0), fFonts(NULL) 00391 { 00392 // nothing else to do... 00393 } 00394 00395 inline FontRuns::FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count) 00396 : RunArray(limits, count), fFonts(fonts) 00397 { 00398 // nothing else to do... 00399 } 00400 00407 class U_LAYOUTEX_API LocaleRuns : public RunArray 00408 { 00409 public: 00425 inline LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count); 00426 00438 LocaleRuns(le_int32 initialCapacity); 00439 00445 virtual ~LocaleRuns(); 00446 00460 const Locale *getLocale(le_int32 run) const; 00461 00462 00485 le_int32 add(const Locale *locale, le_int32 limit); 00486 00492 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } 00493 00499 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } 00500 00501 protected: 00502 virtual void init(le_int32 capacity); 00503 virtual void grow(le_int32 capacity); 00504 00508 const Locale **fLocales; 00509 00510 private: 00511 00512 inline LocaleRuns(); 00513 inline LocaleRuns(const LocaleRuns &other); 00514 inline LocaleRuns &operator=(const LocaleRuns & /*other*/) { return *this; }; 00515 00520 static const char fgClassID; 00521 }; 00522 00523 inline LocaleRuns::LocaleRuns() 00524 : RunArray(0), fLocales(NULL) 00525 { 00526 // nothing else to do... 00527 } 00528 00529 inline LocaleRuns::LocaleRuns(const LocaleRuns & /*other*/) 00530 : RunArray(0), fLocales(NULL) 00531 { 00532 // nothing else to do... 00533 } 00534 00535 inline LocaleRuns::LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count) 00536 : RunArray(limits, count), fLocales(locales) 00537 { 00538 // nothing else to do... 00539 } 00540 00546 class U_LAYOUTEX_API ValueRuns : public RunArray 00547 { 00548 public: 00563 inline ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count); 00564 00576 ValueRuns(le_int32 initialCapacity); 00577 00583 virtual ~ValueRuns(); 00584 00598 le_int32 getValue(le_int32 run) const; 00599 00600 00622 le_int32 add(le_int32 value, le_int32 limit); 00623 00629 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } 00630 00636 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } 00637 00638 protected: 00639 virtual void init(le_int32 capacity); 00640 virtual void grow(le_int32 capacity); 00641 00642 private: 00643 00644 inline ValueRuns(); 00645 inline ValueRuns(const ValueRuns &other); 00646 inline ValueRuns &operator=(const ValueRuns & /*other*/) { return *this; }; 00647 00652 static const char fgClassID; 00653 00654 const le_int32 *fValues; 00655 }; 00656 00657 inline ValueRuns::ValueRuns() 00658 : RunArray(0), fValues(NULL) 00659 { 00660 // nothing else to do... 00661 } 00662 00663 inline ValueRuns::ValueRuns(const ValueRuns & /*other*/) 00664 : RunArray(0), fValues(NULL) 00665 { 00666 // nothing else to do... 00667 } 00668 00669 inline ValueRuns::ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count) 00670 : RunArray(limits, count), fValues(values) 00671 { 00672 // nothing else to do... 00673 } 00674 00675 U_NAMESPACE_END 00676 #endif