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 \
<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" />
<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>
<ClCompile Include="uresdata.cpp">
<Filter>locales & resources</Filter>
</ClCompile>
- <ClCompile Include="uresource.cpp">
+ <ClCompile Include="resource.cpp">
<Filter>locales & resources</Filter>
</ClCompile>
<ClCompile Include="caniter.cpp">
<ClInclude Include="uresdata.h">
<Filter>locales & resources</Filter>
</ClInclude>
- <ClInclude Include="uresource.h">
+ <ClInclude Include="resource.h">
<Filter>locales & resources</Filter>
</ClInclude>
<ClInclude Include="uresimp.h">
* 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"
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;
}
* Copyright (C) 2015, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
-* uresource.h
+* resource.h
*
* created on: 2015nov04
* created by: Markus W. Scherer
* \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
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
};
/**
* 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.
* @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.
* @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);
/**
* @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
};
/**
* 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.
* @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.
* @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);
/**
* @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
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,
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) {
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);
}
#include "unicode/utf16.h"
#include "cmemory.h"
#include "cstring.h"
+#include "resource.h"
#include "uarrsort.h"
#include "uassert.h"
#include "ucol_swp.h"
#include "uinvchar.h"
#include "uresdata.h"
#include "uresimp.h"
-#include "uresource.h"
/*
* Resource access helpers
// 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;
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);
}
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;
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);
}
#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();
*/
U_CFUNC void
ures_getAllTableItems(const ResourceData *pResData, Resource table,
- icu::ResourceDataValue &value, icu::UResourceTableSink &sink,
+ icu::ResourceDataValue &value, icu::ResourceTableSink &sink,
UErrorCode &errorCode);
/**
*/
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 */
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 */
#include "unicode/numfmt.h"
#include "currfmt.h"
#include "unicode/localpointer.h"
+#include "resource.h"
#include "simplepatternformatter.h"
#include "quantityformatter.h"
#include "unicode/plurrule.h"
#include "unicode/putil.h"
#include "unicode/smpdtfmt.h"
#include "uassert.h"
-#include "uresource.h"
#include "sharednumberformat.h"
#include "sharedpluralrules.h"
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] =
* 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.
* 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);
* 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);
* 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) {
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.
}
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;
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"