ICU-11986 use prefix Resource for C++ classes, prefix UResource for C types

X-SVN-Rev: 38087
This commit is contained in:
Markus Scherer 2015-11-18 00:18:28 +00:00
parent a47a3679ac
commit d5877ebe4e
10 changed files with 80 additions and 80 deletions

View File

@ -84,7 +84,7 @@ uhash.o uhash_us.o uenum.o ustrenum.o uvector.o ustack.o uvectr32.o uvectr64.o \
ucnv.o ucnv_bld.o ucnv_cnv.o ucnv_io.o ucnv_cb.o ucnv_err.o ucnvlat1.o \
ucnv_u7.o ucnv_u8.o ucnv_u16.o ucnv_u32.o ucnvscsu.o ucnvbocu.o \
ucnv_ext.o ucnvmbcs.o ucnv2022.o ucnvhz.o ucnv_lmb.o ucnvisci.o ucnvdisp.o ucnv_set.o ucnv_ct.o \
uresource.o uresbund.o ures_cnv.o uresdata.o resbund.o resbund_cnv.o \
resource.o uresbund.o ures_cnv.o uresdata.o resbund.o resbund_cnv.o \
messagepattern.o ucat.o locmap.o uloc.o locid.o locutil.o locavailable.o locdispnames.o loclikely.o locresdata.o \
bytestream.o stringpiece.o \
stringtriebuilder.o bytestriebuilder.o \

View File

@ -380,7 +380,7 @@
<ClCompile Include="ures_cnv.c" />
<ClCompile Include="uresbund.cpp" />
<ClCompile Include="uresdata.cpp" />
<ClCompile Include="uresource.cpp" />
<ClCompile Include="resource.cpp" />
<ClCompile Include="caniter.cpp">
</ClCompile>
<ClCompile Include="filterednormalizer2.cpp" />
@ -1137,7 +1137,7 @@
<ClInclude Include="uresdata.h" />
<ClInclude Include="uresimp.h" />
<ClInclude Include="ureslocs.h" />
<ClInclude Include="uresource.h" />
<ClInclude Include="resource.h" />
<CustomBuild Include="unicode\caniter.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" ..\..\include\unicode
</Command>

View File

@ -346,7 +346,7 @@
<ClCompile Include="uresdata.cpp">
<Filter>locales &amp; resources</Filter>
</ClCompile>
<ClCompile Include="uresource.cpp">
<ClCompile Include="resource.cpp">
<Filter>locales &amp; resources</Filter>
</ClCompile>
<ClCompile Include="caniter.cpp">
@ -775,7 +775,7 @@
<ClInclude Include="uresdata.h">
<Filter>locales &amp; resources</Filter>
</ClInclude>
<ClInclude Include="uresource.h">
<ClInclude Include="resource.h">
<Filter>locales &amp; resources</Filter>
</ClInclude>
<ClInclude Include="uresimp.h">

View File

@ -3,13 +3,13 @@
* Copyright (C) 2015, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
* uresource.cpp
* resource.cpp
*
* created on: 2015nov04
* created by: Markus W. Scherer
*/
#include "uresource.h"
#include "resource.h"
#include "unicode/utypes.h"
#include "unicode/uobject.h"
@ -17,38 +17,38 @@
U_NAMESPACE_BEGIN
UResourceValue::~UResourceValue() {}
ResourceValue::~ResourceValue() {}
UResourceArraySink::~UResourceArraySink() {}
ResourceArraySink::~ResourceArraySink() {}
void UResourceArraySink::put(
int32_t /*index*/, UResourceValue & /*value*/, UErrorCode & /*errorCode*/) {}
void ResourceArraySink::put(
int32_t /*index*/, ResourceValue & /*value*/, UErrorCode & /*errorCode*/) {}
UResourceArraySink *UResourceArraySink::getOrCreateArraySink(
ResourceArraySink *ResourceArraySink::getOrCreateArraySink(
int32_t /*index*/, int32_t /*size*/, UErrorCode & /*errorCode*/) {
return NULL;
}
UResourceTableSink *UResourceArraySink::getOrCreateTableSink(
ResourceTableSink *ResourceArraySink::getOrCreateTableSink(
int32_t /*index*/, int32_t /*initialSize*/, UErrorCode & /*errorCode*/) {
return NULL;
}
UResourceTableSink::~UResourceTableSink() {}
ResourceTableSink::~ResourceTableSink() {}
void UResourceTableSink::put(
const char * /*key*/, UResourceValue & /*value*/, UErrorCode & /*errorCode*/) {}
void ResourceTableSink::put(
const char * /*key*/, ResourceValue & /*value*/, UErrorCode & /*errorCode*/) {}
void UResourceTableSink::putNoFallback(const char * /*key*/, UErrorCode & /*errorCode*/) {}
void ResourceTableSink::putNoFallback(const char * /*key*/, UErrorCode & /*errorCode*/) {}
UResourceArraySink *UResourceTableSink::getOrCreateArraySink(
ResourceArraySink *ResourceTableSink::getOrCreateArraySink(
const char * /*key*/, int32_t /*size*/, UErrorCode & /*errorCode*/) {
return NULL;
}
UResourceTableSink *UResourceTableSink::getOrCreateTableSink(
ResourceTableSink *ResourceTableSink::getOrCreateTableSink(
const char * /*key*/, int32_t /*initialSize*/, UErrorCode & /*errorCode*/) {
return NULL;
}

View File

@ -3,7 +3,7 @@
* Copyright (C) 2015, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
* uresource.h
* resource.h
*
* created on: 2015nov04
* created by: Markus W. Scherer
@ -17,31 +17,31 @@
* \brief ICU resource bundle key and value types.
*/
// Note: Ported from ICU4J class ICUResource and its nested classes,
// Note: Ported from ICU4J class UResource and its nested classes,
// but the C++ classes are separate, not nested.
// We use the Resource prefix for C++ classes, as usual.
// The UResource prefix would be used for C types.
#include "unicode/utypes.h"
#include "unicode/unistr.h"
#include "unicode/ures.h"
U_NAMESPACE_BEGIN
class UResourceTableSink;
class ResourceTableSink;
// Note: In C++, we use const char * pointers for keys,
// rather than an abstraction like Java ICUResource.Key.
// rather than an abstraction like Java UResource.Key.
/**
* Represents a resource bundle item's value.
* Avoids object creations as much as possible.
* Mutable, not thread-safe.
*
* If we add public API like this, we should use the UResource prefix for C types
* and just a Resource prefix for the C++ versions, as usual.
*/
class U_COMMON_API UResourceValue : public UObject {
class U_COMMON_API ResourceValue : public UObject {
public:
virtual ~UResourceValue();
virtual ~ResourceValue();
/**
* @return ICU resource type, for example, URES_STRING
@ -101,11 +101,11 @@ public:
virtual const uint8_t *getBinary(int32_t &length, UErrorCode &errorCode) const = 0;
protected:
UResourceValue() {}
ResourceValue() {}
private:
UResourceValue(const UResourceValue &); // no copy constructor
UResourceValue &operator=(const UResourceValue &); // no assignment operator
ResourceValue(const ResourceValue &); // no copy constructor
ResourceValue &operator=(const ResourceValue &); // no assignment operator
};
/**
@ -113,12 +113,12 @@ private:
* The base class does nothing.
*
* Nested arrays and tables are stored as nested sinks,
* never put() as UResourceValue items.
* never put() as ResourceValue items.
*/
class U_COMMON_API UResourceArraySink : public UObject {
class U_COMMON_API ResourceArraySink : public UObject {
public:
UResourceArraySink() {}
virtual ~UResourceArraySink();
ResourceArraySink() {}
virtual ~ResourceArraySink();
/**
* Adds a value from a resource array.
@ -126,7 +126,7 @@ public:
* @param index of the resource array item
* @param value resource value
*/
virtual void put(int32_t index, UResourceValue &value, UErrorCode &errorCode);
virtual void put(int32_t index, ResourceValue &value, UErrorCode &errorCode);
/**
* Returns a nested resource array at the array index as another sink.
@ -140,7 +140,7 @@ public:
* @param size number of array items
* @return nested-array sink, or NULL
*/
virtual UResourceArraySink *getOrCreateArraySink(
virtual ResourceArraySink *getOrCreateArraySink(
int32_t index, int32_t size, UErrorCode &errorCode);
/**
@ -155,12 +155,12 @@ public:
* @param initialSize size hint for creating the sink if necessary
* @return nested-table sink, or NULL
*/
virtual UResourceTableSink *getOrCreateTableSink(
virtual ResourceTableSink *getOrCreateTableSink(
int32_t index, int32_t initialSize, UErrorCode &errorCode);
private:
UResourceArraySink(const UResourceArraySink &); // no copy constructor
UResourceArraySink &operator=(const UResourceArraySink &); // no assignment operator
ResourceArraySink(const ResourceArraySink &); // no copy constructor
ResourceArraySink &operator=(const ResourceArraySink &); // no assignment operator
};
/**
@ -168,12 +168,12 @@ private:
* The base class does nothing.
*
* Nested arrays and tables are stored as nested sinks,
* never put() as UResourceValue items.
* never put() as ResourceValue items.
*/
class U_COMMON_API UResourceTableSink : public UObject {
class U_COMMON_API ResourceTableSink : public UObject {
public:
UResourceTableSink() {}
virtual ~UResourceTableSink();
ResourceTableSink() {}
virtual ~ResourceTableSink();
/**
* Adds a key-value pair from a resource table.
@ -181,7 +181,7 @@ public:
* @param key resource key string
* @param value resource value
*/
virtual void put(const char *key, UResourceValue &value, UErrorCode &errorCode);
virtual void put(const char *key, ResourceValue &value, UErrorCode &errorCode);
/**
* Adds a no-fallback/no-inheritance marker for this key.
@ -206,7 +206,7 @@ public:
* @param size number of array items
* @return nested-array sink, or NULL
*/
virtual UResourceArraySink *getOrCreateArraySink(
virtual ResourceArraySink *getOrCreateArraySink(
const char *key, int32_t size, UErrorCode &errorCode);
/**
@ -221,12 +221,12 @@ public:
* @param initialSize size hint for creating the sink if necessary
* @return nested-table sink, or NULL
*/
virtual UResourceTableSink *getOrCreateTableSink(
virtual ResourceTableSink *getOrCreateTableSink(
const char *key, int32_t initialSize, UErrorCode &errorCode);
private:
UResourceTableSink(const UResourceTableSink &); // no copy constructor
UResourceTableSink &operator=(const UResourceTableSink &); // no assignment operator
ResourceTableSink(const ResourceTableSink &); // no copy constructor
ResourceTableSink &operator=(const ResourceTableSink &); // no assignment operator
};
U_NAMESPACE_END

View File

@ -1886,7 +1886,7 @@ namespace {
void getAllContainerItemsWithFallback(
const UResourceBundle *bundle, ResourceDataValue &value,
UResourceArraySink *arraySink, UResourceTableSink *tableSink,
ResourceArraySink *arraySink, ResourceTableSink *tableSink,
UErrorCode &errorCode) {
if (U_FAILURE(errorCode)) { return; }
// We recursively enumerate child-first,
@ -1952,7 +1952,7 @@ void getAllContainerItemsWithFallback(
void getAllContainerItemsWithFallback(
const UResourceBundle *bundle, const char *path,
UResourceArraySink *arraySink, UResourceTableSink *tableSink,
ResourceArraySink *arraySink, ResourceTableSink *tableSink,
UErrorCode &errorCode) {
if (U_FAILURE(errorCode)) { return; }
if (path == NULL) {
@ -1988,13 +1988,13 @@ void getAllContainerItemsWithFallback(
U_CAPI void U_EXPORT2
ures_getAllArrayItemsWithFallback(const UResourceBundle *bundle, const char *path,
UResourceArraySink &sink, UErrorCode &errorCode) {
ResourceArraySink &sink, UErrorCode &errorCode) {
getAllContainerItemsWithFallback(bundle, path, &sink, NULL, errorCode);
}
U_CAPI void U_EXPORT2
ures_getAllTableItemsWithFallback(const UResourceBundle *bundle, const char *path,
UResourceTableSink &sink, UErrorCode &errorCode) {
ResourceTableSink &sink, UErrorCode &errorCode) {
getAllContainerItemsWithFallback(bundle, path, NULL, &sink, errorCode);
}

View File

@ -23,6 +23,7 @@
#include "unicode/utf16.h"
#include "cmemory.h"
#include "cstring.h"
#include "resource.h"
#include "uarrsort.h"
#include "uassert.h"
#include "ucol_swp.h"
@ -30,7 +31,6 @@
#include "uinvchar.h"
#include "uresdata.h"
#include "uresimp.h"
#include "uresource.h"
/*
* Resource access helpers
@ -699,7 +699,7 @@ res_getResource(const ResourceData *pResData, const char *key) {
// and doing the enumeration in the higher-level code on top of those accessors.
U_CFUNC void
ures_getAllTableItems(const ResourceData *pResData, Resource table,
icu::ResourceDataValue &value, icu::UResourceTableSink &sink,
icu::ResourceDataValue &value, icu::ResourceTableSink &sink,
UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
const uint16_t *keys16 = NULL;
@ -752,13 +752,13 @@ ures_getAllTableItems(const ResourceData *pResData, Resource table,
int32_t type = RES_GET_TYPE(res);
if (URES_IS_ARRAY(type)) {
int32_t numItems = getArrayLength(pResData, res);
icu::UResourceArraySink *subSink = sink.getOrCreateArraySink(key, numItems, errorCode);
icu::ResourceArraySink *subSink = sink.getOrCreateArraySink(key, numItems, errorCode);
if (subSink != NULL) {
ures_getAllArrayItems(pResData, res, value, *subSink, errorCode);
}
} else if (URES_IS_TABLE(type)) {
int32_t numItems = getTableLength(pResData, res);
icu::UResourceTableSink *subSink = sink.getOrCreateTableSink(key, numItems, errorCode);
icu::ResourceTableSink *subSink = sink.getOrCreateTableSink(key, numItems, errorCode);
if (subSink != NULL) {
ures_getAllTableItems(pResData, res, value, *subSink, errorCode);
}
@ -806,7 +806,7 @@ res_getArrayItem(const ResourceData *pResData, Resource array, int32_t indexR) {
U_CFUNC void
ures_getAllArrayItems(const ResourceData *pResData, Resource array,
icu::ResourceDataValue &value, icu::UResourceArraySink &sink,
icu::ResourceDataValue &value, icu::ResourceArraySink &sink,
UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return; }
const uint16_t *items16 = NULL;
@ -841,13 +841,13 @@ ures_getAllArrayItems(const ResourceData *pResData, Resource array,
int32_t type = RES_GET_TYPE(res);
if (URES_IS_ARRAY(type)) {
int32_t numItems = getArrayLength(pResData, res);
icu::UResourceArraySink *subSink = sink.getOrCreateArraySink(i, numItems, errorCode);
icu::ResourceArraySink *subSink = sink.getOrCreateArraySink(i, numItems, errorCode);
if (subSink != NULL) {
ures_getAllArrayItems(pResData, res, value, *subSink, errorCode);
}
} else if (URES_IS_TABLE(type)) {
int32_t numItems = getTableLength(pResData, res);
icu::UResourceTableSink *subSink = sink.getOrCreateTableSink(i, numItems, errorCode);
icu::ResourceTableSink *subSink = sink.getOrCreateTableSink(i, numItems, errorCode);
if (subSink != NULL) {
ures_getAllTableItems(pResData, res, value, *subSink, errorCode);
}

View File

@ -467,11 +467,11 @@ U_CFUNC Resource res_findResource(const ResourceData *pResData, Resource r,
#ifdef __cplusplus
#include "uresource.h"
#include "resource.h"
U_NAMESPACE_BEGIN
class ResourceDataValue : public UResourceValue {
class ResourceDataValue : public ResourceValue {
public:
ResourceDataValue() : pResData(NULL), res(URES_NONE) {}
virtual ~ResourceDataValue();
@ -501,7 +501,7 @@ U_NAMESPACE_END
*/
U_CFUNC void
ures_getAllTableItems(const ResourceData *pResData, Resource table,
icu::ResourceDataValue &value, icu::UResourceTableSink &sink,
icu::ResourceDataValue &value, icu::ResourceTableSink &sink,
UErrorCode &errorCode);
/**
@ -510,7 +510,7 @@ ures_getAllTableItems(const ResourceData *pResData, Resource table,
*/
U_CFUNC void
ures_getAllArrayItems(const ResourceData *pResData, Resource array,
icu::ResourceDataValue &value, icu::UResourceArraySink &sink,
icu::ResourceDataValue &value, icu::ResourceArraySink &sink,
UErrorCode &errorCode);
#endif /* __cplusplus */

View File

@ -226,11 +226,11 @@ ures_getStringByKeyWithFallback(const UResourceBundle *resB,
U_CAPI void U_EXPORT2
ures_getAllArrayItemsWithFallback(const UResourceBundle *bundle, const char *path,
icu::UResourceArraySink &sink, UErrorCode &errorCode);
icu::ResourceArraySink &sink, UErrorCode &errorCode);
U_CAPI void U_EXPORT2
ures_getAllTableItemsWithFallback(const UResourceBundle *bundle, const char *path,
icu::UResourceTableSink &sink, UErrorCode &errorCode);
icu::ResourceTableSink &sink, UErrorCode &errorCode);
#endif /* __cplusplus */

View File

@ -17,6 +17,7 @@
#include "unicode/numfmt.h"
#include "currfmt.h"
#include "unicode/localpointer.h"
#include "resource.h"
#include "simplepatternformatter.h"
#include "quantityformatter.h"
#include "unicode/plurrule.h"
@ -32,7 +33,6 @@
#include "unicode/putil.h"
#include "unicode/smpdtfmt.h"
#include "uassert.h"
#include "uresource.h"
#include "sharednumberformat.h"
#include "sharedpluralrules.h"
@ -128,7 +128,7 @@ public:
const NumericDateFormatters *getNumericDateFormatters() const {
return numericDateFormatters;
}
void setPerUnitFormatterIfAbsent(int32_t unitIndex, int32_t width, UResourceValue &value,
void setPerUnitFormatterIfAbsent(int32_t unitIndex, int32_t width, ResourceValue &value,
UErrorCode &errorCode) {
if (perUnitFormatters[unitIndex][width] == NULL) {
perUnitFormatters[unitIndex][width] =
@ -221,15 +221,15 @@ static const UChar gNarrow[] = { 0x4E, 0x61, 0x72, 0x72, 0x6F, 0x77 };
* C++: Each inner sink class has a reference to the main outer sink.
* Java: Use non-static inner classes instead.
*/
struct UnitDataSink : public UResourceTableSink {
struct UnitDataSink : public ResourceTableSink {
/**
* Sink for a table of display patterns. For example,
* unitsShort/duration/hour contains other{"{0} hrs"}.
*/
struct UnitPatternSink : public UResourceTableSink {
struct UnitPatternSink : public ResourceTableSink {
UnitPatternSink(UnitDataSink &sink) : outer(sink) {}
~UnitPatternSink();
virtual void put(const char *key, UResourceValue &value, UErrorCode &errorCode) {
virtual void put(const char *key, ResourceValue &value, UErrorCode &errorCode) {
if (U_FAILURE(errorCode)) { return; }
if (uprv_strcmp(key, "dnam") == 0) {
// Skip the unit display name for now.
@ -254,10 +254,10 @@ struct UnitDataSink : public UResourceTableSink {
* Sink for a table of per-unit tables. For example,
* unitsShort/duration contains tables for duration-unit subtypes day & hour.
*/
struct UnitSubtypeSink : public UResourceTableSink {
struct UnitSubtypeSink : public ResourceTableSink {
UnitSubtypeSink(UnitDataSink &sink) : outer(sink) {}
~UnitSubtypeSink();
virtual UResourceTableSink *getOrCreateTableSink(
virtual ResourceTableSink *getOrCreateTableSink(
const char *key, int32_t /* initialSize */, UErrorCode &errorCode) {
if (U_FAILURE(errorCode)) { return NULL; }
outer.unitIndex = MeasureUnit::internalGetIndexForTypeAndSubtype(outer.type, key);
@ -275,10 +275,10 @@ struct UnitDataSink : public UResourceTableSink {
* Sink for compound x-per-y display pattern. For example,
* unitsShort/compound/per may be "{0}/{1}".
*/
struct UnitCompoundSink : public UResourceTableSink {
struct UnitCompoundSink : public ResourceTableSink {
UnitCompoundSink(UnitDataSink &sink) : outer(sink) {}
~UnitCompoundSink();
virtual void put(const char *key, UResourceValue &value, UErrorCode &errorCode) {
virtual void put(const char *key, ResourceValue &value, UErrorCode &errorCode) {
if (U_SUCCESS(errorCode) && uprv_strcmp(key, "per") == 0) {
outer.cacheData.perFormatters[outer.width].
compile(value.getUnicodeString(errorCode), errorCode);
@ -292,10 +292,10 @@ struct UnitDataSink : public UResourceTableSink {
* unitsShort contains tables for area & duration.
* It also contains a table for the compound/per pattern.
*/
struct UnitTypeSink : public UResourceTableSink {
struct UnitTypeSink : public ResourceTableSink {
UnitTypeSink(UnitDataSink &sink) : outer(sink) {}
~UnitTypeSink();
virtual UResourceTableSink *getOrCreateTableSink(
virtual ResourceTableSink *getOrCreateTableSink(
const char *key, int32_t /* initialSize */, UErrorCode &errorCode) {
if (U_FAILURE(errorCode)) { return NULL; }
if (uprv_strcmp(key, "currency") == 0) {
@ -318,7 +318,7 @@ struct UnitDataSink : public UResourceTableSink {
cacheData(outputData),
width(UMEASFMT_WIDTH_COUNT), type(NULL), unitIndex(0), hasPatterns(FALSE) {}
~UnitDataSink();
virtual void put(const char *key, UResourceValue &value, UErrorCode &errorCode) {
virtual void put(const char *key, ResourceValue &value, UErrorCode &errorCode) {
// Handle aliases like
// units:alias{"/LOCALE/unitsShort"}
// which should only occur in the root bundle.
@ -341,7 +341,7 @@ struct UnitDataSink : public UResourceTableSink {
}
cacheData.widthFallback[sourceWidth] = targetWidth;
}
virtual UResourceTableSink *getOrCreateTableSink(
virtual ResourceTableSink *getOrCreateTableSink(
const char *key, int32_t /* initialSize */, UErrorCode &errorCode) {
if (U_SUCCESS(errorCode) && (width = widthFromKey(key)) != UMEASFMT_WIDTH_COUNT) {
return &typeSink;
@ -363,7 +363,7 @@ struct UnitDataSink : public UResourceTableSink {
return UMEASFMT_WIDTH_COUNT;
}
static UMeasureFormatWidth widthFromAlias(const UResourceValue &value, UErrorCode &errorCode) {
static UMeasureFormatWidth widthFromAlias(const ResourceValue &value, UErrorCode &errorCode) {
int32_t length;
const UChar *s = value.getAliasString(length, errorCode);
// For example: "/LOCALE/unitsShort"