1 /* 2 ************************************************************************ 3 * Copyright (c) 2008-2010, International Business Machines 4 * Corporation and others. All Rights Reserved. 5 ************************************************************************ 6 */ 7 8 /** C Utilities to aid in debugging **/ 9 10 #ifndef _UDBGUTIL_H 11 #define _UDBGUTIL_H 12 13 #include "unicode/testtype.h" 14 #include "unicode/utypes.h" 15 16 17 enum UDebugEnumType { 18 UDBG_UDebugEnumType = 0, /* Self-referential, strings for UDebugEnumType. Count=ENUM_COUNT. */ 19 #if !UCONFIG_NO_FORMATTING 20 UDBG_UCalendarDateFields, /* UCalendarDateFields. Count=UCAL_FIELD_COUNT. Unsupported if UCONFIG_NO_FORMATTING. */ 21 UDBG_UCalendarMonths, /* UCalendarMonths. Count= (UCAL_UNDECIMBER+1) */ 22 UDBG_UDateFormatStyle, /* Count = UDAT_SHORT=1 */ 23 #endif 24 UDBG_UPlugReason, /* Count = UPLUG_REASON_COUNT */ 25 UDBG_UPlugLevel, /* COUNT = UPLUG_LEVEL_COUNT */ 26 UDBG_UAcceptResult, /* Count = ULOC_ACCEPT_FALLBACK+1=3 */ 27 28 /* All following enums may be discontiguous. */ 29 30 #if !UCONFIG_NO_COLLATION 31 UDBG_UColAttributeValue, /* UCOL_ATTRIBUTE_VALUE_COUNT */ 32 #endif 33 UDBG_ENUM_COUNT, 34 UDBG_HIGHEST_CONTIGUOUS_ENUM = UDBG_UAcceptResult, /**< last enum in this list with contiguous (testable) values. */ 35 UDBG_INVALID_ENUM = -1 /** Invalid enum value **/ 36 }; 37 38 typedef enum UDebugEnumType UDebugEnumType; 39 40 /** 41 * @param type the type of enum 42 * Print how many enums are contained for this type. 43 * Should be equal to the appropriate _COUNT constant or there is an error. Return -1 if unsupported. 44 */ 45 T_CTEST_API int32_t T_CTEST_EXPORT2 udbg_enumCount(UDebugEnumType type); 46 47 /** 48 * Convert an enum to a string 49 * @param type type of enum 50 * @param field field number 51 * @return string of the format "ERA", "YEAR", etc, or NULL if out of range or unsupported 52 */ 53 T_CTEST_API const char * T_CTEST_EXPORT2 udbg_enumName(UDebugEnumType type, int32_t field); 54 55 /** 56 * for consistency checking 57 * @param type the type of enum 58 * Print how many enums should be contained for this type. 59 * This is equal to the appropriate _COUNT constant or there is an error. Returns -1 if unsupported. 60 */ 61 T_CTEST_API int32_t T_CTEST_EXPORT2 udbg_enumExpectedCount(UDebugEnumType type); 62 63 /** 64 * For consistency checking, returns the expected enum ordinal value for the given index value. 65 * @param type which type 66 * @param field field number 67 * @return should be equal to 'field' or -1 if out of range. 68 */ 69 T_CTEST_API int32_t T_CTEST_EXPORT2 udbg_enumArrayValue(UDebugEnumType type, int32_t field); 70 71 /** 72 * Locate the specified field value by name. 73 * @param type which type 74 * @param name name of string (case sensitive) 75 * @return should be a field value or -1 if not found. 76 */ 77 T_CTEST_API int32_t T_CTEST_EXPORT2 udbg_enumByName(UDebugEnumType type, const char *name); 78 79 #endif 80