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:
00056 RunArray(const le_int32 *limits, le_int32 count);
00057
00069 RunArray(le_int32 initalCapacity);
00070
00076 virtual ~RunArray();
00077
00085 le_int32 getCount() const;
00086
00095 le_int32 getLimit() const;
00096
00106 le_int32 getLimit(le_int32 run) const;
00107
00132 le_int32 add(le_int32 limit);
00133
00139 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00140
00146 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00147
00148 protected:
00161 virtual void init(le_int32 capacity);
00162
00175 virtual void grow(le_int32 capacity);
00176
00186 le_bool fClientArrays;
00187
00188 private:
00193 static const char fgClassID;
00194
00195 le_int32 ensureCapacity();
00196
00197 RunArray();
00198 RunArray(const RunArray & );
00199 RunArray &operator=(const RunArray & ) { return *this; };
00200
00201 const le_int32 *fLimits;
00202 le_int32 fCount;
00203 le_int32 fCapacity;
00204 };
00205
00206 inline RunArray::RunArray()
00207 : UObject(), fClientArrays(false), fLimits(NULL), fCount(0), fCapacity(0)
00208 {
00209
00210 }
00211
00212 inline RunArray::RunArray(const RunArray & )
00213 : UObject(), fClientArrays(false), fLimits(NULL), fCount(0), fCapacity(0)
00214 {
00215
00216 }
00217
00218 inline RunArray::RunArray(const le_int32 *limits, le_int32 count)
00219 : UObject(), fClientArrays(true), fLimits(limits), fCount(count), fCapacity(count)
00220 {
00221
00222 }
00223
00224 inline le_int32 RunArray::getCount() const
00225 {
00226 return fCount;
00227 }
00228
00229 inline le_int32 RunArray::getLimit(le_int32 run) const
00230 {
00231 if (run < 0 || run >= fCount) {
00232 return -1;
00233 }
00234
00235 return fLimits[run];
00236 }
00237
00238 inline le_int32 RunArray::getLimit() const
00239 {
00240 return getLimit(fCount - 1);
00241 }
00242
00249 class U_LAYOUTEX_API FontRuns : public RunArray
00250 {
00251 public:
00264 FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count);
00265
00277 FontRuns(le_int32 initialCapacity);
00278
00284 virtual ~FontRuns();
00285
00299 const LEFontInstance *getFont(le_int32 run) const;
00300
00301
00323 le_int32 add(const LEFontInstance *font, le_int32 limit);
00324
00330 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00331
00337 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00338
00339 protected:
00340 virtual void init(le_int32 capacity);
00341 virtual void grow(le_int32 capacity);
00342
00343 private:
00344
00345 FontRuns();
00346 FontRuns(const FontRuns &other);
00347 FontRuns &operator=(const FontRuns & ) { return *this; };
00348
00353 static const char fgClassID;
00354
00355 const LEFontInstance **fFonts;
00356 };
00357
00358 inline FontRuns::FontRuns()
00359 : RunArray(0), fFonts(NULL)
00360 {
00361
00362 }
00363
00364 inline FontRuns::FontRuns(const FontRuns & )
00365 : RunArray(0), fFonts(NULL)
00366 {
00367
00368 }
00369
00370 inline FontRuns::FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count)
00371 : RunArray(limits, count), fFonts(fonts)
00372 {
00373
00374 }
00375
00382 class U_LAYOUTEX_API LocaleRuns : public RunArray
00383 {
00384 public:
00397 LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count);
00398
00410 LocaleRuns(le_int32 initialCapacity);
00411
00417 virtual ~LocaleRuns();
00418
00432 const Locale *getLocale(le_int32 run) const;
00433
00434
00456 le_int32 add(const Locale *locale, le_int32 limit);
00457
00463 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00464
00470 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00471
00472 protected:
00473 virtual void init(le_int32 capacity);
00474 virtual void grow(le_int32 capacity);
00475
00476 private:
00477
00478 LocaleRuns();
00479 LocaleRuns(const LocaleRuns &other);
00480 LocaleRuns &operator=(const LocaleRuns & ) { return *this; };
00481
00486 static const char fgClassID;
00487
00488 const Locale **fLocales;
00489 };
00490
00491 inline LocaleRuns::LocaleRuns()
00492 : RunArray(0), fLocales(NULL)
00493 {
00494
00495 }
00496
00497 inline LocaleRuns::LocaleRuns(const LocaleRuns & )
00498 : RunArray(0), fLocales(NULL)
00499 {
00500
00501 }
00502
00503 inline LocaleRuns::LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count)
00504 : RunArray(limits, count), fLocales(locales)
00505 {
00506
00507 }
00508
00514 class U_LAYOUTEX_API ValueRuns : public RunArray
00515 {
00516 public:
00529 ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count);
00530
00542 ValueRuns(le_int32 initialCapacity);
00543
00549 virtual ~ValueRuns();
00550
00564 le_int32 getValue(le_int32 run) const;
00565
00566
00588 le_int32 add(le_int32 value, le_int32 limit);
00589
00595 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00596
00602 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00603
00604 protected:
00605 virtual void init(le_int32 capacity);
00606 virtual void grow(le_int32 capacity);
00607
00608 private:
00609
00610 ValueRuns();
00611 ValueRuns(const ValueRuns &other);
00612 ValueRuns &operator=(const ValueRuns & ) { return *this; };
00613
00618 static const char fgClassID;
00619
00620 const le_int32 *fValues;
00621 };
00622
00623 inline ValueRuns::ValueRuns()
00624 : RunArray(0), fValues(NULL)
00625 {
00626
00627 }
00628
00629 inline ValueRuns::ValueRuns(const ValueRuns & )
00630 : RunArray(0), fValues(NULL)
00631 {
00632
00633 }
00634
00635 inline ValueRuns::ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count)
00636 : RunArray(limits, count), fValues(values)
00637 {
00638
00639 }
00640
00641 U_NAMESPACE_END
00642 #endif