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
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 le_int32 getLimit() const;
00102
00112 inline le_int32 getLimit(le_int32 run) const;
00113
00138 le_int32 add(le_int32 limit);
00139
00145 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00146
00152 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00153
00154 protected:
00167 virtual void init(le_int32 capacity);
00168
00181 virtual void grow(le_int32 capacity);
00182
00192 le_bool fClientArrays;
00193
00194 private:
00199 static const char fgClassID;
00200
00201 le_int32 ensureCapacity();
00202
00203 inline RunArray();
00204 inline RunArray(const RunArray & );
00205 inline RunArray &operator=(const RunArray & ) { return *this; };
00206
00207 const le_int32 *fLimits;
00208 le_int32 fCount;
00209 le_int32 fCapacity;
00210 };
00211
00212 inline RunArray::RunArray()
00213 : UObject(), fClientArrays(FALSE), fLimits(NULL), fCount(0), fCapacity(0)
00214 {
00215
00216 }
00217
00218 inline RunArray::RunArray(const RunArray & )
00219 : UObject(), fClientArrays(FALSE), fLimits(NULL), fCount(0), fCapacity(0)
00220 {
00221
00222 }
00223
00224 inline RunArray::RunArray(const le_int32 *limits, le_int32 count)
00225 : UObject(), fClientArrays(TRUE), fLimits(limits), fCount(count), fCapacity(count)
00226 {
00227
00228 }
00229
00230 inline le_int32 RunArray::getCount() const
00231 {
00232 return fCount;
00233 }
00234
00235 inline le_int32 RunArray::getLimit(le_int32 run) const
00236 {
00237 if (run < 0 || run >= fCount) {
00238 return -1;
00239 }
00240
00241 return fLimits[run];
00242 }
00243
00244 inline le_int32 RunArray::getLimit() const
00245 {
00246 return getLimit(fCount - 1);
00247 }
00248
00255 class U_LAYOUTEX_API FontRuns : public RunArray
00256 {
00257 public:
00273 inline FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count);
00274
00286 FontRuns(le_int32 initialCapacity);
00287
00293 virtual ~FontRuns();
00294
00308 const LEFontInstance *getFont(le_int32 run) const;
00309
00310
00333 le_int32 add(const LEFontInstance *font, le_int32 limit);
00334
00340 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00341
00347 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00348
00349 protected:
00350 virtual void init(le_int32 capacity);
00351 virtual void grow(le_int32 capacity);
00352
00353 private:
00354
00355 inline FontRuns();
00356 inline FontRuns(const FontRuns &other);
00357 inline FontRuns &operator=(const FontRuns & ) { return *this; };
00358
00363 static const char fgClassID;
00364
00365 const LEFontInstance **fFonts;
00366 };
00367
00368 inline FontRuns::FontRuns()
00369 : RunArray(0), fFonts(NULL)
00370 {
00371
00372 }
00373
00374 inline FontRuns::FontRuns(const FontRuns & )
00375 : RunArray(0), fFonts(NULL)
00376 {
00377
00378 }
00379
00380 inline FontRuns::FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count)
00381 : RunArray(limits, count), fFonts(fonts)
00382 {
00383
00384 }
00385
00392 class U_LAYOUTEX_API LocaleRuns : public RunArray
00393 {
00394 public:
00410 inline LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count);
00411
00423 LocaleRuns(le_int32 initialCapacity);
00424
00430 virtual ~LocaleRuns();
00431
00445 const Locale *getLocale(le_int32 run) const;
00446
00447
00470 le_int32 add(const Locale *locale, le_int32 limit);
00471
00477 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00478
00484 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00485
00486 protected:
00487 virtual void init(le_int32 capacity);
00488 virtual void grow(le_int32 capacity);
00489
00490 private:
00491
00492 inline LocaleRuns();
00493 inline LocaleRuns(const LocaleRuns &other);
00494 inline LocaleRuns &operator=(const LocaleRuns & ) { return *this; };
00495
00500 static const char fgClassID;
00501
00502 const Locale **fLocales;
00503 };
00504
00505 inline LocaleRuns::LocaleRuns()
00506 : RunArray(0), fLocales(NULL)
00507 {
00508
00509 }
00510
00511 inline LocaleRuns::LocaleRuns(const LocaleRuns & )
00512 : RunArray(0), fLocales(NULL)
00513 {
00514
00515 }
00516
00517 inline LocaleRuns::LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count)
00518 : RunArray(limits, count), fLocales(locales)
00519 {
00520
00521 }
00522
00528 class U_LAYOUTEX_API ValueRuns : public RunArray
00529 {
00530 public:
00545 inline ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count);
00546
00558 ValueRuns(le_int32 initialCapacity);
00559
00565 virtual ~ValueRuns();
00566
00580 le_int32 getValue(le_int32 run) const;
00581
00582
00604 le_int32 add(le_int32 value, le_int32 limit);
00605
00611 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00612
00618 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00619
00620 protected:
00621 virtual void init(le_int32 capacity);
00622 virtual void grow(le_int32 capacity);
00623
00624 private:
00625
00626 inline ValueRuns();
00627 inline ValueRuns(const ValueRuns &other);
00628 inline ValueRuns &operator=(const ValueRuns & ) { return *this; };
00629
00634 static const char fgClassID;
00635
00636 const le_int32 *fValues;
00637 };
00638
00639 inline ValueRuns::ValueRuns()
00640 : RunArray(0), fValues(NULL)
00641 {
00642
00643 }
00644
00645 inline ValueRuns::ValueRuns(const ValueRuns & )
00646 : RunArray(0), fValues(NULL)
00647 {
00648
00649 }
00650
00651 inline ValueRuns::ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count)
00652 : RunArray(limits, count), fValues(values)
00653 {
00654
00655 }
00656
00657 U_NAMESPACE_END
00658 #endif