ICU 74.1 74.1

RunArrays.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 **********************************************************************
5 * Copyright (C) 2003-2008, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
8 */
9
10 #ifndef __RUNARRAYS_H
11
12 #define __RUNARRAYS_H
13
14 #include "layout/LETypes.h"
15 #include "layout/LEFontInstance.h"
16
17 #include "unicode/utypes.h"
18 #include "unicode/locid.h"
19
25 U_NAMESPACE_BEGIN
26
32 #define INITIAL_CAPACITY 16
33
40 #define CAPACITY_GROW_LIMIT 128
41
50 class U_LAYOUTEX_API RunArray : public UObject
51 {
52 public:
64 inline RunArray(const le_int32 *limits, le_int32 count);
65
77 RunArray(le_int32 initialCapacity);
78
84 virtual ~RunArray();
85
93 inline le_int32 getCount() const;
94
103 inline void reset();
104
113 inline le_int32 getLimit() const;
114
124 inline le_int32 getLimit(le_int32 run) const;
125
150 le_int32 add(le_int32 limit);
151
157 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
158
164 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
165
166 protected:
179 virtual void init(le_int32 capacity);
180
193 virtual void grow(le_int32 capacity);
194
204 le_bool fClientArrays;
205
206 private:
211 static const char fgClassID;
212
213 le_int32 ensureCapacity();
214
215 inline RunArray();
216 inline RunArray(const RunArray & /*other*/);
217 inline RunArray &operator=(const RunArray & /*other*/) { return *this; };
218
219 const le_int32 *fLimits;
220 le_int32 fCount;
221 le_int32 fCapacity;
222 };
223
224 inline RunArray::RunArray()
225 : UObject(), fClientArrays(false), fLimits(nullptr), fCount(0), fCapacity(0)
226 {
227 // nothing else to do...
228 }
229
230 inline RunArray::RunArray(const RunArray & /*other*/)
231 : UObject(), fClientArrays(false), fLimits(nullptr), fCount(0), fCapacity(0)
232 {
233 // nothing else to do...
234 }
235
236 inline RunArray::RunArray(const le_int32 *limits, le_int32 count)
237 : UObject(), fClientArrays(true), fLimits(limits), fCount(count), fCapacity(count)
238 {
239 // nothing else to do...
240 }
241
242 inline le_int32 RunArray::getCount() const
243 {
244 return fCount;
245 }
246
247 inline void RunArray::reset()
248 {
249 fCount = 0;
250 }
251
252 inline le_int32 RunArray::getLimit(le_int32 run) const
253 {
254 if (run < 0 || run >= fCount) {
255 return -1;
256 }
257
258 return fLimits[run];
259 }
260
261 inline le_int32 RunArray::getLimit() const
262 {
263 return getLimit(fCount - 1);
264 }
265
272 class U_LAYOUTEX_API FontRuns : public RunArray
273 {
274 public:
290 inline FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count);
291
303 FontRuns(le_int32 initialCapacity);
304
310 virtual ~FontRuns();
311
325 const LEFontInstance *getFont(le_int32 run) const;
326
327
350 le_int32 add(const LEFontInstance *font, le_int32 limit);
351
357 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
358
364 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
365
366 protected:
367 virtual void init(le_int32 capacity);
368 virtual void grow(le_int32 capacity);
369
370 private:
371
372 inline FontRuns();
373 inline FontRuns(const FontRuns &other);
374 inline FontRuns &operator=(const FontRuns & /*other*/) { return *this; };
375
380 static const char fgClassID;
381
382 const LEFontInstance **fFonts;
383 };
384
385 inline FontRuns::FontRuns()
386 : RunArray(0), fFonts(nullptr)
387 {
388 // nothing else to do...
389 }
390
391 inline FontRuns::FontRuns(const FontRuns & /*other*/)
392 : RunArray(0), fFonts(nullptr)
393 {
394 // nothing else to do...
395 }
396
397 inline FontRuns::FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count)
398 : RunArray(limits, count), fFonts(fonts)
399 {
400 // nothing else to do...
401 }
402
409 class U_LAYOUTEX_API LocaleRuns : public RunArray
410 {
411 public:
427 inline LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count);
428
440 LocaleRuns(le_int32 initialCapacity);
441
447 virtual ~LocaleRuns();
448
462 const Locale *getLocale(le_int32 run) const;
463
464
487 le_int32 add(const Locale *locale, le_int32 limit);
488
494 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
495
501 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
502
503 protected:
504 virtual void init(le_int32 capacity);
505 virtual void grow(le_int32 capacity);
506
510 const Locale **fLocales;
511
512 private:
513
514 inline LocaleRuns();
515 inline LocaleRuns(const LocaleRuns &other);
516 inline LocaleRuns &operator=(const LocaleRuns & /*other*/) { return *this; };
517
522 static const char fgClassID;
523 };
524
525 inline LocaleRuns::LocaleRuns()
526 : RunArray(0), fLocales(nullptr)
527 {
528 // nothing else to do...
529 }
530
531 inline LocaleRuns::LocaleRuns(const LocaleRuns & /*other*/)
532 : RunArray(0), fLocales(nullptr)
533 {
534 // nothing else to do...
535 }
536
537 inline LocaleRuns::LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count)
538 : RunArray(limits, count), fLocales(locales)
539 {
540 // nothing else to do...
541 }
542
548 class U_LAYOUTEX_API ValueRuns : public RunArray
549 {
550 public:
565 inline ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count);
566
578 ValueRuns(le_int32 initialCapacity);
579
585 virtual ~ValueRuns();
586
600 le_int32 getValue(le_int32 run) const;
601
602
624 le_int32 add(le_int32 value, le_int32 limit);
625
631 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
632
638 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
639
640 protected:
641 virtual void init(le_int32 capacity);
642 virtual void grow(le_int32 capacity);
643
644 private:
645
646 inline ValueRuns();
647 inline ValueRuns(const ValueRuns &other);
648 inline ValueRuns &operator=(const ValueRuns & /*other*/) { return *this; };
649
654 static const char fgClassID;
655
656 const le_int32 *fValues;
657 };
658
659 inline ValueRuns::ValueRuns()
660 : RunArray(0), fValues(nullptr)
661 {
662 // nothing else to do...
663 }
664
665 inline ValueRuns::ValueRuns(const ValueRuns & /*other*/)
666 : RunArray(0), fValues(nullptr)
667 {
668 // nothing else to do...
669 }
670
671 inline ValueRuns::ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count)
672 : RunArray(limits, count), fValues(values)
673 {
674 // nothing else to do...
675 }
676
677 U_NAMESPACE_END
678 #endif
icu::FontRuns
The FontRuns class associates pointers to LEFontInstance objects with runs of text.
Definition: RunArrays.h:273
icu::FontRuns::~FontRuns
virtual ~FontRuns()
The destructor; virtual so that subclass destructors are invoked as well.
icu::FontRuns::init
virtual void init(le_int32 capacity)
Create a data array with the given initial size.
icu::FontRuns::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition: RunArrays.h:364
icu::FontRuns::getFont
const LEFontInstance * getFont(le_int32 run) const
Get the LEFontInstance object associated with the given run of text.
icu::FontRuns::FontRuns
FontRuns(le_int32 initialCapacity)
Construct an empty FontRuns object.
icu::FontRuns::add
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...
icu::FontRuns::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Definition: RunArrays.h:357
icu::FontRuns::grow
virtual void grow(le_int32 capacity)
Grow a data array to the given initial size.
icu::LocaleRuns
The LocaleRuns class associates pointers to Locale objects with runs of text.
Definition: RunArrays.h:410
icu::LocaleRuns::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition: RunArrays.h:501
icu::LocaleRuns::~LocaleRuns
virtual ~LocaleRuns()
The destructor; virtual so that subclass destructors are invoked as well.
icu::LocaleRuns::grow
virtual void grow(le_int32 capacity)
Grow a data array to the given initial size.
icu::LocaleRuns::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Definition: RunArrays.h:494
icu::LocaleRuns::LocaleRuns
LocaleRuns(le_int32 initialCapacity)
Construct an empty LocaleRuns object.
icu::LocaleRuns::fLocales
const Locale ** fLocales
Definition: RunArrays.h:510
icu::LocaleRuns::getLocale
const Locale * getLocale(le_int32 run) const
Get the Locale object associated with the given run of text.
icu::LocaleRuns::init
virtual void init(le_int32 capacity)
Create a data array with the given initial size.
icu::LocaleRuns::add
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...
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
icu::RunArray
The RunArray class is a base class for building classes which represent data that is associated with ...
Definition: RunArrays.h:51
icu::RunArray::~RunArray
virtual ~RunArray()
The destructor; virtual so that subclass destructors are invoked as well.
icu::RunArray::getLimit
le_int32 getLimit() const
Get the last limit index.
Definition: RunArrays.h:261
icu::RunArray::grow
virtual void grow(le_int32 capacity)
Grow a data array to the given initial size.
icu::RunArray::fClientArrays
le_bool fClientArrays
Set by the constructors to indicate whether or not the client supplied the data arrays.
Definition: RunArrays.h:204
icu::RunArray::reset
void reset()
Reset the limit indices array.
Definition: RunArrays.h:247
icu::RunArray::init
virtual void init(le_int32 capacity)
Create a data array with the given initial size.
icu::RunArray::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition: RunArrays.h:164
icu::RunArray::RunArray
RunArray(le_int32 initialCapacity)
Construct an empty RunArray object.
icu::RunArray::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Definition: RunArrays.h:157
icu::RunArray::getCount
le_int32 getCount() const
Get the number of entries in the limit indices array.
Definition: RunArrays.h:242
icu::RunArray::add
le_int32 add(le_int32 limit)
Add a limit index to the limit indices array and return the run index where it was stored.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::ValueRuns
The ValueRuns class associates integer values with runs of text.
Definition: RunArrays.h:549
icu::ValueRuns::~ValueRuns
virtual ~ValueRuns()
The destructor; virtual so that subclass destructors are invoked as well.
icu::ValueRuns::init
virtual void init(le_int32 capacity)
Create a data array with the given initial size.
icu::ValueRuns::add
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 ...
icu::ValueRuns::getValue
le_int32 getValue(le_int32 run) const
Get the integer value associated with the given run of text.
icu::ValueRuns::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Definition: RunArrays.h:631
icu::ValueRuns::grow
virtual void grow(le_int32 capacity)
Grow a data array to the given initial size.
icu::ValueRuns::ValueRuns
ValueRuns(le_int32 initialCapacity)
Construct an empty ValueRuns object.
icu::ValueRuns::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition: RunArrays.h:638
locid.h
C++ API: Locale ID object.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
U_LAYOUTEX_API
#define U_LAYOUTEX_API
Set to export library symbols from inside the layout extensions library, and to import them from outs...
Definition: utypes.h:303