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