+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
- * Copyright (C) 2003-2004, International Business Machines
+ * Copyright (C) 2003-2008, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
#include "unicode/utypes.h"
#include "unicode/locid.h"
+/**
+ * \file
+ * \brief C++ API: base class for building classes which represent data that is associated with runs of text.
+ */
+
U_NAMESPACE_BEGIN
/**
* The initial size of an array if it is unspecified.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
#define INITIAL_CAPACITY 16
* When an array needs to grow, it will double in size until
* it becomes this large, then it will grow by this amount.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
#define CAPACITY_GROW_LIMIT 128
* maintains an array of limit indices into the text, subclasses
* provide one or more arrays of data.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
class U_LAYOUTEX_API RunArray : public UObject
{
*
* @param count is the number of entries in the limit array.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- RunArray(const le_int32 *limits, le_int32 count);
+ inline RunArray(const le_int32 *limits, le_int32 count);
/**
* Construct an empty <code>RunArray</code> object. Clients can add limit
*
* @see add
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
RunArray(le_int32 initialCapacity);
/**
* The destructor; virtual so that subclass destructors are invoked as well.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
virtual ~RunArray();
*
* @return the number of entries in the limit indices array.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
+ */
+ inline le_int32 getCount() const;
+
+ /**
+ * Reset the limit indices array. This method sets the number of entries in the
+ * limit indices array to zero. It does not delete the array.
+ *
+ * Note: Subclass arrays will also be reset and not deleted.
+ *
+ * @stable ICU 3.6
*/
- le_int32 getCount() const;
+ inline void reset();
/**
* Get the last limit index. This is the number of characters in
*
* @return the last limit index.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- le_int32 getLimit() const;
+ inline le_int32 getLimit() const;
/**
* Get the limit index for a particular run of text.
*
* @return the limit index for the run, or -1 if <code>run</code> is out of bounds.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- le_int32 getLimit(le_int32 run) const;
+ inline le_int32 getLimit(le_int32 run) const;
/**
* Add a limit index to the limit indices array and return the run index
* @see init
* @see grow
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
le_int32 add(le_int32 limit);
/**
- * ICU "poor man's RTTI", returns a UClassID for the actual class.
+ * ICU "poor man's RTTI", returns a UClassID for this class.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
+ static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
/**
- * ICU "poor man's RTTI", returns a UClassID for this class.
+ * ICU "poor man's RTTI", returns a UClassID for the actual class.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
+ virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
protected:
/**
*
* @see add
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
virtual void init(le_int32 capacity);
*
* @see add
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
virtual void grow(le_int32 capacity);
* <code>add</code> method won't change the arrays
* and the destructor won't delete them.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
le_bool fClientArrays;
le_int32 ensureCapacity();
- RunArray();
- RunArray(const RunArray & /*other*/);
- RunArray &operator=(const RunArray & /*other*/) { return *this; };
+ inline RunArray();
+ inline RunArray(const RunArray & /*other*/);
+ inline RunArray &operator=(const RunArray & /*other*/) { return *this; };
const le_int32 *fLimits;
le_int32 fCount;
return fCount;
}
+inline void RunArray::reset()
+{
+ fCount = 0;
+}
+
inline le_int32 RunArray::getLimit(le_int32 run) const
{
if (run < 0 || run >= fCount) {
* The <code>FontRuns</code> class associates pointers to <code>LEFontInstance</code>
* objects with runs of text.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
class U_LAYOUTEX_API FontRuns : public RunArray
{
*
* @param count is the number of entries in the two arrays.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count);
+ inline FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count);
/**
* Construct an empty <code>FontRuns</code> object. Clients can add font and limit
*
* @see add
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
FontRuns(le_int32 initialCapacity);
/**
* The destructor; virtual so that subclass destructors are invoked as well.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
virtual ~FontRuns();
*
* @see RunArray::getLimit
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
const LEFontInstance *getFont(le_int32 run) const;
*
* @return the run index where the font and limit index were stored, or -1 if the data cannot be stored.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
le_int32 add(const LEFontInstance *font, le_int32 limit);
/**
- * ICU "poor man's RTTI", returns a UClassID for the actual class.
+ * ICU "poor man's RTTI", returns a UClassID for this class.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
+ static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
/**
- * ICU "poor man's RTTI", returns a UClassID for this class.
+ * ICU "poor man's RTTI", returns a UClassID for the actual class.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
+ virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
protected:
virtual void init(le_int32 capacity);
private:
- FontRuns();
- FontRuns(const FontRuns &other);
- FontRuns &operator=(const FontRuns & /*other*/) { return *this; };
+ inline FontRuns();
+ inline FontRuns(const FontRuns &other);
+ inline FontRuns &operator=(const FontRuns & /*other*/) { return *this; };
/**
* The address of this static class variable serves as this class's ID
* The <code>LocaleRuns</code> class associates pointers to <code>Locale</code>
* objects with runs of text.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
class U_LAYOUTEX_API LocaleRuns : public RunArray
{
*
* @param count is the number of entries in the two arrays.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count);
+ inline LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count);
/**
* Construct an empty <code>LocaleRuns</code> object. Clients can add locale and limit
*
* @see add
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
LocaleRuns(le_int32 initialCapacity);
/**
* The destructor; virtual so that subclass destructors are invoked as well.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
virtual ~LocaleRuns();
*
* @see RunArray::getLimit
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
const Locale *getLocale(le_int32 run) const;
*
* @return the run index where the locale and limit index were stored, or -1 if the data cannot be stored.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
le_int32 add(const Locale *locale, le_int32 limit);
/**
- * ICU "poor man's RTTI", returns a UClassID for the actual class.
+ * ICU "poor man's RTTI", returns a UClassID for this class.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
+ static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
/**
- * ICU "poor man's RTTI", returns a UClassID for this class.
+ * ICU "poor man's RTTI", returns a UClassID for the actual class.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
+ virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
protected:
virtual void init(le_int32 capacity);
virtual void grow(le_int32 capacity);
+ /**
+ * @internal
+ */
+ const Locale **fLocales;
+
private:
- LocaleRuns();
- LocaleRuns(const LocaleRuns &other);
- LocaleRuns &operator=(const LocaleRuns & /*other*/) { return *this; };
+ inline LocaleRuns();
+ inline LocaleRuns(const LocaleRuns &other);
+ inline LocaleRuns &operator=(const LocaleRuns & /*other*/) { return *this; };
/**
* The address of this static class variable serves as this class's ID
* for ICU "poor man's RTTI".
*/
static const char fgClassID;
-
- const Locale **fLocales;
};
inline LocaleRuns::LocaleRuns()
/**
* The <code>ValueRuns</code> class associates integer values with runs of text.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
class U_LAYOUTEX_API ValueRuns : public RunArray
{
*
* @param count is the number of entries in the two arrays.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count);
+ inline ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count);
/**
* Construct an empty <code>ValueRuns</code> object. Clients can add value and limit
*
* @see add
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
ValueRuns(le_int32 initialCapacity);
/**
* The destructor; virtual so that subclass destructors are invoked as well.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
virtual ~ValueRuns();
*
* @see RunArray::getLimit
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
le_int32 getValue(le_int32 run) const;
*
* @return the run index where the value and limit index were stored, or -1 if the data cannot be stored.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
le_int32 add(le_int32 value, le_int32 limit);
/**
- * ICU "poor man's RTTI", returns a UClassID for the actual class.
+ * ICU "poor man's RTTI", returns a UClassID for this class.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
+ static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
/**
- * ICU "poor man's RTTI", returns a UClassID for this class.
+ * ICU "poor man's RTTI", returns a UClassID for the actual class.
*
- * @draft ICU 2.6
+ * @stable ICU 3.2
*/
- static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
+ virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
protected:
virtual void init(le_int32 capacity);
private:
- ValueRuns();
- ValueRuns(const ValueRuns &other);
- ValueRuns &operator=(const ValueRuns & /*other*/) { return *this; };
+ inline ValueRuns();
+ inline ValueRuns(const ValueRuns &other);
+ inline ValueRuns &operator=(const ValueRuns & /*other*/) { return *this; };
/**
* The address of this static class variable serves as this class's ID