1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/tools/toolutil/udbgutil.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,151 @@ 1.4 +/* 1.5 +************************************************************************ 1.6 +* Copyright (c) 2008-2013, International Business Machines 1.7 +* Corporation and others. All Rights Reserved. 1.8 +************************************************************************ 1.9 +*/ 1.10 + 1.11 +/** C Utilities to aid in debugging **/ 1.12 + 1.13 +#ifndef _UDBGUTIL_H 1.14 +#define _UDBGUTIL_H 1.15 + 1.16 +#include "unicode/utypes.h" 1.17 +#include <stdio.h> 1.18 + 1.19 +enum UDebugEnumType { 1.20 + UDBG_UDebugEnumType = 0, /* Self-referential, strings for UDebugEnumType. Count=ENUM_COUNT. */ 1.21 +#if !UCONFIG_NO_FORMATTING 1.22 + UDBG_UCalendarDateFields, /* UCalendarDateFields. Count=UCAL_FIELD_COUNT. Unsupported if UCONFIG_NO_FORMATTING. */ 1.23 + UDBG_UCalendarMonths, /* UCalendarMonths. Count= (UCAL_UNDECIMBER+1) */ 1.24 + UDBG_UDateFormatStyle, /* Count = UDAT_SHORT=1 */ 1.25 +#endif 1.26 + UDBG_UPlugReason, /* Count = UPLUG_REASON_COUNT */ 1.27 + UDBG_UPlugLevel, /* COUNT = UPLUG_LEVEL_COUNT */ 1.28 + UDBG_UAcceptResult, /* Count = ULOC_ACCEPT_FALLBACK+1=3 */ 1.29 + 1.30 + /* All following enums may be discontiguous. */ 1.31 + 1.32 +#if !UCONFIG_NO_COLLATION 1.33 + UDBG_UColAttributeValue, /* UCOL_ATTRIBUTE_VALUE_COUNT */ 1.34 +#endif 1.35 + UDBG_ENUM_COUNT, 1.36 + UDBG_HIGHEST_CONTIGUOUS_ENUM = UDBG_UAcceptResult, /**< last enum in this list with contiguous (testable) values. */ 1.37 + UDBG_INVALID_ENUM = -1 /** Invalid enum value **/ 1.38 +}; 1.39 + 1.40 +typedef enum UDebugEnumType UDebugEnumType; 1.41 + 1.42 +/** 1.43 + * @param type the type of enum 1.44 + * Print how many enums are contained for this type. 1.45 + * Should be equal to the appropriate _COUNT constant or there is an error. Return -1 if unsupported. 1.46 + */ 1.47 +U_CAPI int32_t U_EXPORT2 udbg_enumCount(UDebugEnumType type); 1.48 + 1.49 +/** 1.50 + * Convert an enum to a string 1.51 + * @param type type of enum 1.52 + * @param field field number 1.53 + * @return string of the format "ERA", "YEAR", etc, or NULL if out of range or unsupported 1.54 + */ 1.55 +U_CAPI const char * U_EXPORT2 udbg_enumName(UDebugEnumType type, int32_t field); 1.56 + 1.57 +/** 1.58 + * for consistency checking 1.59 + * @param type the type of enum 1.60 + * Print how many enums should be contained for this type. 1.61 + * This is equal to the appropriate _COUNT constant or there is an error. Returns -1 if unsupported. 1.62 + */ 1.63 +U_CAPI int32_t U_EXPORT2 udbg_enumExpectedCount(UDebugEnumType type); 1.64 + 1.65 +/** 1.66 + * For consistency checking, returns the expected enum ordinal value for the given index value. 1.67 + * @param type which type 1.68 + * @param field field number 1.69 + * @return should be equal to 'field' or -1 if out of range. 1.70 + */ 1.71 +U_CAPI int32_t U_EXPORT2 udbg_enumArrayValue(UDebugEnumType type, int32_t field); 1.72 + 1.73 +/** 1.74 + * Locate the specified field value by name. 1.75 + * @param type which type 1.76 + * @param name name of string (case sensitive) 1.77 + * @return should be a field value or -1 if not found. 1.78 + */ 1.79 +U_CAPI int32_t U_EXPORT2 udbg_enumByName(UDebugEnumType type, const char *name); 1.80 + 1.81 + 1.82 +/** 1.83 + * Return the Platform (U_PLATFORM) as a string 1.84 + */ 1.85 +U_CAPI const char *udbg_getPlatform(void); 1.86 + 1.87 +/** 1.88 + * Get the nth system parameter's name 1.89 + * @param i index of name, starting from zero 1.90 + * @return name, or NULL if off the end 1.91 + * @see udbg_getSystemParameterValue 1.92 + */ 1.93 +U_CAPI const char *udbg_getSystemParameterNameByIndex(int32_t i); 1.94 + 1.95 +/** 1.96 + * Get the nth system parameter's value, in a user supplied buffer 1.97 + * @parameter i index of value, starting from zero 1.98 + * @param status error status 1.99 + * @return length written (standard termination rules) 1.100 + * @see udbg_getSystemParameterName 1.101 + */ 1.102 +U_CAPI int32_t udbg_getSystemParameterValueByIndex(int32_t i, char *buffer, int32_t bufferCapacity, UErrorCode *status); 1.103 + 1.104 +/** 1.105 + * Write ICU info as XML 1.106 + */ 1.107 +U_CAPI void udbg_writeIcuInfo(FILE *f); 1.108 + 1.109 +/** 1.110 + * \def UDBG_KNOWNISSUE_LEN 1.111 + * Length of output buffer for udbg_knownIssueURLFrom 1.112 + */ 1.113 +#define UDBG_KNOWNISSUE_LEN 255 1.114 + 1.115 +/** 1.116 + * Convert a "known issue" string into a URL 1.117 + * @param ticket ticket string such as "10245" or "cldrbug:5013" 1.118 + * @param buf output buffer - must be UDBG_KNOWNISSUE_LEN in size 1.119 + * @return pointer to output buffer, or NULL on err 1.120 + */ 1.121 +U_CAPI char *udbg_knownIssueURLFrom(const char *ticket, char *buf); 1.122 + 1.123 +/** 1.124 + * Open (or reopen) a 'known issue' table. 1.125 + * @param ptr pointer to 'table'. Opaque. 1.126 + * @return new or existing ptr 1.127 + */ 1.128 +U_CAPI void *udbg_knownIssue_openU(void *ptr, const char *ticket, char *where, const UChar *msg, UBool *firstForTicket, 1.129 + UBool *firstForWhere); 1.130 + 1.131 + 1.132 +/** 1.133 + * Open (or reopen) a 'known issue' table. 1.134 + * @param ptr pointer to 'table'. Opaque. 1.135 + * @return new or existing ptr 1.136 + */ 1.137 +U_CAPI void *udbg_knownIssue_open(void *ptr, const char *ticket, char *where, const char *msg, UBool *firstForTicket, 1.138 + UBool *firstForWhere); 1.139 + 1.140 +/** 1.141 + * Print 'known issue' table, to std::cout. 1.142 + * @param ptr pointer from udbg_knownIssue 1.143 + * @return TRUE if there were any issues. 1.144 + */ 1.145 +U_CAPI UBool udbg_knownIssue_print(void *ptr); 1.146 + 1.147 +/** 1.148 + * Close 'known issue' table. 1.149 + * @param ptr 1.150 + */ 1.151 +U_CAPI void udbg_knownIssue_close(void *ptr); 1.152 + 1.153 + 1.154 +#endif