#ifndef __RESTRACE_H__
#define __RESTRACE_H__
#include "unicode/utypes.h"
#if U_ENABLE_TRACING
struct UResourceBundle;
U_NAMESPACE_BEGIN
class CharString;
class U_COMMON_API ResourceTracer {
public:
ResourceTracer() :
fResB(nullptr),
fParent(nullptr),
fKey(nullptr),
fIndex(-1) {}
ResourceTracer(const UResourceBundle* resB) :
fResB(resB),
fParent(nullptr),
fKey(nullptr),
fIndex(-1) {}
ResourceTracer(const UResourceBundle* resB, const char* key) :
fResB(resB),
fParent(nullptr),
fKey(key),
fIndex(-1) {}
ResourceTracer(const UResourceBundle* resB, int32_t index) :
fResB(resB),
fParent(nullptr),
fKey(nullptr),
fIndex(index) {}
ResourceTracer(const ResourceTracer& parent, const char* key) :
fResB(nullptr),
fParent(&parent),
fKey(key),
fIndex(-1) {}
ResourceTracer(const ResourceTracer& parent, int32_t index) :
fResB(nullptr),
fParent(&parent),
fKey(nullptr),
fIndex(index) {}
~ResourceTracer();
void trace(const char* type) const;
void traceOpen() const;
void maybeTrace(const char* type) const {
if (fResB || fParent) {
trace(type);
}
}
private:
const UResourceBundle* fResB;
const ResourceTracer* fParent;
const char* fKey;
int32_t fIndex;
CharString& getFilePath(CharString& output, UErrorCode& status) const;
CharString& getResPath(CharString& output, UErrorCode& status) const;
};
class FileTracer {
public:
static void traceOpen(const char* path, const char* type, const char* name);
private:
static void traceOpenDataFile(const char* path, const char* type, const char* name);
static void traceOpenResFile(const char* path, const char* name);
};
U_NAMESPACE_END
#else
U_NAMESPACE_BEGIN
class U_COMMON_API ResourceTracer { … };
class FileTracer { … };
U_NAMESPACE_END
#endif
#endif