00001
00002
00003
00004
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
00018 U_NAMESPACE_BEGIN
00019
00025 #define INITIAL_CAPACITY 16
00026
00033 #define CAPACITY_GROW_LIMIT 128
00034
00043 class U_LAYOUTEX_API RunArray : public UObject
00044 {
00045 public:
00057 RunArray(const le_int32 *limits, le_int32 count);
00058
00070 RunArray(le_int32 initalCapacity);
00071
00077 virtual ~RunArray();
00078
00086 le_int32 getCount() const;
00087
00096 le_int32 getLimit() const;
00097
00107 le_int32 getLimit(le_int32 run) const;
00108
00133 le_int32 add(le_int32 limit);
00134
00140 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00141
00147 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00148
00149 protected:
00162 virtual void init(le_int32 capacity);
00163
00176 virtual void grow(le_int32 capacity);
00177
00187 le_bool fClientArrays;
00188
00189 private:
00194 static const char fgClassID;
00195
00196 le_int32 ensureCapacity();
00197
00198 RunArray();
00199 RunArray(const RunArray & );
00200 RunArray &operator=(const RunArray & ) { return *this; };
00201
00202 const le_int32 *fLimits;
00203 le_int32 fCount;
00204 le_int32 fCapacity;
00205 };
00206
00207 inline RunArray::RunArray()
00208 : UObject(), fClientArrays(FALSE), fLimits(NULL), fCount(0), fCapacity(0)
00209 {
00210
00211 }
00212
00213 inline RunArray::RunArray(const RunArray & )
00214 : UObject(), fClientArrays(FALSE), fLimits(NULL), fCount(0), fCapacity(0)
00215 {
00216
00217 }
00218
00219 inline RunArray::RunArray(const le_int32 *limits, le_int32 count)
00220 : UObject(), fClientArrays(TRUE), fLimits(limits), fCount(count), fCapacity(count)
00221 {
00222
00223 }
00224
00225 inline le_int32 RunArray::getCount() const
00226 {
00227 return fCount;
00228 }
00229
00230 inline le_int32 RunArray::getLimit(le_int32 run) const
00231 {
00232 if (run < 0 || run >= fCount) {
00233 return -1;
00234 }
00235
00236 return fLimits[run];
00237 }
00238
00239 inline le_int32 RunArray::getLimit() const
00240 {
00241 return getLimit(fCount - 1);
00242 }
00243
00250 class U_LAYOUTEX_API FontRuns : public RunArray
00251 {
00252 public:
00268 FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count);
00269
00281 FontRuns(le_int32 initialCapacity);
00282
00288 virtual ~FontRuns();
00289
00303 const LEFontInstance *getFont(le_int32 run) const;
00304
00305
00328 le_int32 add(const LEFontInstance *font, le_int32 limit);
00329
00335 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00336
00342 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00343
00344 protected:
00345 virtual void init(le_int32 capacity);
00346 virtual void grow(le_int32 capacity);
00347
00348 private:
00349
00350 FontRuns();
00351 FontRuns(const FontRuns &other);
00352 FontRuns &operator=(const FontRuns & ) { return *this; };
00353
00358 static const char fgClassID;
00359
00360 const LEFontInstance **fFonts;
00361 };
00362
00363 inline FontRuns::FontRuns()
00364 : RunArray(0), fFonts(NULL)
00365 {
00366
00367 }
00368
00369 inline FontRuns::FontRuns(const FontRuns & )
00370 : RunArray(0), fFonts(NULL)
00371 {
00372
00373 }
00374
00375 inline FontRuns::FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count)
00376 : RunArray(limits, count), fFonts(fonts)
00377 {
00378
00379 }
00380
00387 class U_LAYOUTEX_API LocaleRuns : public RunArray
00388 {
00389 public:
00405 LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count);
00406
00418 LocaleRuns(le_int32 initialCapacity);
00419
00425 virtual ~LocaleRuns();
00426
00440 const Locale *getLocale(le_int32 run) const;
00441
00442
00465 le_int32 add(const Locale *locale, le_int32 limit);
00466
00472 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00473
00479 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00480
00481 protected:
00482 virtual void init(le_int32 capacity);
00483 virtual void grow(le_int32 capacity);
00484
00485 private:
00486
00487 LocaleRuns();
00488 LocaleRuns(const LocaleRuns &other);
00489 LocaleRuns &operator=(const LocaleRuns & ) { return *this; };
00490
00495 static const char fgClassID;
00496
00497 const Locale **fLocales;
00498 };
00499
00500 inline LocaleRuns::LocaleRuns()
00501 : RunArray(0), fLocales(NULL)
00502 {
00503
00504 }
00505
00506 inline LocaleRuns::LocaleRuns(const LocaleRuns & )
00507 : RunArray(0), fLocales(NULL)
00508 {
00509
00510 }
00511
00512 inline LocaleRuns::LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count)
00513 : RunArray(limits, count), fLocales(locales)
00514 {
00515
00516 }
00517
00523 class U_LAYOUTEX_API ValueRuns : public RunArray
00524 {
00525 public:
00540 ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count);
00541
00553 ValueRuns(le_int32 initialCapacity);
00554
00560 virtual ~ValueRuns();
00561
00575 le_int32 getValue(le_int32 run) const;
00576
00577
00599 le_int32 add(le_int32 value, le_int32 limit);
00600
00606 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00607
00613 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00614
00615 protected:
00616 virtual void init(le_int32 capacity);
00617 virtual void grow(le_int32 capacity);
00618
00619 private:
00620
00621 ValueRuns();
00622 ValueRuns(const ValueRuns &other);
00623 ValueRuns &operator=(const ValueRuns & ) { return *this; };
00624
00629 static const char fgClassID;
00630
00631 const le_int32 *fValues;
00632 };
00633
00634 inline ValueRuns::ValueRuns()
00635 : RunArray(0), fValues(NULL)
00636 {
00637
00638 }
00639
00640 inline ValueRuns::ValueRuns(const ValueRuns & )
00641 : RunArray(0), fValues(NULL)
00642 {
00643
00644 }
00645
00646 inline ValueRuns::ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count)
00647 : RunArray(limits, count), fValues(values)
00648 {
00649
00650 }
00651
00652 U_NAMESPACE_END
00653 #endif