michael@0: /* michael@0: ************************************************************************ michael@0: * Copyright (c) 2008-2013, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: ************************************************************************ michael@0: */ michael@0: michael@0: /** C Utilities to aid in debugging **/ michael@0: michael@0: #ifndef _UDBGUTIL_H michael@0: #define _UDBGUTIL_H michael@0: michael@0: #include "unicode/utypes.h" michael@0: #include michael@0: michael@0: enum UDebugEnumType { michael@0: UDBG_UDebugEnumType = 0, /* Self-referential, strings for UDebugEnumType. Count=ENUM_COUNT. */ michael@0: #if !UCONFIG_NO_FORMATTING michael@0: UDBG_UCalendarDateFields, /* UCalendarDateFields. Count=UCAL_FIELD_COUNT. Unsupported if UCONFIG_NO_FORMATTING. */ michael@0: UDBG_UCalendarMonths, /* UCalendarMonths. Count= (UCAL_UNDECIMBER+1) */ michael@0: UDBG_UDateFormatStyle, /* Count = UDAT_SHORT=1 */ michael@0: #endif michael@0: UDBG_UPlugReason, /* Count = UPLUG_REASON_COUNT */ michael@0: UDBG_UPlugLevel, /* COUNT = UPLUG_LEVEL_COUNT */ michael@0: UDBG_UAcceptResult, /* Count = ULOC_ACCEPT_FALLBACK+1=3 */ michael@0: michael@0: /* All following enums may be discontiguous. */ michael@0: michael@0: #if !UCONFIG_NO_COLLATION michael@0: UDBG_UColAttributeValue, /* UCOL_ATTRIBUTE_VALUE_COUNT */ michael@0: #endif michael@0: UDBG_ENUM_COUNT, michael@0: UDBG_HIGHEST_CONTIGUOUS_ENUM = UDBG_UAcceptResult, /**< last enum in this list with contiguous (testable) values. */ michael@0: UDBG_INVALID_ENUM = -1 /** Invalid enum value **/ michael@0: }; michael@0: michael@0: typedef enum UDebugEnumType UDebugEnumType; michael@0: michael@0: /** michael@0: * @param type the type of enum michael@0: * Print how many enums are contained for this type. michael@0: * Should be equal to the appropriate _COUNT constant or there is an error. Return -1 if unsupported. michael@0: */ michael@0: U_CAPI int32_t U_EXPORT2 udbg_enumCount(UDebugEnumType type); michael@0: michael@0: /** michael@0: * Convert an enum to a string michael@0: * @param type type of enum michael@0: * @param field field number michael@0: * @return string of the format "ERA", "YEAR", etc, or NULL if out of range or unsupported michael@0: */ michael@0: U_CAPI const char * U_EXPORT2 udbg_enumName(UDebugEnumType type, int32_t field); michael@0: michael@0: /** michael@0: * for consistency checking michael@0: * @param type the type of enum michael@0: * Print how many enums should be contained for this type. michael@0: * This is equal to the appropriate _COUNT constant or there is an error. Returns -1 if unsupported. michael@0: */ michael@0: U_CAPI int32_t U_EXPORT2 udbg_enumExpectedCount(UDebugEnumType type); michael@0: michael@0: /** michael@0: * For consistency checking, returns the expected enum ordinal value for the given index value. michael@0: * @param type which type michael@0: * @param field field number michael@0: * @return should be equal to 'field' or -1 if out of range. michael@0: */ michael@0: U_CAPI int32_t U_EXPORT2 udbg_enumArrayValue(UDebugEnumType type, int32_t field); michael@0: michael@0: /** michael@0: * Locate the specified field value by name. michael@0: * @param type which type michael@0: * @param name name of string (case sensitive) michael@0: * @return should be a field value or -1 if not found. michael@0: */ michael@0: U_CAPI int32_t U_EXPORT2 udbg_enumByName(UDebugEnumType type, const char *name); michael@0: michael@0: michael@0: /** michael@0: * Return the Platform (U_PLATFORM) as a string michael@0: */ michael@0: U_CAPI const char *udbg_getPlatform(void); michael@0: michael@0: /** michael@0: * Get the nth system parameter's name michael@0: * @param i index of name, starting from zero michael@0: * @return name, or NULL if off the end michael@0: * @see udbg_getSystemParameterValue michael@0: */ michael@0: U_CAPI const char *udbg_getSystemParameterNameByIndex(int32_t i); michael@0: michael@0: /** michael@0: * Get the nth system parameter's value, in a user supplied buffer michael@0: * @parameter i index of value, starting from zero michael@0: * @param status error status michael@0: * @return length written (standard termination rules) michael@0: * @see udbg_getSystemParameterName michael@0: */ michael@0: U_CAPI int32_t udbg_getSystemParameterValueByIndex(int32_t i, char *buffer, int32_t bufferCapacity, UErrorCode *status); michael@0: michael@0: /** michael@0: * Write ICU info as XML michael@0: */ michael@0: U_CAPI void udbg_writeIcuInfo(FILE *f); michael@0: michael@0: /** michael@0: * \def UDBG_KNOWNISSUE_LEN michael@0: * Length of output buffer for udbg_knownIssueURLFrom michael@0: */ michael@0: #define UDBG_KNOWNISSUE_LEN 255 michael@0: michael@0: /** michael@0: * Convert a "known issue" string into a URL michael@0: * @param ticket ticket string such as "10245" or "cldrbug:5013" michael@0: * @param buf output buffer - must be UDBG_KNOWNISSUE_LEN in size michael@0: * @return pointer to output buffer, or NULL on err michael@0: */ michael@0: U_CAPI char *udbg_knownIssueURLFrom(const char *ticket, char *buf); michael@0: michael@0: /** michael@0: * Open (or reopen) a 'known issue' table. michael@0: * @param ptr pointer to 'table'. Opaque. michael@0: * @return new or existing ptr michael@0: */ michael@0: U_CAPI void *udbg_knownIssue_openU(void *ptr, const char *ticket, char *where, const UChar *msg, UBool *firstForTicket, michael@0: UBool *firstForWhere); michael@0: michael@0: michael@0: /** michael@0: * Open (or reopen) a 'known issue' table. michael@0: * @param ptr pointer to 'table'. Opaque. michael@0: * @return new or existing ptr michael@0: */ michael@0: U_CAPI void *udbg_knownIssue_open(void *ptr, const char *ticket, char *where, const char *msg, UBool *firstForTicket, michael@0: UBool *firstForWhere); michael@0: michael@0: /** michael@0: * Print 'known issue' table, to std::cout. michael@0: * @param ptr pointer from udbg_knownIssue michael@0: * @return TRUE if there were any issues. michael@0: */ michael@0: U_CAPI UBool udbg_knownIssue_print(void *ptr); michael@0: michael@0: /** michael@0: * Close 'known issue' table. michael@0: * @param ptr michael@0: */ michael@0: U_CAPI void udbg_knownIssue_close(void *ptr); michael@0: michael@0: michael@0: #endif