ICU 76.1 76.1
Loading...
Searching...
No Matches
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
25U_NAMESPACE_BEGIN
26
32#define INITIAL_CAPACITY 16
33
40#define CAPACITY_GROW_LIMIT 128
41
51{
52public:
64 inline RunArray(const le_int32 *limits, le_int32 count);
65
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
151
157 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
158
164 inline UClassID getDynamicClassID() const override { return getStaticClassID(); }
165
166protected:
179 virtual void init(le_int32 capacity);
180
193 virtual void grow(le_int32 capacity);
194
205
206private:
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
224inline RunArray::RunArray()
225 : UObject(), fClientArrays(false), fLimits(nullptr), fCount(0), fCapacity(0)
226{
227 // nothing else to do...
228}
229
230inline RunArray::RunArray(const RunArray & /*other*/)
231 : UObject(), fClientArrays(false), fLimits(nullptr), fCount(0), fCapacity(0)
232{
233 // nothing else to do...
234}
235
236inline 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
243{
244 return fCount;
245}
246
247inline void RunArray::reset()
248{
249 fCount = 0;
250}
251
253{
254 if (run < 0 || run >= fCount) {
255 return -1;
256 }
257
258 return fLimits[run];
259}
260
262{
263 return getLimit(fCount - 1);
264}
265
273{
274public:
290 inline FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count);
291
304
310 virtual ~FontRuns();
311
326
327
350 le_int32 add(const LEFontInstance *font, le_int32 limit);
351
357 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
358
364 inline UClassID getDynamicClassID() const override { return getStaticClassID(); }
365
366protected:
367 void init(le_int32 capacity) override;
368 void grow(le_int32 capacity) override;
369
370private:
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
385inline FontRuns::FontRuns()
386 : RunArray(0), fFonts(nullptr)
387{
388 // nothing else to do...
389}
390
391inline FontRuns::FontRuns(const FontRuns & /*other*/)
392 : RunArray(0), fFonts(nullptr)
393{
394 // nothing else to do...
395}
396
397inline 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
410{
411public:
427 inline LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count);
428
441
447 virtual ~LocaleRuns();
448
463
464
487 le_int32 add(const Locale *locale, le_int32 limit);
488
494 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
495
501 inline UClassID getDynamicClassID() const override { return getStaticClassID(); }
502
503protected:
504 void init(le_int32 capacity) override;
505 void grow(le_int32 capacity) override;
506
511
512private:
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
525inline LocaleRuns::LocaleRuns()
526 : RunArray(0), fLocales(nullptr)
527{
528 // nothing else to do...
529}
530
531inline LocaleRuns::LocaleRuns(const LocaleRuns & /*other*/)
532 : RunArray(0), fLocales(nullptr)
533{
534 // nothing else to do...
535}
536
537inline 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
549{
550public:
565 inline ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count);
566
579
585 virtual ~ValueRuns();
586
601
602
625
631 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
632
638 inline UClassID getDynamicClassID() const override { return getStaticClassID(); }
639
640protected:
641 void init(le_int32 capacity) override;
642 void grow(le_int32 capacity) override;
643
644private:
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
659inline ValueRuns::ValueRuns()
660 : RunArray(0), fValues(nullptr)
661{
662 // nothing else to do...
663}
664
665inline ValueRuns::ValueRuns(const ValueRuns & /*other*/)
666 : RunArray(0), fValues(nullptr)
667{
668 // nothing else to do...
669}
670
671inline 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
678#endif
The FontRuns class associates pointers to LEFontInstance objects with runs of text.
Definition RunArrays.h:273
const LEFontInstance * getFont(le_int32 run) const
Get the LEFontInstance object associated with the given run of text.
void grow(le_int32 capacity) override
Grow a data array to the given initial size.
virtual ~FontRuns()
The destructor; virtual so that subclass destructors are invoked as well.
UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition RunArrays.h:364
FontRuns(le_int32 initialCapacity)
Construct an empty FontRuns object.
void init(le_int32 capacity) override
Create a data array with the given initial size.
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...
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Definition RunArrays.h:357
"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:410
virtual ~LocaleRuns()
The destructor; virtual so that subclass destructors are invoked as well.
void init(le_int32 capacity) override
Create a data array with the given initial size.
const Locale * getLocale(le_int32 run) const
Get the Locale object associated with the given run of text.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Definition RunArrays.h:494
UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition RunArrays.h:501
LocaleRuns(le_int32 initialCapacity)
Construct an empty LocaleRuns object.
const Locale ** fLocales
Definition RunArrays.h:510
void grow(le_int32 capacity) override
Grow a data array to the given initial size.
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...
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:195
The RunArray class is a base class for building classes which represent data that is associated with ...
Definition RunArrays.h:51
virtual ~RunArray()
The destructor; virtual so that subclass destructors are invoked as well.
le_int32 getLimit() const
Get the last limit index.
Definition RunArrays.h:261
virtual void grow(le_int32 capacity)
Grow a data array to the given initial size.
le_bool fClientArrays
Set by the constructors to indicate whether or not the client supplied the data arrays.
Definition RunArrays.h:204
void reset()
Reset the limit indices array.
Definition RunArrays.h:247
UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition RunArrays.h:164
virtual void init(le_int32 capacity)
Create a data array with the given initial size.
RunArray(le_int32 initialCapacity)
Construct an empty RunArray object.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Definition RunArrays.h:157
le_int32 getCount() const
Get the number of entries in the limit indices array.
Definition RunArrays.h:242
le_int32 add(le_int32 limit)
Add a limit index to the limit indices array and return the run index where it was stored.
UObject is the common ICU "boilerplate" class.
Definition uobject.h:223
The ValueRuns class associates integer values with runs of text.
Definition RunArrays.h:549
virtual ~ValueRuns()
The destructor; virtual so that subclass destructors are invoked as well.
void init(le_int32 capacity) override
Create a data array with the given initial size.
UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition RunArrays.h:638
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 ...
le_int32 getValue(le_int32 run) const
Get the integer value associated with the given run of text.
void grow(le_int32 capacity) override
Grow a data array to the given initial size.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Definition RunArrays.h:631
ValueRuns(le_int32 initialCapacity)
Construct an empty ValueRuns object.
C++ API: Locale ID object.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
Basic definitions for ICU, for both C and C++ APIs.
#define U_LAYOUTEX_API
Set to export library symbols from inside the layout extensions library, and to import them from outs...
Definition utypes.h:318