LEInsertionList.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. **********************************************************************
  3. * Copyright (C) 1998-2014, International Business Machines
  4. * Corporation and others. All Rights Reserved.
  5. **********************************************************************
  6. */
  7. #ifndef __LEINSERTIONLIST_H
  8. #define __LEINSERTIONLIST_H
  9. #include "LETypes.h"
  10. U_NAMESPACE_BEGIN
  11. struct InsertionRecord;
  12. #ifndef U_HIDE_INTERNAL_API
  13. /**
  14. * This class encapsulates the callback used by <code>LEInsertionList</code>
  15. * to apply an insertion from the insertion list.
  16. *
  17. * @internal
  18. */
  19. class U_LAYOUT_API LEInsertionCallback
  20. {
  21. public:
  22. /**
  23. * This method will be called by <code>LEInsertionList::applyInsertions</code> for each
  24. * entry on the insertion list.
  25. *
  26. * @param atPosition the position of the insertion
  27. * @param count the number of glyphs to insert
  28. * @param newGlyphs the address of the glyphs to insert
  29. *
  30. * @return <code>TRUE</code> if <code>LEInsertions::applyInsertions</code> should
  31. * stop after applying this insertion.
  32. *
  33. * @internal
  34. */
  35. virtual le_bool applyInsertion(le_int32 atPosition, le_int32 count, LEGlyphID newGlyphs[]) = 0;
  36. /**
  37. * The destructor
  38. */
  39. virtual ~LEInsertionCallback();
  40. };
  41. /**
  42. * This class is used to keep track of insertions to an array of
  43. * <code>LEGlyphIDs</code>. The insertions are kept on a linked
  44. * list of <code>InsertionRecords</code> so that the glyph array
  45. * doesn't have to be grown for each insertion. The insertions are
  46. * stored on the list from leftmost to rightmost to make it easier
  47. * to do the insertions.
  48. *
  49. * The insertions are applied to the array by calling the
  50. * <code>applyInsertions</code> method, which calls a client
  51. * supplied <code>LEInsertionCallback</code> object to actually
  52. * apply the individual insertions.
  53. *
  54. * @internal
  55. */
  56. class LEInsertionList : public UObject
  57. {
  58. public:
  59. /**
  60. * Construct an empty insertion list.
  61. *
  62. * @param rightToLeft <code>TRUE</code> if the glyphs are stored
  63. * in the array in right to left order.
  64. *
  65. * @internal
  66. */
  67. LEInsertionList(le_bool rightToLeft);
  68. /**
  69. * The destructor.
  70. */
  71. ~LEInsertionList();
  72. /**
  73. * Add an entry to the insertion list.
  74. *
  75. * @param position the glyph at this position in the array will be
  76. * replaced by the new glyphs.
  77. * @param count the number of new glyphs
  78. * @param success set to an error code if the auxillary data cannot be retrieved.
  79. *
  80. * @return the address of an array in which to store the new glyphs. This will
  81. * <em>not</em> be in the glyph array.
  82. *
  83. * @internal
  84. */
  85. LEGlyphID *insert(le_int32 position, le_int32 count, LEErrorCode &success);
  86. /**
  87. * Return the number of new glyphs that have been inserted.
  88. *
  89. * @return the number of new glyphs which have been inserted
  90. *
  91. * @internal
  92. */
  93. le_int32 getGrowAmount();
  94. /**
  95. * Call the <code>LEInsertionCallback</code> once for each
  96. * entry on the insertion list.
  97. *
  98. * @param callback the <code>LEInsertionCallback</code> to call for each insertion.
  99. *
  100. * @return <code>TRUE</code> if <code>callback</code> returned <code>TRUE</code> to
  101. * terminate the insertion list processing.
  102. *
  103. * @internal
  104. */
  105. le_bool applyInsertions(LEInsertionCallback *callback);
  106. /**
  107. * Empty the insertion list and free all associated
  108. * storage.
  109. *
  110. * @internal
  111. */
  112. void reset();
  113. /**
  114. * ICU "poor man's RTTI", returns a UClassID for the actual class.
  115. *
  116. * @deprecated ICU 54. See {@link icu::LayoutEngine}
  117. */
  118. virtual UClassID getDynamicClassID() const;
  119. /**
  120. * ICU "poor man's RTTI", returns a UClassID for this class.
  121. *
  122. * @deprecated ICU 54. See {@link icu::LayoutEngine}
  123. */
  124. static UClassID getStaticClassID();
  125. private:
  126. /**
  127. * The head of the insertion list.
  128. *
  129. * @internal
  130. */
  131. InsertionRecord *head;
  132. /**
  133. * The tail of the insertion list.
  134. *
  135. * @internal
  136. */
  137. InsertionRecord *tail;
  138. /**
  139. * The total number of new glyphs on the insertion list.
  140. *
  141. * @internal
  142. */
  143. le_int32 growAmount;
  144. /**
  145. * Set to <code>TRUE</code> if the glyphs are in right
  146. * to left order. Since we want the rightmost insertion
  147. * to be first on the list, we need to append the
  148. * insertions in this case. Otherwise they're prepended.
  149. *
  150. * @internal
  151. */
  152. le_bool append;
  153. };
  154. #endif /* U_HIDE_INTERNAL_API */
  155. U_NAMESPACE_END
  156. #endif