urep.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. ******************************************************************************
  3. * Copyright (C) 1997-2010, International Business Machines
  4. * Corporation and others. All Rights Reserved.
  5. ******************************************************************************
  6. * Date Name Description
  7. * 06/23/00 aliu Creation.
  8. ******************************************************************************
  9. */
  10. #ifndef __UREP_H
  11. #define __UREP_H
  12. #include "unicode/utypes.h"
  13. U_CDECL_BEGIN
  14. /********************************************************************
  15. * General Notes
  16. ********************************************************************
  17. * TODO
  18. * Add usage scenario
  19. * Add test code
  20. * Talk about pinning
  21. * Talk about "can truncate result if out of memory"
  22. */
  23. /********************************************************************
  24. * Data Structures
  25. ********************************************************************/
  26. /**
  27. * \file
  28. * \brief C API: Callbacks for UReplaceable
  29. */
  30. /**
  31. * An opaque replaceable text object. This will be manipulated only
  32. * through the caller-supplied UReplaceableFunctor struct. Related
  33. * to the C++ class Replaceable.
  34. * This is currently only used in the Transliterator C API, see utrans.h .
  35. * @stable ICU 2.0
  36. */
  37. typedef void* UReplaceable;
  38. /**
  39. * A set of function pointers that transliterators use to manipulate a
  40. * UReplaceable. The caller should supply the required functions to
  41. * manipulate their text appropriately. Related to the C++ class
  42. * Replaceable.
  43. * @stable ICU 2.0
  44. */
  45. typedef struct UReplaceableCallbacks {
  46. /**
  47. * Function pointer that returns the number of UChar code units in
  48. * this text.
  49. *
  50. * @param rep A pointer to "this" UReplaceable object.
  51. * @return The length of the text.
  52. * @stable ICU 2.0
  53. */
  54. int32_t (*length)(const UReplaceable* rep);
  55. /**
  56. * Function pointer that returns a UChar code units at the given
  57. * offset into this text; 0 <= offset < n, where n is the value
  58. * returned by (*length)(rep). See unistr.h for a description of
  59. * charAt() vs. char32At().
  60. *
  61. * @param rep A pointer to "this" UReplaceable object.
  62. * @param offset The index at which to fetch the UChar (code unit).
  63. * @return The UChar (code unit) at offset, or U+FFFF if the offset is out of bounds.
  64. * @stable ICU 2.0
  65. */
  66. UChar (*charAt)(const UReplaceable* rep,
  67. int32_t offset);
  68. /**
  69. * Function pointer that returns a UChar32 code point at the given
  70. * offset into this text. See unistr.h for a description of
  71. * charAt() vs. char32At().
  72. *
  73. * @param rep A pointer to "this" UReplaceable object.
  74. * @param offset The index at which to fetch the UChar32 (code point).
  75. * @return The UChar32 (code point) at offset, or U+FFFF if the offset is out of bounds.
  76. * @stable ICU 2.0
  77. */
  78. UChar32 (*char32At)(const UReplaceable* rep,
  79. int32_t offset);
  80. /**
  81. * Function pointer that replaces text between start and limit in
  82. * this text with the given text. Attributes (out of band info)
  83. * should be retained.
  84. *
  85. * @param rep A pointer to "this" UReplaceable object.
  86. * @param start the starting index of the text to be replaced,
  87. * inclusive.
  88. * @param limit the ending index of the text to be replaced,
  89. * exclusive.
  90. * @param text the new text to replace the UChars from
  91. * start..limit-1.
  92. * @param textLength the number of UChars at text, or -1 if text
  93. * is null-terminated.
  94. * @stable ICU 2.0
  95. */
  96. void (*replace)(UReplaceable* rep,
  97. int32_t start,
  98. int32_t limit,
  99. const UChar* text,
  100. int32_t textLength);
  101. /**
  102. * Function pointer that copies the characters in the range
  103. * [<tt>start</tt>, <tt>limit</tt>) into the array <tt>dst</tt>.
  104. *
  105. * @param rep A pointer to "this" UReplaceable object.
  106. * @param start offset of first character which will be copied
  107. * into the array
  108. * @param limit offset immediately following the last character to
  109. * be copied
  110. * @param dst array in which to copy characters. The length of
  111. * <tt>dst</tt> must be at least <tt>(limit - start)</tt>.
  112. * @stable ICU 2.1
  113. */
  114. void (*extract)(UReplaceable* rep,
  115. int32_t start,
  116. int32_t limit,
  117. UChar* dst);
  118. /**
  119. * Function pointer that copies text between start and limit in
  120. * this text to another index in the text. Attributes (out of
  121. * band info) should be retained. After this call, there will be
  122. * (at least) two copies of the characters originally located at
  123. * start..limit-1.
  124. *
  125. * @param rep A pointer to "this" UReplaceable object.
  126. * @param start the starting index of the text to be copied,
  127. * inclusive.
  128. * @param limit the ending index of the text to be copied,
  129. * exclusive.
  130. * @param dest the index at which the copy of the UChars should be
  131. * inserted.
  132. * @stable ICU 2.0
  133. */
  134. void (*copy)(UReplaceable* rep,
  135. int32_t start,
  136. int32_t limit,
  137. int32_t dest);
  138. } UReplaceableCallbacks;
  139. U_CDECL_END
  140. #endif