1 // © 2019 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
7 #include "unicode/utypes.h"
11 struct UResourceBundle
;
18 * Instances of this class store information used to trace reads from resource
19 * bundles when ICU is built with --enable-tracing.
21 * All arguments of type const UResourceBundle*, const char*, and
22 * const ResourceTracer& are stored as pointers. The caller must retain
23 * ownership for the lifetime of this ResourceTracer.
25 * Exported as U_COMMON_API for Windows because it is a value field
26 * in other exported types.
28 class U_COMMON_API ResourceTracer
{
36 ResourceTracer(const UResourceBundle
* resB
) :
42 ResourceTracer(const UResourceBundle
* resB
, const char* key
) :
48 ResourceTracer(const UResourceBundle
* resB
, int32_t index
) :
54 ResourceTracer(const ResourceTracer
& parent
, const char* key
) :
60 ResourceTracer(const ResourceTracer
& parent
, int32_t index
) :
68 void trace(const char* type
) const;
69 void traceOpen() const;
72 * Calls trace() if the resB or parent provided to the constructor was
73 * non-null; otherwise, does nothing.
75 void maybeTrace(const char* type
) const {
76 if (fResB
|| fParent
) {
82 const UResourceBundle
* fResB
;
83 const ResourceTracer
* fParent
;
87 CharString
& getFilePath(CharString
& output
, UErrorCode
& status
) const;
89 CharString
& getResPath(CharString
& output
, UErrorCode
& status
) const;
93 * This class provides methods to trace data file reads when ICU is built
94 * with --enable-tracing.
98 static void traceOpen(const char* path
, const char* type
, const char* name
);
101 static void traceOpenDataFile(const char* path
, const char* type
, const char* name
);
102 static void traceOpenResFile(const char* path
, const char* name
);
107 #else // U_ENABLE_TRACING
112 * Default trivial implementation when --enable-tracing is not used.
114 class U_COMMON_API ResourceTracer
{
118 ResourceTracer(const void*) {}
120 ResourceTracer(const void*, const char*) {}
122 ResourceTracer(const void*, int32_t) {}
124 ResourceTracer(const ResourceTracer
&, const char*) {}
126 ResourceTracer(const ResourceTracer
&, int32_t) {}
128 void trace(const char*) const {}
130 void traceOpen() const {}
132 void maybeTrace(const char*) const {}
136 * Default trivial implementation when --enable-tracing is not used.
140 static void traceOpen(const char*, const char*, const char*) {}
145 #endif // U_ENABLE_TRACING
147 #endif //__RESTRACE_H__