ICU 50.1.2  50.1.2
RunArrays.h
Go to the documentation of this file.
1 /*
2  **********************************************************************
3  * Copyright (C) 2003-2008, International Business Machines
4  * Corporation and others. All Rights Reserved.
5  **********************************************************************
6  */
7 
8 #ifndef __RUNARRAYS_H
9 
10 #define __RUNARRAYS_H
11 
12 #include "layout/LETypes.h"
13 #include "layout/LEFontInstance.h"
14 
15 #include "unicode/utypes.h"
16 #include "unicode/locid.h"
17 
24 
30 #define INITIAL_CAPACITY 16
31 
38 #define CAPACITY_GROW_LIMIT 128
39 
49 {
50 public:
62  inline RunArray(const le_int32 *limits, le_int32 count);
63 
75  RunArray(le_int32 initialCapacity);
76 
82  virtual ~RunArray();
83 
91  inline le_int32 getCount() const;
92 
101  inline void reset();
102 
111  inline le_int32 getLimit() const;
112 
122  inline le_int32 getLimit(le_int32 run) const;
123 
148  le_int32 add(le_int32 limit);
149 
155  static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
156 
162  virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
163 
164 protected:
177  virtual void init(le_int32 capacity);
178 
191  virtual void grow(le_int32 capacity);
192 
203 
204 private:
209  static const char fgClassID;
210 
211  le_int32 ensureCapacity();
212 
213  inline RunArray();
214  inline RunArray(const RunArray & /*other*/);
215  inline RunArray &operator=(const RunArray & /*other*/) { return *this; };
216 
217  const le_int32 *fLimits;
218  le_int32 fCount;
219  le_int32 fCapacity;
220 };
221 
222 inline RunArray::RunArray()
223  : UObject(), fClientArrays(FALSE), fLimits(NULL), fCount(0), fCapacity(0)
224 {
225  // nothing else to do...
226 }
227 
228 inline RunArray::RunArray(const RunArray & /*other*/)
229  : UObject(), fClientArrays(FALSE), fLimits(NULL), fCount(0), fCapacity(0)
230 {
231  // nothing else to do...
232 }
233 
234 inline RunArray::RunArray(const le_int32 *limits, le_int32 count)
235  : UObject(), fClientArrays(TRUE), fLimits(limits), fCount(count), fCapacity(count)
236 {
237  // nothing else to do...
238 }
239 
241 {
242  return fCount;
243 }
244 
245 inline void RunArray::reset()
246 {
247  fCount = 0;
248 }
249 
251 {
252  if (run < 0 || run >= fCount) {
253  return -1;
254  }
255 
256  return fLimits[run];
257 }
258 
260 {
261  return getLimit(fCount - 1);
262 }
263 
271 {
272 public:
288  inline FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count);
289 
301  FontRuns(le_int32 initialCapacity);
302 
308  virtual ~FontRuns();
309 
323  const LEFontInstance *getFont(le_int32 run) const;
324 
325 
348  le_int32 add(const LEFontInstance *font, le_int32 limit);
349 
355  static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
356 
362  virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
363 
364 protected:
365  virtual void init(le_int32 capacity);
366  virtual void grow(le_int32 capacity);
367 
368 private:
369 
370  inline FontRuns();
371  inline FontRuns(const FontRuns &other);
372  inline FontRuns &operator=(const FontRuns & /*other*/) { return *this; };
373 
378  static const char fgClassID;
379 
380  const LEFontInstance **fFonts;
381 };
382 
383 inline FontRuns::FontRuns()
384  : RunArray(0), fFonts(NULL)
385 {
386  // nothing else to do...
387 }
388 
389 inline FontRuns::FontRuns(const FontRuns & /*other*/)
390  : RunArray(0), fFonts(NULL)
391 {
392  // nothing else to do...
393 }
394 
395 inline FontRuns::FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count)
396  : RunArray(limits, count), fFonts(fonts)
397 {
398  // nothing else to do...
399 }
400 
408 {
409 public:
425  inline LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count);
426 
438  LocaleRuns(le_int32 initialCapacity);
439 
445  virtual ~LocaleRuns();
446 
460  const Locale *getLocale(le_int32 run) const;
461 
462 
485  le_int32 add(const Locale *locale, le_int32 limit);
486 
492  static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
493 
499  virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
500 
501 protected:
502  virtual void init(le_int32 capacity);
503  virtual void grow(le_int32 capacity);
504 
508  const Locale **fLocales;
509 
510 private:
511 
512  inline LocaleRuns();
513  inline LocaleRuns(const LocaleRuns &other);
514  inline LocaleRuns &operator=(const LocaleRuns & /*other*/) { return *this; };
515 
520  static const char fgClassID;
521 };
522 
523 inline LocaleRuns::LocaleRuns()
524  : RunArray(0), fLocales(NULL)
525 {
526  // nothing else to do...
527 }
528 
529 inline LocaleRuns::LocaleRuns(const LocaleRuns & /*other*/)
530  : RunArray(0), fLocales(NULL)
531 {
532  // nothing else to do...
533 }
534 
535 inline LocaleRuns::LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count)
536  : RunArray(limits, count), fLocales(locales)
537 {
538  // nothing else to do...
539 }
540 
547 {
548 public:
563  inline ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count);
564 
576  ValueRuns(le_int32 initialCapacity);
577 
583  virtual ~ValueRuns();
584 
598  le_int32 getValue(le_int32 run) const;
599 
600 
622  le_int32 add(le_int32 value, le_int32 limit);
623 
629  static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
630 
636  virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
637 
638 protected:
639  virtual void init(le_int32 capacity);
640  virtual void grow(le_int32 capacity);
641 
642 private:
643 
644  inline ValueRuns();
645  inline ValueRuns(const ValueRuns &other);
646  inline ValueRuns &operator=(const ValueRuns & /*other*/) { return *this; };
647 
652  static const char fgClassID;
653 
654  const le_int32 *fValues;
655 };
656 
657 inline ValueRuns::ValueRuns()
658  : RunArray(0), fValues(NULL)
659 {
660  // nothing else to do...
661 }
662 
663 inline ValueRuns::ValueRuns(const ValueRuns & /*other*/)
664  : RunArray(0), fValues(NULL)
665 {
666  // nothing else to do...
667 }
668 
669 inline ValueRuns::ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count)
670  : RunArray(limits, count), fValues(values)
671 {
672  // nothing else to do...
673 }
674 
676 #endif
le_int32 getCount() const
Get the number of entries in the limit indices array.
Definition: RunArrays.h:240
virtual UClassID getDynamicClassID() const
ICU &quot;poor man&#39;s RTTI&quot;, returns a UClassID for the actual class.
Definition: RunArrays.h:362
static UClassID getStaticClassID()
ICU &quot;poor man&#39;s RTTI&quot;, returns a UClassID for this class.
Definition: RunArrays.h:155
static UClassID getStaticClassID()
ICU &quot;poor man&#39;s RTTI&quot;, returns a UClassID for this class.
Definition: RunArrays.h:355
virtual UClassID getDynamicClassID() const
ICU &quot;poor man&#39;s RTTI&quot;, returns a UClassID for the actual class.
Definition: RunArrays.h:162
const Locale ** fLocales
Definition: RunArrays.h:508
le_int32 getLimit() const
Get the last limit index.
Definition: RunArrays.h:259
void * UClassID
UClassID is used to identify classes without using the compiler&#39;s RTTI.
Definition: uobject.h:96
virtual UClassID getDynamicClassID() const
ICU &quot;poor man&#39;s RTTI&quot;, returns a UClassID for the actual class.
Definition: RunArrays.h:636
C API: Basic definitions for the ICU LayoutEngine.
static UClassID getStaticClassID()
ICU &quot;poor man&#39;s RTTI&quot;, returns a UClassID for this class.
Definition: RunArrays.h:492
The FontRuns class associates pointers to LEFontInstance objects with runs of text.
Definition: RunArrays.h:270
int32_t le_int32
A type used for signed, 32-bit integers.
Definition: LETypes.h:34
UBool le_bool
A type used for boolean values.
Definition: LETypes.h:77
The LocaleRuns class associates pointers to Locale objects with runs of text.
Definition: RunArrays.h:407
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
#define NULL
Define NULL if necessary, to 0 for C++ and to ((void *)0) for C.
Definition: utypes.h:186
le_bool fClientArrays
Set by the constructors to indicate whether or not the client supplied the data arrays.
Definition: RunArrays.h:202
void reset()
Reset the limit indices array.
Definition: RunArrays.h:245
#define TRUE
The TRUE value of a UBool.
Definition: umachine.h:204
virtual UClassID getDynamicClassID() const
ICU &quot;poor man&#39;s RTTI&quot;, returns a UClassID for the actual class.
Definition: RunArrays.h:499
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
#define U_LAYOUTEX_API
Set to export library symbols from inside the layout extensions library, and to import them from outs...
Definition: utypes.h:360
The ValueRuns class associates integer values with runs of text.
Definition: RunArrays.h:546
static UClassID getStaticClassID()
ICU &quot;poor man&#39;s RTTI&quot;, returns a UClassID for this class.
Definition: RunArrays.h:629
C++ API: Locale ID object.
This is a virtual base class that serves as the interface between a LayoutEngine and the platform fon...
Basic definitions for ICU, for both C and C++ APIs.
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:208
C++ API: Layout Engine Font Instance object.
UObject is the common ICU &quot;boilerplate&quot; class.
Definition: uobject.h:229
The RunArray class is a base class for building classes which represent data that is associated with ...
Definition: RunArrays.h:48
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:182