udbgutil.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. ************************************************************************
  5. * Copyright (c) 2008-2015, International Business Machines
  6. * Corporation and others. All Rights Reserved.
  7. ************************************************************************
  8. */
  9. /** C Utilities to aid in debugging **/
  10. #ifndef _UDBGUTIL_H
  11. #define _UDBGUTIL_H
  12. #include "unicode/utypes.h"
  13. #include <stdio.h>
  14. enum UDebugEnumType {
  15. UDBG_UDebugEnumType = 0, /* Self-referential, strings for UDebugEnumType. Count=ENUM_COUNT. */
  16. #if !UCONFIG_NO_FORMATTING
  17. UDBG_UCalendarDateFields, /* UCalendarDateFields. Count=UCAL_FIELD_COUNT. Unsupported if UCONFIG_NO_FORMATTING. */
  18. UDBG_UCalendarMonths, /* UCalendarMonths. Count= (UCAL_UNDECIMBER+1) */
  19. UDBG_UDateFormatStyle, /* Count = UDAT_SHORT=1 */
  20. #endif
  21. #if UCONFIG_ENABLE_PLUGINS
  22. UDBG_UPlugReason, /* Count = UPLUG_REASON_COUNT */
  23. UDBG_UPlugLevel, /* COUNT = UPLUG_LEVEL_COUNT */
  24. #endif
  25. UDBG_UAcceptResult, /* Count = ULOC_ACCEPT_FALLBACK+1=3 */
  26. /* All following enums may be discontiguous. */
  27. #if !UCONFIG_NO_COLLATION
  28. UDBG_UColAttributeValue, /* UCOL_ATTRIBUTE_VALUE_COUNT */
  29. #endif
  30. UDBG_ENUM_COUNT,
  31. UDBG_HIGHEST_CONTIGUOUS_ENUM = UDBG_UAcceptResult, /**< last enum in this list with contiguous (testable) values. */
  32. UDBG_INVALID_ENUM = -1 /** Invalid enum value **/
  33. };
  34. typedef enum UDebugEnumType UDebugEnumType;
  35. /**
  36. * @param type the type of enum
  37. * Print how many enums are contained for this type.
  38. * Should be equal to the appropriate _COUNT constant or there is an error. Return -1 if unsupported.
  39. */
  40. U_CAPI int32_t U_EXPORT2 udbg_enumCount(UDebugEnumType type);
  41. /**
  42. * Convert an enum to a string
  43. * @param type type of enum
  44. * @param field field number
  45. * @return string of the format "ERA", "YEAR", etc, or NULL if out of range or unsupported
  46. */
  47. U_CAPI const char * U_EXPORT2 udbg_enumName(UDebugEnumType type, int32_t field);
  48. /**
  49. * for consistency checking
  50. * @param type the type of enum
  51. * Print how many enums should be contained for this type.
  52. * This is equal to the appropriate _COUNT constant or there is an error. Returns -1 if unsupported.
  53. */
  54. U_CAPI int32_t U_EXPORT2 udbg_enumExpectedCount(UDebugEnumType type);
  55. /**
  56. * For consistency checking, returns the expected enum ordinal value for the given index value.
  57. * @param type which type
  58. * @param field field number
  59. * @return should be equal to 'field' or -1 if out of range.
  60. */
  61. U_CAPI int32_t U_EXPORT2 udbg_enumArrayValue(UDebugEnumType type, int32_t field);
  62. /**
  63. * Locate the specified field value by name.
  64. * @param type which type
  65. * @param name name of string (case sensitive)
  66. * @return should be a field value or -1 if not found.
  67. */
  68. U_CAPI int32_t U_EXPORT2 udbg_enumByName(UDebugEnumType type, const char *name);
  69. /**
  70. * Return the Platform (U_PLATFORM) as a string
  71. */
  72. U_CAPI const char *udbg_getPlatform(void);
  73. /**
  74. * Get the nth system parameter's name
  75. * @param i index of name, starting from zero
  76. * @return name, or NULL if off the end
  77. * @see udbg_getSystemParameterValue
  78. */
  79. U_CAPI const char *udbg_getSystemParameterNameByIndex(int32_t i);
  80. /**
  81. * Get the nth system parameter's value, in a user supplied buffer
  82. * @parameter i index of value, starting from zero
  83. * @param status error status
  84. * @return length written (standard termination rules)
  85. * @see udbg_getSystemParameterName
  86. */
  87. U_CAPI int32_t udbg_getSystemParameterValueByIndex(int32_t i, char *buffer, int32_t bufferCapacity, UErrorCode *status);
  88. /**
  89. * Write ICU info as XML
  90. */
  91. U_CAPI void udbg_writeIcuInfo(FILE *f);
  92. /**
  93. * \def UDBG_KNOWNISSUE_LEN
  94. * Length of output buffer for udbg_knownIssueURLFrom
  95. */
  96. #define UDBG_KNOWNISSUE_LEN 255
  97. /**
  98. * Convert a "known issue" string into a URL
  99. * @param ticket ticket string such as "10245" or "cldrbug:5013"
  100. * @param buf output buffer - must be UDBG_KNOWNISSUE_LEN in size
  101. * @return pointer to output buffer, or NULL on err
  102. */
  103. U_CAPI char *udbg_knownIssueURLFrom(const char *ticket, char *buf);
  104. /**
  105. * Open (or reopen) a 'known issue' table.
  106. * @param ptr pointer to 'table'. Opaque.
  107. * @return new or existing ptr
  108. */
  109. U_CAPI void *udbg_knownIssue_openU(void *ptr, const char *ticket, char *where, const UChar *msg, UBool *firstForTicket,
  110. UBool *firstForWhere);
  111. /**
  112. * Open (or reopen) a 'known issue' table.
  113. * @param ptr pointer to 'table'. Opaque.
  114. * @return new or existing ptr
  115. */
  116. U_CAPI void *udbg_knownIssue_open(void *ptr, const char *ticket, char *where, const char *msg, UBool *firstForTicket,
  117. UBool *firstForWhere);
  118. /**
  119. * Print 'known issue' table, to std::cout.
  120. * @param ptr pointer from udbg_knownIssue
  121. * @return TRUE if there were any issues.
  122. */
  123. U_CAPI UBool udbg_knownIssue_print(void *ptr);
  124. /**
  125. * Close 'known issue' table.
  126. * @param ptr
  127. */
  128. U_CAPI void udbg_knownIssue_close(void *ptr);
  129. #endif