ICU 57.1 57.1
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"
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{
50public:
62 inline RunArray(const le_int32 *limits, le_int32 count);
63
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
149
155 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
156
162 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
163
164protected:
177 virtual void init(le_int32 capacity);
178
191 virtual void grow(le_int32 capacity);
192
203
204private:
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
222inline RunArray::RunArray()
223 : UObject(), fClientArrays(FALSE), fLimits(NULL), fCount(0), fCapacity(0)
224{
225 // nothing else to do...
226}
227
228inline RunArray::RunArray(const RunArray & /*other*/)
229 : UObject(), fClientArrays(FALSE), fLimits(NULL), fCount(0), fCapacity(0)
230{
231 // nothing else to do...
232}
233
235 : UObject(), fClientArrays(TRUE), fLimits(limits), fCount(count), fCapacity(count)
236{
237 // nothing else to do...
238}
239
241{
242 return fCount;
243}
244
245inline 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{
272public:
288 inline FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count);
289
302
308 virtual ~FontRuns();
309
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
364protected:
365 virtual void init(le_int32 capacity);
366 virtual void grow(le_int32 capacity);
367
368private:
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
383inline FontRuns::FontRuns()
384 : RunArray(0), fFonts(NULL)
385{
386 // nothing else to do...
387}
388
389inline FontRuns::FontRuns(const FontRuns & /*other*/)
390 : RunArray(0), fFonts(NULL)
391{
392 // nothing else to do...
393}
394
396 : RunArray(limits, count), fFonts(fonts)
397{
398 // nothing else to do...
399}
400
408{
409public:
425 inline LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count);
426
439
445 virtual ~LocaleRuns();
446
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
501protected:
502 virtual void init(le_int32 capacity);
503 virtual void grow(le_int32 capacity);
504
509
510private:
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
524 : RunArray(0), fLocales(NULL)
525{
526 // nothing else to do...
527}
528
529inline LocaleRuns::LocaleRuns(const LocaleRuns & /*other*/)
530 : RunArray(0), fLocales(NULL)
531{
532 // nothing else to do...
533}
534
536 : RunArray(limits, count), fLocales(locales)
537{
538 // nothing else to do...
539}
540
547{
548public:
563 inline ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count);
564
577
583 virtual ~ValueRuns();
584
599
600
623
629 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
630
636 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
637
638protected:
639 virtual void init(le_int32 capacity);
640 virtual void grow(le_int32 capacity);
641
642private:
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
658 : RunArray(0), fValues(NULL)
659{
660 // nothing else to do...
661}
662
663inline ValueRuns::ValueRuns(const ValueRuns & /*other*/)
664 : RunArray(0), fValues(NULL)
665{
666 // nothing else to do...
667}
668
669inline 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
C++ API: Layout Engine Font Instance object.
C API: Basic definitions for the ICU LayoutEngine.
int32_t le_int32
A type used for signed, 32-bit integers.
Definition LETypes.h:34
The FontRuns class associates pointers to LEFontInstance objects with runs of text.
Definition RunArrays.h:271
const LEFontInstance * getFont(le_int32 run) const
Get the LEFontInstance object assoicated with the given run of text.
le_int32 add(const LEFontInstance *font, le_int32 limit)
Add an LEFontInstance and limit index pair to the data arrays and return the run index where the data...
virtual void init(le_int32 capacity)
Create a data array with the given initial size.
FontRuns(le_int32 initialCapacity)
Construct an empty FontRuns object.
virtual ~FontRuns()
The destructor; virtual so that subclass destructors are invoked as well.
virtual void grow(le_int32 capacity)
Grow a data array to the given initial size.
FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count)
Construct a FontRuns object from pre-existing arrays of fonts and limit indices.
Definition RunArrays.h:395
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition RunArrays.h:362
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Definition RunArrays.h:355
This is a virtual base class that serves as the interface between a LayoutEngine and the platform fon...
"Smart pointer" base class; do not use directly: use LocalPointer etc.
The LocaleRuns class associates pointers to Locale objects with runs of text.
Definition RunArrays.h:408
const Locale * getLocale(le_int32 run) const
Get the Locale object assoicated with the given run of text.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Definition RunArrays.h:492
le_int32 add(const Locale *locale, le_int32 limit)
Add a Locale and limit index pair to the data arrays and return the run index where the data was stor...
LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count)
Construct a LocaleRuns object from pre-existing arrays of locales and limit indices.
Definition RunArrays.h:535
virtual void grow(le_int32 capacity)
Grow a data array to the given initial size.
virtual void init(le_int32 capacity)
Create a data array with the given initial size.
virtual ~LocaleRuns()
The destructor; virtual so that subclass destructors are invoked as well.
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition RunArrays.h:499
const Locale ** fLocales
Definition RunArrays.h:508
LocaleRuns(le_int32 initialCapacity)
Construct an empty LocaleRuns object.
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:185
The RunArray class is a base class for building classes which represent data that is associated with ...
Definition RunArrays.h:49
le_int32 getCount() const
Get the number of entries in the limit indices array.
Definition RunArrays.h:240
virtual void init(le_int32 capacity)
Create a data array with the given initial size.
RunArray(le_int32 initialCapacity)
Construct an empty RunArray object.
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition RunArrays.h:162
le_int32 getLimit() const
Get the last limit index.
Definition RunArrays.h:259
le_int32 add(le_int32 limit)
Add a limit index to the limit indices array and return the run index where it was stored.
le_bool fClientArrays
Set by the constructors to indicate whether or not the client supplied the data arrays.
Definition RunArrays.h:202
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Definition RunArrays.h:155
virtual void grow(le_int32 capacity)
Grow a data array to the given initial size.
void reset()
Reset the limit indices array.
Definition RunArrays.h:245
RunArray(const le_int32 *limits, le_int32 count)
Construct a RunArray object from a pre-existing array of limit indices.
Definition RunArrays.h:234
virtual ~RunArray()
The destructor; virtual so that subclass destructors are invoked as well.
UObject is the common ICU "boilerplate" class.
Definition uobject.h:221
The ValueRuns class associates integer values with runs of text.
Definition RunArrays.h:547
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition RunArrays.h:636
virtual ~ValueRuns()
The destructor; virtual so that subclass destructors are invoked as well.
ValueRuns(le_int32 initialCapacity)
Construct an empty ValueRuns object.
le_int32 getValue(le_int32 run) const
Get the integer value assoicated with the given run of text.
ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count)
Construct a ValueRuns object from pre-existing arrays of values and limit indices.
Definition RunArrays.h:669
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Definition RunArrays.h:629
virtual void grow(le_int32 capacity)
Grow a data array to the given initial size.
virtual void init(le_int32 capacity)
Create a data array with the given initial size.
le_int32 add(le_int32 value, le_int32 limit)
Add an integer value and limit index pair to the data arrays and return the run index where the data ...
C++ API: Locale ID object.
#define TRUE
The TRUE value of a UBool.
Definition umachine.h:238
#define FALSE
The FALSE value of a UBool.
Definition umachine.h:242
Basic definitions for ICU, for both C and C++ APIs.
#define NULL
Define NULL if necessary, to 0 for C++ and to ((void *)0) for C.
Definition utypes.h:186
#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
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:129