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