Loading...
Searching...
No Matches
RunArrays.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
* Copyright (C) 2003-2008, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
#ifndef __RUNARRAYS_H
#define __RUNARRAYS_H
#include "layout/LETypes.h"
#include "layout/LEFontInstance.h"
#include "unicode/utypes.h"
#include "unicode/locid.h"
U_NAMESPACE_BEGIN
#define INITIAL_CAPACITY 16
#define CAPACITY_GROW_LIMIT 128
class U_LAYOUTEX_API RunArray : public UObject
{
public:
inline RunArray(const le_int32 *limits, le_int32 count);
RunArray(le_int32 initialCapacity);
virtual ~RunArray();
inline le_int32 getCount() const;
inline void reset();
inline le_int32 getLimit() const;
inline le_int32 getLimit(le_int32 run) const;
le_int32 add(le_int32 limit);
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
inline UClassID getDynamicClassID() const override { return getStaticClassID(); }
protected:
virtual void init(le_int32 capacity);
virtual void grow(le_int32 capacity);
le_bool fClientArrays;
private:
static const char fgClassID;
le_int32 ensureCapacity();
inline RunArray();
inline RunArray(const RunArray & /*other*/);
inline RunArray &operator=(const RunArray & /*other*/) { return *this; }
const le_int32 *fLimits;
le_int32 fCount;
le_int32 fCapacity;
};
inline RunArray::RunArray()
: UObject(), fClientArrays(false), fLimits(nullptr), fCount(0), fCapacity(0)
{
// nothing else to do...
}
inline RunArray::RunArray(const RunArray & /*other*/)
: UObject(), fClientArrays(false), fLimits(nullptr), fCount(0), fCapacity(0)
{
// nothing else to do...
}
inline RunArray::RunArray(const le_int32 *limits, le_int32 count)
: UObject(), fClientArrays(true), fLimits(limits), fCount(count), fCapacity(count)
{
// nothing else to do...
}
inline le_int32 RunArray::getCount() const
{
return fCount;
}
inline void RunArray::reset()
{
fCount = 0;
}
inline le_int32 RunArray::getLimit(le_int32 run) const
{
if (run < 0 || run >= fCount) {
return -1;
}
return fLimits[run];
}
inline le_int32 RunArray::getLimit() const
{
return getLimit(fCount - 1);
}
class U_LAYOUTEX_API FontRuns : public RunArray
{
public:
inline FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count);
FontRuns(le_int32 initialCapacity);
virtual ~FontRuns();
const LEFontInstance *getFont(le_int32 run) const;
le_int32 add(const LEFontInstance *font, le_int32 limit);
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
inline UClassID getDynamicClassID() const override { return getStaticClassID(); }
protected:
void init(le_int32 capacity) override;
void grow(le_int32 capacity) override;
private:
inline FontRuns();
inline FontRuns(const FontRuns &other);
inline FontRuns &operator=(const FontRuns & /*other*/) { return *this; }
static const char fgClassID;
const LEFontInstance **fFonts;
};
inline FontRuns::FontRuns()
: RunArray(0), fFonts(nullptr)
{
// nothing else to do...
}
inline FontRuns::FontRuns(const FontRuns & /*other*/)
: RunArray(0), fFonts(nullptr)
{
// nothing else to do...
}
inline FontRuns::FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count)
: RunArray(limits, count), fFonts(fonts)
{
// nothing else to do...
}
class U_LAYOUTEX_API LocaleRuns : public RunArray
{
public:
inline LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count);
LocaleRuns(le_int32 initialCapacity);
virtual ~LocaleRuns();
const Locale *getLocale(le_int32 run) const;
le_int32 add(const Locale *locale, le_int32 limit);
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
inline UClassID getDynamicClassID() const override { return getStaticClassID(); }
protected:
void init(le_int32 capacity) override;
void grow(le_int32 capacity) override;
const Locale **fLocales;
private:
inline LocaleRuns();
inline LocaleRuns(const LocaleRuns &other);
inline LocaleRuns &operator=(const LocaleRuns & /*other*/) { return *this; }
static const char fgClassID;
};
inline LocaleRuns::LocaleRuns()
: RunArray(0), fLocales(nullptr)
{
// nothing else to do...
}
inline LocaleRuns::LocaleRuns(const LocaleRuns & /*other*/)
: RunArray(0), fLocales(nullptr)
{
// nothing else to do...
}
inline LocaleRuns::LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count)
: RunArray(limits, count), fLocales(locales)
{
// nothing else to do...
}
class U_LAYOUTEX_API ValueRuns : public RunArray
{
public:
inline ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count);
ValueRuns(le_int32 initialCapacity);
virtual ~ValueRuns();
le_int32 getValue(le_int32 run) const;
le_int32 add(le_int32 value, le_int32 limit);
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
inline UClassID getDynamicClassID() const override { return getStaticClassID(); }
protected:
void init(le_int32 capacity) override;
void grow(le_int32 capacity) override;
private:
inline ValueRuns();
inline ValueRuns(const ValueRuns &other);
inline ValueRuns &operator=(const ValueRuns & /*other*/) { return *this; }
static const char fgClassID;
const le_int32 *fValues;
};
inline ValueRuns::ValueRuns()
: RunArray(0), fValues(nullptr)
{
// nothing else to do...
}
inline ValueRuns::ValueRuns(const ValueRuns & /*other*/)
: RunArray(0), fValues(nullptr)
{
// nothing else to do...
}
inline ValueRuns::ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count)
: RunArray(limits, count), fValues(values)
{
// nothing else to do...
}
U_NAMESPACE_END
#endif
icu::FontRuns
The FontRuns class associates pointers to LEFontInstance objects with runs of text.
Definition RunArrays.h:273
icu::FontRuns::getFont
const LEFontInstance * getFont(le_int32 run) const
Get the LEFontInstance object associated with the given run of text.
icu::FontRuns::grow
void grow(le_int32 capacity) override
Grow a data array to the given initial size.
icu::FontRuns::~FontRuns
virtual ~FontRuns()
The destructor; virtual so that subclass destructors are invoked as well.
icu::FontRuns::FontRuns
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:397
icu::FontRuns::getDynamicClassID
UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition RunArrays.h:364
icu::FontRuns::FontRuns
FontRuns(le_int32 initialCapacity)
Construct an empty FontRuns object.
icu::FontRuns::init
void init(le_int32 capacity) override
Create a data array with the given initial size.
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::LocaleRuns
The LocaleRuns class associates pointers to Locale objects with runs of text.
Definition RunArrays.h:410
icu::LocaleRuns::~LocaleRuns
virtual ~LocaleRuns()
The destructor; virtual so that subclass destructors are invoked as well.
icu::LocaleRuns::LocaleRuns
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:537
icu::LocaleRuns::init
void init(le_int32 capacity) override
Create a data array with the given initial size.
icu::LocaleRuns::getLocale
const Locale * getLocale(le_int32 run) const
Get the Locale object associated with the given run of text.
icu::LocaleRuns::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Definition RunArrays.h:494
icu::LocaleRuns::getDynamicClassID
UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition RunArrays.h:501
icu::LocaleRuns::LocaleRuns
LocaleRuns(le_int32 initialCapacity)
Construct an empty LocaleRuns object.
icu::LocaleRuns::fLocales
const Locale ** fLocales
Definition RunArrays.h:510
icu::LocaleRuns::grow
void grow(le_int32 capacity) override
Grow a data array to 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:198
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::getDynamicClassID
UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition RunArrays.h:164
icu::RunArray::RunArray
RunArray(const le_int32 *limits, le_int32 count)
Construct a RunArray object from a pre-existing array of limit indices.
Definition RunArrays.h:236
icu::RunArray::init
virtual void init(le_int32 capacity)
Create a data array with the given initial size.
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:222
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
void init(le_int32 capacity) override
Create a data array with the given initial size.
icu::ValueRuns::getDynamicClassID
UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition RunArrays.h:638
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::grow
void grow(le_int32 capacity) override
Grow a data array to the given initial size.
icu::ValueRuns::ValueRuns
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:671
icu::ValueRuns::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Definition RunArrays.h:631
icu::ValueRuns::ValueRuns
ValueRuns(le_int32 initialCapacity)
Construct an empty ValueRuns object.
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:318