uenumimp.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. *******************************************************************************
  5. *
  6. * Copyright (C) 2002-2006, International Business Machines
  7. * Corporation and others. All Rights Reserved.
  8. *
  9. *******************************************************************************
  10. * file name: uenumimp.h
  11. * encoding: UTF-8
  12. * tab size: 8 (not used)
  13. * indentation:2
  14. *
  15. * created on: 2002jul08
  16. * created by: Vladimir Weinstein
  17. */
  18. #ifndef __UENUMIMP_H
  19. #define __UENUMIMP_H
  20. #include "unicode/uenum.h"
  21. U_CDECL_BEGIN
  22. /**
  23. * following are the type declarations for
  24. * implementations of APIs. If any of these
  25. * functions are NULL, U_UNSUPPORTED_ERROR
  26. * is returned. If close is NULL, the enumeration
  27. * object is going to be released.
  28. * Initial error checking is done in the body
  29. * of API function, so the implementations
  30. * need not to check the initial error condition.
  31. */
  32. /**
  33. * Function type declaration for uenum_close().
  34. *
  35. * This function should cleanup the enumerator object
  36. *
  37. * @param en enumeration to be closed
  38. */
  39. typedef void U_CALLCONV
  40. UEnumClose(UEnumeration *en);
  41. /**
  42. * Function type declaration for uenum_count().
  43. *
  44. * This function should count the number of elements
  45. * in this enumeration
  46. *
  47. * @param en enumeration to be counted
  48. * @param status pointer to UErrorCode variable
  49. * @return number of elements in enumeration
  50. */
  51. typedef int32_t U_CALLCONV
  52. UEnumCount(UEnumeration *en, UErrorCode *status);
  53. /**
  54. * Function type declaration for uenum_unext().
  55. *
  56. * This function returns the next element as a UChar *,
  57. * or NULL after all elements haven been enumerated.
  58. *
  59. * @param en enumeration
  60. * @param resultLength pointer to result length
  61. * @param status pointer to UErrorCode variable
  62. * @return next element as UChar *,
  63. * or NULL after all elements haven been enumerated
  64. */
  65. typedef const UChar* U_CALLCONV
  66. UEnumUNext(UEnumeration* en,
  67. int32_t* resultLength,
  68. UErrorCode* status);
  69. /**
  70. * Function type declaration for uenum_next().
  71. *
  72. * This function returns the next element as a char *,
  73. * or NULL after all elements haven been enumerated.
  74. *
  75. * @param en enumeration
  76. * @param resultLength pointer to result length
  77. * @param status pointer to UErrorCode variable
  78. * @return next element as char *,
  79. * or NULL after all elements haven been enumerated
  80. */
  81. typedef const char* U_CALLCONV
  82. UEnumNext(UEnumeration* en,
  83. int32_t* resultLength,
  84. UErrorCode* status);
  85. /**
  86. * Function type declaration for uenum_reset().
  87. *
  88. * This function should reset the enumeration
  89. * object
  90. *
  91. * @param en enumeration
  92. * @param status pointer to UErrorCode variable
  93. */
  94. typedef void U_CALLCONV
  95. UEnumReset(UEnumeration* en,
  96. UErrorCode* status);
  97. struct UEnumeration {
  98. /* baseContext. For the base class only. Don't touch! */
  99. void *baseContext;
  100. /* context. Use it for what you need */
  101. void *context;
  102. /**
  103. * these are functions that will
  104. * be used for APIs
  105. */
  106. /* called from uenum_close */
  107. UEnumClose *close;
  108. /* called from uenum_count */
  109. UEnumCount *count;
  110. /* called from uenum_unext */
  111. UEnumUNext *uNext;
  112. /* called from uenum_next */
  113. UEnumNext *next;
  114. /* called from uenum_reset */
  115. UEnumReset *reset;
  116. };
  117. U_CDECL_END
  118. /* This is the default implementation for uenum_unext().
  119. * It automatically converts the char * string to UChar *.
  120. * Don't call this directly. This is called internally by uenum_unext
  121. * when a UEnumeration is defined with 'uNext' pointing to this
  122. * function.
  123. */
  124. U_CAPI const UChar* U_EXPORT2
  125. uenum_unextDefault(UEnumeration* en,
  126. int32_t* resultLength,
  127. UErrorCode* status);
  128. /* This is the default implementation for uenum_next().
  129. * It automatically converts the UChar * string to char *.
  130. * Don't call this directly. This is called internally by uenum_next
  131. * when a UEnumeration is defined with 'next' pointing to this
  132. * function.
  133. */
  134. U_CAPI const char* U_EXPORT2
  135. uenum_nextDefault(UEnumeration* en,
  136. int32_t* resultLength,
  137. UErrorCode* status);
  138. #endif