Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1177)

Side by Side Diff: public/common/unicode/utrace.h

Issue 18836004: Move ICU headers from public/{common,i18n} to source/{common,i18n} (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu46.git@master
Patch Set: same as ps #3. retry uploading Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « public/common/unicode/utf_old.h ('k') | public/common/unicode/utypeinfo.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 *******************************************************************************
3 *
4 * Copyright (C) 2003-2006, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 *
7 *******************************************************************************
8 * file name: utrace.h
9 * encoding: US-ASCII
10 * tab size: 8 (not used)
11 * indentation:4
12 *
13 * created on: 2003aug06
14 * created by: Markus W. Scherer
15 *
16 * Definitions for ICU tracing/logging.
17 *
18 */
19
20 #ifndef __UTRACE_H__
21 #define __UTRACE_H__
22
23 #include <stdarg.h>
24 #include "unicode/utypes.h"
25
26 /**
27 * \file
28 * \brief C API: Definitions for ICU tracing/logging.
29 *
30 * This provides API for debugging the internals of ICU without the use of
31 * a traditional debugger.
32 *
33 * By default, tracing is disabled in ICU. If you need to debug ICU with
34 * tracing, please compile ICU with the --enable-tracing configure option.
35 */
36
37 U_CDECL_BEGIN
38
39 /**
40 * Trace severity levels. Higher levels increase the verbosity of the trace out put.
41 * @see utrace_setLevel
42 * @stable ICU 2.8
43 */
44 typedef enum UTraceLevel {
45 /** Disable all tracing @stable ICU 2.8*/
46 UTRACE_OFF=-1,
47 /** Trace error conditions only @stable ICU 2.8*/
48 UTRACE_ERROR=0,
49 /** Trace errors and warnings @stable ICU 2.8*/
50 UTRACE_WARNING=3,
51 /** Trace opens and closes of ICU services @stable ICU 2.8*/
52 UTRACE_OPEN_CLOSE=5,
53 /** Trace an intermediate number of ICU operations @stable ICU 2.8*/
54 UTRACE_INFO=7,
55 /** Trace the maximum number of ICU operations @stable ICU 2.8*/
56 UTRACE_VERBOSE=9
57 } UTraceLevel;
58
59 /**
60 * These are the ICU functions that will be traced when tracing is enabled.
61 * @stable ICU 2.8
62 */
63 typedef enum UTraceFunctionNumber {
64 UTRACE_FUNCTION_START=0,
65 UTRACE_U_INIT=UTRACE_FUNCTION_START,
66 UTRACE_U_CLEANUP,
67 UTRACE_FUNCTION_LIMIT,
68
69 UTRACE_CONVERSION_START=0x1000,
70 UTRACE_UCNV_OPEN=UTRACE_CONVERSION_START,
71 UTRACE_UCNV_OPEN_PACKAGE,
72 UTRACE_UCNV_OPEN_ALGORITHMIC,
73 UTRACE_UCNV_CLONE,
74 UTRACE_UCNV_CLOSE,
75 UTRACE_UCNV_FLUSH_CACHE,
76 UTRACE_UCNV_LOAD,
77 UTRACE_UCNV_UNLOAD,
78 UTRACE_CONVERSION_LIMIT,
79
80 UTRACE_COLLATION_START=0x2000,
81 UTRACE_UCOL_OPEN=UTRACE_COLLATION_START,
82 UTRACE_UCOL_CLOSE,
83 UTRACE_UCOL_STRCOLL,
84 UTRACE_UCOL_GET_SORTKEY,
85 UTRACE_UCOL_GETLOCALE,
86 UTRACE_UCOL_NEXTSORTKEYPART,
87 UTRACE_UCOL_STRCOLLITER,
88 UTRACE_UCOL_OPEN_FROM_SHORT_STRING,
89 UTRACE_COLLATION_LIMIT
90 } UTraceFunctionNumber;
91
92 /**
93 * Setter for the trace level.
94 * @param traceLevel A UTraceLevel value.
95 * @stable ICU 2.8
96 */
97 U_STABLE void U_EXPORT2
98 utrace_setLevel(int32_t traceLevel);
99
100 /**
101 * Getter for the trace level.
102 * @return The UTraceLevel value being used by ICU.
103 * @stable ICU 2.8
104 */
105 U_STABLE int32_t U_EXPORT2
106 utrace_getLevel(void);
107
108 /* Trace function pointers types ----------------------------- */
109
110 /**
111 * Type signature for the trace function to be called when entering a function .
112 * @param context value supplied at the time the trace functions are set.
113 * @param fnNumber Enum value indicating the ICU function being entered.
114 * @stable ICU 2.8
115 */
116 typedef void U_CALLCONV
117 UTraceEntry(const void *context, int32_t fnNumber);
118
119 /**
120 * Type signature for the trace function to be called when exiting from a func tion.
121 * @param context value supplied at the time the trace functions are set.
122 * @param fnNumber Enum value indicating the ICU function being exited.
123 * @param fmt A formatting string that describes the number and types
124 * of arguments included with the variable args. The fmt
125 * string has the same form as the utrace_vformat format
126 * string.
127 * @param args A variable arguments list. Contents are described by
128 * the fmt parameter.
129 * @see utrace_vformat
130 * @stable ICU 2.8
131 */
132 typedef void U_CALLCONV
133 UTraceExit(const void *context, int32_t fnNumber,
134 const char *fmt, va_list args);
135
136 /**
137 * Type signature for the trace function to be called from within an ICU funct ion
138 * to display data or messages.
139 * @param context value supplied at the time the trace functions are set.
140 * @param fnNumber Enum value indicating the ICU function being exited.
141 * @param level The current tracing level
142 * @param fmt A format string describing the tracing data that is supplie d
143 * as variable args
144 * @param args The data being traced, passed as variable args.
145 * @stable ICU 2.8
146 */
147 typedef void U_CALLCONV
148 UTraceData(const void *context, int32_t fnNumber, int32_t level,
149 const char *fmt, va_list args);
150
151 /**
152 * Set ICU Tracing functions. Installs application-provided tracing
153 * functions into ICU. After doing this, subsequent ICU operations
154 * will call back to the installed functions, providing a trace
155 * of the use of ICU. Passing a NULL pointer for a tracing function
156 * is allowed, and inhibits tracing action at points where that function
157 * would be called.
158 * <p>
159 * Tracing and Threads: Tracing functions are global to a process, and
160 * will be called in response to ICU operations performed by any
161 * thread. If tracing of an individual thread is desired, the
162 * tracing functions must themselves filter by checking that the
163 * current thread is the desired thread.
164 *
165 * @param context an uninterpretted pointer. Whatever is passed in
166 * here will in turn be passed to each of the tracing
167 * functions UTraceEntry, UTraceExit and UTraceData.
168 * ICU does not use or alter this pointer.
169 * @param e Callback function to be called on entry to a
170 * a traced ICU function.
171 * @param x Callback function to be called on exit from a
172 * traced ICU function.
173 * @param d Callback function to be called from within a
174 * traced ICU function, for the purpose of providing
175 * data to the trace.
176 *
177 * @stable ICU 2.8
178 */
179 U_STABLE void U_EXPORT2
180 utrace_setFunctions(const void *context,
181 UTraceEntry *e, UTraceExit *x, UTraceData *d);
182
183 /**
184 * Get the currently installed ICU tracing functions. Note that a null functi on
185 * pointer will be returned if no trace function has been set.
186 *
187 * @param context The currently installed tracing context.
188 * @param e The currently installed UTraceEntry function.
189 * @param x The currently installed UTraceExit function.
190 * @param d The currently installed UTraceData function.
191 * @stable ICU 2.8
192 */
193 U_STABLE void U_EXPORT2
194 utrace_getFunctions(const void **context,
195 UTraceEntry **e, UTraceExit **x, UTraceData **d);
196
197
198
199 /*
200 *
201 * ICU trace format string syntax
202 *
203 * Format Strings are passed to UTraceData functions, and define the
204 * number and types of the trace data being passed on each call.
205 *
206 * The UTraceData function, which is supplied by the application,
207 * not by ICU, can either forward the trace data (passed via
208 * varargs) and the format string back to ICU for formatting into
209 * a displayable string, or it can interpret the format itself,
210 * and do as it wishes with the trace data.
211 *
212 *
213 * Goals for the format string
214 * - basic data output
215 * - easy to use for trace programmer
216 * - sufficient provision for data types for trace output readability
217 * - well-defined types and binary portable APIs
218 *
219 * Non-goals
220 * - printf compatibility
221 * - fancy formatting
222 * - argument reordering and other internationalization features
223 *
224 * ICU trace format strings contain plain text with argument inserts,
225 * much like standard printf format strings.
226 * Each insert begins with a '%', then optionally contains a 'v',
227 * then exactly one type character.
228 * Two '%' in a row represent a '%' instead of an insert.
229 * The trace format strings need not have \n at the end.
230 *
231 *
232 * Types
233 * -----
234 *
235 * Type characters:
236 * - c A char character in the default codepage.
237 * - s A NUL-terminated char * string in the default codepage.
238 * - S A UChar * string. Requires two params, (ptr, length). Length=-1 for nul term.
239 * - b A byte (8-bit integer).
240 * - h A 16-bit integer. Also a 16 bit Unicode code unit.
241 * - d A 32-bit integer. Also a 20 bit Unicode code point value.
242 * - l A 64-bit integer.
243 * - p A data pointer.
244 *
245 * Vectors
246 * -------
247 *
248 * If the 'v' is not specified, then one item of the specified type
249 * is passed in.
250 * If the 'v' (for "vector") is specified, then a vector of items of the
251 * specified type is passed in, via a pointer to the first item
252 * and an int32_t value for the length of the vector.
253 * Length==-1 means zero or NUL termination. Works for vectors of all types.
254 *
255 * Note: %vS is a vector of (UChar *) strings. The strings must
256 * be nul terminated as there is no way to provide a
257 * separate length parameter for each string. The length
258 * parameter (required for all vectors) is the number of
259 * strings, not the length of the strings.
260 *
261 * Examples
262 * --------
263 *
264 * These examples show the parameters that will be passed to an application's
265 * UTraceData() function for various formats.
266 *
267 * - the precise formatting is up to the application!
268 * - the examples use type casts for arguments only to _show_ the types of
269 * arguments without needing variable declarations in the examples;
270 * the type casts will not be necessary in actual code
271 *
272 * UTraceDataFunc(context, fnNumber, level,
273 * "There is a character %c in the string %s.", // Format String
274 * (char)c, (const char *)s); // varargs parame ters
275 * -> There is a character 0x42 'B' in the string "Bravo".
276 *
277 * UTraceDataFunc(context, fnNumber, level,
278 * "Vector of bytes %vb vector of chars %vc",
279 * (const uint8_t *)bytes, (int32_t)bytesLength,
280 * (const char *)chars, (int32_t)charsLength);
281 * -> Vector of bytes
282 * 42 63 64 3f [4]
283 * vector of chars
284 * "Bcd?"[4]
285 *
286 * UTraceDataFunc(context, fnNumber, level,
287 * "An int32_t %d and a whole bunch of them %vd",
288 * (int32_t)-5, (const int32_t *)ints, (int32_t)intsLength);
289 * -> An int32_t 0xfffffffb and a whole bunch of them
290 * fffffffb 00000005 0000010a [3]
291 *
292 */
293
294
295
296 /**
297 * Trace output Formatter. An application's UTraceData tracing functions may call
298 * back to this function to format the trace output in a
299 * human readable form. Note that a UTraceData function may ch oose
300 * to not format the data; it could, for example, save it in
301 * in the raw form it was received (more compact), leaving
302 * formatting for a later trace analyis tool.
303 * @param outBuf pointer to a buffer to receive the formatted output. Output
304 * will be nul terminated if there is space in the buffer -
305 * if the length of the requested output < the output buffer si ze.
306 * @param capacity Length of the output buffer.
307 * @param indent Number of spaces to indent the output. Intended to allow
308 * data displayed from nested functions to be indented for read ability.
309 * @param fmt Format specification for the data to output
310 * @param args Data to be formatted.
311 * @return Length of formatted output, including the terminating NUL.
312 * If buffer capacity is insufficient, the required capacity is returned.
313 * @stable ICU 2.8
314 */
315 U_STABLE int32_t U_EXPORT2
316 utrace_vformat(char *outBuf, int32_t capacity,
317 int32_t indent, const char *fmt, va_list args);
318
319 /**
320 * Trace output Formatter. An application's UTraceData tracing functions may call
321 * this function to format any additional trace data, beyond th at
322 * provided by default, in human readable form with the same
323 * formatting conventions used by utrace_vformat().
324 * @param outBuf pointer to a buffer to receive the formatted output. Output
325 * will be nul terminated if there is space in the buffer -
326 * if the length of the requested output < the output buffer si ze.
327 * @param capacity Length of the output buffer.
328 * @param indent Number of spaces to indent the output. Intended to allow
329 * data displayed from nested functions to be indented for read ability.
330 * @param fmt Format specification for the data to output
331 * @param ... Data to be formatted.
332 * @return Length of formatted output, including the terminating NUL.
333 * If buffer capacity is insufficient, the required capacity is returned.
334 * @stable ICU 2.8
335 */
336 U_STABLE int32_t U_EXPORT2
337 utrace_format(char *outBuf, int32_t capacity,
338 int32_t indent, const char *fmt, ...);
339
340
341
342 /* Trace function numbers --------------------------------------------------- */
343
344 /**
345 * Get the name of a function from its trace function number.
346 *
347 * @param fnNumber The trace number for an ICU function.
348 * @return The name string for the function.
349 *
350 * @see UTraceFunctionNumber
351 * @stable ICU 2.8
352 */
353 U_STABLE const char * U_EXPORT2
354 utrace_functionName(int32_t fnNumber);
355
356 U_CDECL_END
357
358 #endif
OLDNEW
« no previous file with comments | « public/common/unicode/utf_old.h ('k') | public/common/unicode/utypeinfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698