mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 15:42:14 +00:00
ICU-882 Final removal of deprecated API
X-SVN-Rev: 5206
This commit is contained in:
parent
f0ea8f4523
commit
3b7fbcb29e
6 changed files with 13 additions and 1078 deletions
|
@ -48,19 +48,10 @@
|
|||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/resbund.h"
|
||||
#include "mutex.h"
|
||||
|
||||
#include "rbdata.h"
|
||||
#include "filestrm.h"
|
||||
#include "cstring.h"
|
||||
#include "uresimp.h"
|
||||
|
||||
#include "cmemory.h"
|
||||
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
#include "uhash.h"
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Implementation Notes
|
||||
*
|
||||
|
@ -175,12 +166,7 @@
|
|||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const char* ResourceBundle::kDefaultSuffix = ".res";
|
||||
const int32_t ResourceBundle::kDefaultSuffixLen = 4;
|
||||
const char* ResourceBundle::kDefaultFilename = "root";
|
||||
const char* ResourceBundle::kDefaultLocaleName = "root";
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
@ -188,24 +174,20 @@ ResourceBundle::ResourceBundle( const UnicodeString& path,
|
|||
const Locale& locale,
|
||||
UErrorCode& error)
|
||||
{
|
||||
constructForLocale(path, locale, error);
|
||||
constructForLocale(path, locale, error);
|
||||
}
|
||||
|
||||
ResourceBundle::ResourceBundle(UErrorCode &err) {
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
fItemCache = 0;
|
||||
#endif
|
||||
resource = ures_open(0, Locale::getDefault().getName(), &err);
|
||||
if(U_SUCCESS(err)) {
|
||||
fRealLocale = Locale(ures_getRealLocale(resource, &err));
|
||||
}
|
||||
resource = ures_open(0, Locale::getDefault().getName(), &err);
|
||||
if(U_SUCCESS(err)) {
|
||||
fRealLocale = Locale(ures_getRealLocale(resource, &err));
|
||||
}
|
||||
}
|
||||
|
||||
ResourceBundle::ResourceBundle( const UnicodeString& path,
|
||||
UErrorCode& error)
|
||||
{
|
||||
constructForLocale(path,
|
||||
Locale::getDefault(), error);
|
||||
constructForLocale(path, Locale::getDefault(), error);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -219,9 +201,6 @@ ResourceBundle::ResourceBundle( const UnicodeString& path,
|
|||
UErrorCode& status)
|
||||
: fRealLocale(localeName)
|
||||
{
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
fItemCache = 0;
|
||||
#endif
|
||||
int32_t patlen = path.length();
|
||||
|
||||
if(patlen > 0) {
|
||||
|
@ -242,7 +221,7 @@ ResourceBundle::ResourceBundle(const wchar_t* path,
|
|||
const Locale& locale,
|
||||
UErrorCode& err)
|
||||
{
|
||||
constructForLocale(path, locale, err);
|
||||
constructForLocale(path, locale, err);
|
||||
}
|
||||
|
||||
ResourceBundle::ResourceBundle(const ResourceBundle &other) {
|
||||
|
@ -252,9 +231,6 @@ ResourceBundle::ResourceBundle(const ResourceBundle &other) {
|
|||
if(other.resource->fIsTopLevel == TRUE) {
|
||||
constructForLocale(ures_getPath(other.resource), Locale(ures_getName(other.resource)), status);
|
||||
} else {
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
fItemCache = 0;
|
||||
#endif
|
||||
resource = copyResb(0, other.resource, &status);
|
||||
}
|
||||
} else {
|
||||
|
@ -264,16 +240,10 @@ ResourceBundle::ResourceBundle(const ResourceBundle &other) {
|
|||
}
|
||||
|
||||
ResourceBundle::ResourceBundle(UResourceBundle *res, UErrorCode& err) {
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
fItemCache = 0;
|
||||
#endif
|
||||
resource = copyResb(0, res, &err);
|
||||
}
|
||||
|
||||
ResourceBundle::ResourceBundle( const char* path, const Locale& locale, UErrorCode& err) {
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
fItemCache = 0;
|
||||
#endif
|
||||
resource = ures_open(path, locale.getName(), &err);
|
||||
if(U_SUCCESS(err)) {
|
||||
fRealLocale = Locale(ures_getRealLocale(resource, &err));
|
||||
|
@ -281,18 +251,11 @@ ResourceBundle::ResourceBundle( const char* path, const Locale& locale, UErrorCo
|
|||
}
|
||||
|
||||
|
||||
|
||||
ResourceBundle& ResourceBundle::operator=(const ResourceBundle& other)
|
||||
{
|
||||
if(this == &other) {
|
||||
return *this;
|
||||
}
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
if(fItemCache != 0) {
|
||||
uhash_close(fItemCache);
|
||||
fItemCache = 0;
|
||||
}
|
||||
#endif
|
||||
if(resource != 0) {
|
||||
ures_close(resource);
|
||||
resource = 0;
|
||||
|
@ -308,30 +271,11 @@ ResourceBundle& ResourceBundle::operator=(const ResourceBundle& other)
|
|||
|
||||
ResourceBundle::~ResourceBundle()
|
||||
{
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
if(fItemCache != 0) {
|
||||
uhash_close(fItemCache);
|
||||
}
|
||||
#endif
|
||||
if(resource != 0) {
|
||||
ures_close(resource);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
void
|
||||
ResourceBundle::deleteValue(UHashKey value) {
|
||||
delete (ResourceBundleData *)value.pointer;
|
||||
}
|
||||
|
||||
void ResourceBundle::initItemCache(UErrorCode& error) {
|
||||
if(fItemCache == 0) {
|
||||
fItemCache = uhash_open(uhash_hashChars, uhash_compareChars, &error);
|
||||
uhash_setValueDeleter(fItemCache, deleteValue);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
ResourceBundle::constructForLocale(const UnicodeString& path,
|
||||
const Locale& locale,
|
||||
|
@ -340,10 +284,6 @@ ResourceBundle::constructForLocale(const UnicodeString& path,
|
|||
char name[128];
|
||||
int32_t patlen = path.length();
|
||||
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
fItemCache = 0;
|
||||
#endif
|
||||
|
||||
if(patlen > 0) {
|
||||
path.extract(0, patlen, name);
|
||||
name[patlen] = '\0';
|
||||
|
@ -361,10 +301,6 @@ ResourceBundle::constructForLocale(const wchar_t* path,
|
|||
const Locale& locale,
|
||||
UErrorCode& error)
|
||||
{
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
fItemCache = 0;
|
||||
#endif
|
||||
|
||||
if(path != 0) {
|
||||
resource = ures_openW(path, locale.getName(), &error);
|
||||
} else {
|
||||
|
@ -383,11 +319,11 @@ UnicodeString ResourceBundle::getString(UErrorCode& status) const {
|
|||
}
|
||||
|
||||
const uint8_t *ResourceBundle::getBinary(int32_t& len, UErrorCode& status) const {
|
||||
return ures_getBinary(resource, &len, &status);
|
||||
return ures_getBinary(resource, &len, &status);
|
||||
}
|
||||
|
||||
const char *ResourceBundle::getName(void) {
|
||||
return ures_getName(resource);
|
||||
return ures_getName(resource);
|
||||
}
|
||||
|
||||
const char *ResourceBundle::getKey(void) {
|
||||
|
@ -461,283 +397,16 @@ UnicodeString ResourceBundle::getStringEx(const char* key, UErrorCode& status) c
|
|||
const char*
|
||||
ResourceBundle::getVersionNumber() const
|
||||
{
|
||||
return ures_getVersionNumber(resource);
|
||||
return ures_getVersionNumber(resource);
|
||||
}
|
||||
|
||||
void ResourceBundle::getVersion(UVersionInfo versionInfo) const {
|
||||
ures_getVersion(resource, versionInfo);
|
||||
ures_getVersion(resource, versionInfo);
|
||||
}
|
||||
|
||||
const Locale &ResourceBundle::getLocale(void) const
|
||||
{
|
||||
return fRealLocale;
|
||||
return fRealLocale;
|
||||
}
|
||||
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
// Start deprecated API
|
||||
const UnicodeString*
|
||||
ResourceBundle::getString( const char *resourceTag,
|
||||
UErrorCode& err) const
|
||||
{
|
||||
StringList *sldata;
|
||||
|
||||
|
||||
if(U_FAILURE(err)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
((ResourceBundle &)(*this)).initItemCache(err); // Semantically const
|
||||
|
||||
sldata = (StringList *)uhash_get(fItemCache, resourceTag);
|
||||
|
||||
if(sldata == 0) {
|
||||
const UChar *result = ures_get(resource, resourceTag, &err);
|
||||
if(result != 0) {
|
||||
UnicodeString *t = new UnicodeString[1];
|
||||
t->setTo(TRUE, result, -1);
|
||||
sldata = new StringList(t, 1);
|
||||
} else {
|
||||
err = U_MISSING_RESOURCE_ERROR;
|
||||
return 0;
|
||||
}
|
||||
sldata->fCreationStatus = err;
|
||||
uhash_put(fItemCache, (void *)resourceTag, sldata, &err);
|
||||
} else {
|
||||
err = sldata->fCreationStatus;
|
||||
}
|
||||
return sldata->fStrings;
|
||||
}
|
||||
|
||||
const UnicodeString*
|
||||
ResourceBundle::getStringArray( const char *resourceTag,
|
||||
int32_t& count,
|
||||
UErrorCode& err) const
|
||||
{
|
||||
UnicodeString *result;
|
||||
StringList *sldata;
|
||||
int32_t len=0;
|
||||
|
||||
if(U_FAILURE(err)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
((ResourceBundle &)(*this)).initItemCache(err); // Semantically const
|
||||
|
||||
sldata = (StringList *)uhash_get(fItemCache, resourceTag);
|
||||
|
||||
if(sldata == 0) {
|
||||
UResourceBundle array;
|
||||
ures_setIsStackObject(&array, TRUE);
|
||||
UErrorCode fallbackInfo = U_ZERO_ERROR;
|
||||
ures_getByKey(resource, resourceTag, &array, &fallbackInfo);
|
||||
if(U_SUCCESS(fallbackInfo)) {
|
||||
count = ures_getSize(&array);
|
||||
result = new UnicodeString[count];
|
||||
const UChar *string = 0;
|
||||
for(int32_t i=0; i<count; i++) {
|
||||
string = ures_getStringByIndex(&array, i, &len, &err);
|
||||
(result+i)->setTo(TRUE, string, len);
|
||||
}
|
||||
ures_close(&array);
|
||||
sldata = new StringList(result, count);
|
||||
} else {
|
||||
err = U_MISSING_RESOURCE_ERROR;
|
||||
return 0;
|
||||
}
|
||||
sldata->fCreationStatus = fallbackInfo;
|
||||
uhash_put(fItemCache, (void *)resourceTag, sldata, &err);
|
||||
err = fallbackInfo;
|
||||
} else {
|
||||
count = sldata->fCount;
|
||||
err = sldata->fCreationStatus;
|
||||
}
|
||||
return sldata->fStrings;
|
||||
}
|
||||
|
||||
const UnicodeString*
|
||||
ResourceBundle::getArrayItem( const char *resourceTag,
|
||||
int32_t indexS,
|
||||
UErrorCode& err) const
|
||||
{
|
||||
int32_t num;
|
||||
const UnicodeString *array = getStringArray(resourceTag, num, err);
|
||||
|
||||
if(U_FAILURE(err) || indexS<0 || indexS>=num) {
|
||||
err = U_MISSING_RESOURCE_ERROR;
|
||||
return 0;
|
||||
} else {
|
||||
return &array[indexS];
|
||||
}
|
||||
}
|
||||
|
||||
const UnicodeString**
|
||||
ResourceBundle::get2dArray(const char *resourceTag,
|
||||
int32_t& rowCount,
|
||||
int32_t& columnCount,
|
||||
UErrorCode& err) const
|
||||
{
|
||||
//UnicodeString **result = 0;
|
||||
UnicodeString **result;
|
||||
String2dList *sldata = 0;
|
||||
int32_t len=0;
|
||||
|
||||
if(U_FAILURE(err)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
((ResourceBundle &)(*this)).initItemCache(err); // Semantically const
|
||||
|
||||
sldata = (String2dList *)uhash_get(fItemCache, resourceTag);
|
||||
|
||||
if(sldata == 0) {
|
||||
UResourceBundle array;
|
||||
ures_setIsStackObject(&array, TRUE);
|
||||
UErrorCode fallbackInfo = U_ZERO_ERROR;
|
||||
ures_getByKey(resource, resourceTag, &array, &fallbackInfo);
|
||||
if(U_SUCCESS(fallbackInfo)) {
|
||||
rowCount = ures_getSize(&array);
|
||||
if(rowCount > 0) {
|
||||
result = new UnicodeString*[rowCount];
|
||||
UResourceBundle row;
|
||||
ures_setIsStackObject(&row, TRUE);
|
||||
ures_getByIndex(&array, 0, &row, &err);
|
||||
columnCount = ures_getSize(&row);
|
||||
const UChar* string = 0;
|
||||
for(int32_t i=0; i<rowCount; i++) {
|
||||
*(result+i) = new UnicodeString[columnCount];
|
||||
ures_getByIndex(&array, i, &row, &err);
|
||||
for(int32_t j=0; j<columnCount; j++) {
|
||||
string = ures_getStringByIndex(&row, j, &len, &err);
|
||||
(*(result+i)+j)->setTo(TRUE, string, len);
|
||||
}
|
||||
ures_close(&row);
|
||||
}
|
||||
sldata = new String2dList(result, rowCount, columnCount);
|
||||
sldata->fCreationStatus = fallbackInfo;
|
||||
uhash_put(fItemCache, (void *)resourceTag, sldata, &err);
|
||||
err = fallbackInfo;
|
||||
}
|
||||
ures_close(&array);
|
||||
} else {
|
||||
err = U_MISSING_RESOURCE_ERROR;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
rowCount = sldata->fRowCount;
|
||||
columnCount = sldata->fColCount;
|
||||
err = sldata->fCreationStatus;
|
||||
}
|
||||
|
||||
return (const UnicodeString**)sldata->fStrings;
|
||||
}
|
||||
|
||||
|
||||
const UnicodeString*
|
||||
ResourceBundle::get2dArrayItem(const char *resourceTag,
|
||||
int32_t rowIndex,
|
||||
int32_t columnIndex,
|
||||
UErrorCode& err) const
|
||||
{
|
||||
int32_t rows = 0;
|
||||
int32_t columns = 0;
|
||||
|
||||
const UnicodeString** array= get2dArray(resourceTag, rows, columns, err);
|
||||
|
||||
if(array == 0 || rowIndex < 0 || columnIndex < 0 || rowIndex >= rows || columnIndex >= columns) {
|
||||
err = U_MISSING_RESOURCE_ERROR;
|
||||
return 0;
|
||||
} else {
|
||||
return &array[rowIndex][columnIndex];
|
||||
}
|
||||
}
|
||||
|
||||
const UnicodeString*
|
||||
ResourceBundle::getTaggedArrayItem( const char *resourceTag,
|
||||
const UnicodeString& itemTag,
|
||||
UErrorCode& err) const
|
||||
{
|
||||
StringList *sldata = 0;
|
||||
int32_t len = 0;
|
||||
|
||||
if(U_FAILURE(err)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char item[256];
|
||||
char key[256];
|
||||
int32_t taglen = itemTag.length();
|
||||
itemTag.extract(0, taglen, key, "");
|
||||
key[taglen] = '\0';
|
||||
itemTag.extract(0, taglen, item, "");
|
||||
item[taglen] = '\0';
|
||||
uprv_strcat(key, resourceTag);
|
||||
|
||||
((ResourceBundle &)(*this)).initItemCache(err); // Semantically const
|
||||
|
||||
sldata = (StringList *)uhash_get(fItemCache, key);
|
||||
|
||||
if(sldata == 0) {
|
||||
UResourceBundle table;
|
||||
ures_setIsStackObject(&table, TRUE);
|
||||
UErrorCode fallbackInfo = U_ZERO_ERROR;
|
||||
ures_getByKey(resource, resourceTag, &table, &fallbackInfo);
|
||||
if(U_SUCCESS(fallbackInfo)) {
|
||||
const UChar *result = ures_getStringByKey(&table, item, &len, &err);
|
||||
if(result != 0) {
|
||||
UnicodeString *t = new UnicodeString[1];
|
||||
t->setTo(TRUE, result, len);
|
||||
sldata = new StringList(t, 1);
|
||||
} else {
|
||||
err = U_MISSING_RESOURCE_ERROR;
|
||||
return 0;
|
||||
}
|
||||
ures_close(&table);
|
||||
sldata->fCreationStatus = fallbackInfo;
|
||||
uhash_put(fItemCache, key, sldata, &err);
|
||||
err = fallbackInfo;
|
||||
} else {
|
||||
err = U_MISSING_RESOURCE_ERROR;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
err = sldata->fCreationStatus;
|
||||
}
|
||||
return sldata->fStrings;
|
||||
}
|
||||
|
||||
void
|
||||
ResourceBundle::getTaggedArray( const char *resourceTag,
|
||||
UnicodeString*& itemTags,
|
||||
UnicodeString*& items,
|
||||
int32_t& numItems,
|
||||
UErrorCode& err) const
|
||||
{
|
||||
if(U_FAILURE(err)) {
|
||||
return;
|
||||
}
|
||||
UResourceBundle table;
|
||||
ures_setIsStackObject(&table, TRUE);
|
||||
ures_getByKey(resource, resourceTag, &table, &err);
|
||||
if(U_SUCCESS(err)) {
|
||||
numItems = ures_getSize(&table);
|
||||
itemTags = new UnicodeString[numItems];
|
||||
items = new UnicodeString[numItems];
|
||||
const UChar *value = 0;
|
||||
const char *key = 0;
|
||||
int32_t len = 0;
|
||||
int16_t indexR = -1;
|
||||
res_getNextStringTableItem(&(table.fResData), table.fRes, &value, &key, &len, &indexR);
|
||||
while(value != 0) {
|
||||
items[indexR-1].setTo(value);
|
||||
itemTags[indexR-1].setTo(key);
|
||||
res_getNextStringTableItem(&(table.fResData), table.fRes, &value, &key, &len, &indexR);
|
||||
}
|
||||
} else {
|
||||
err = U_MISSING_RESOURCE_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//eof
|
||||
|
||||
|
|
|
@ -51,19 +51,8 @@
|
|||
#include "unicode/unistr.h"
|
||||
#include "unicode/locid.h"
|
||||
|
||||
#ifndef _FILESTRM
|
||||
typedef struct _FileStream FileStream;
|
||||
#endif
|
||||
|
||||
/* forward declarations */
|
||||
class Locale;
|
||||
class RuleBasedCollator;
|
||||
class ResourceBundle;
|
||||
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
struct UHashtable;
|
||||
union UHashKey;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A class representing a collection of resource information pertaining to a given
|
||||
|
@ -354,164 +343,6 @@ public:
|
|||
* @stable
|
||||
*/
|
||||
UnicodeString getStringEx(const char* key, UErrorCode& status) const;
|
||||
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
/**
|
||||
* Returns the contents of a string resource. Resource data is undifferentiated
|
||||
* Unicode text. The resource file may contain quoted strings or escape sequences;
|
||||
* these will be parsed prior to the data's return.
|
||||
*
|
||||
* @param resourceTag The resource tag of the string resource the caller wants
|
||||
* @param err Set to U_MISSING_RESOURCE_ERROR if a resource with the
|
||||
* specified tag couldn't be found.
|
||||
* @return A pointer to the string from the resource bundle, or NULL if there was
|
||||
* an error.(its lifetime is that of the resource bundle.)
|
||||
* @deprecated to be removed in first release in 2001. Use getStringEx() instead.
|
||||
*/
|
||||
const UnicodeString* getString( const char *resourceTag,
|
||||
UErrorCode& err) const;
|
||||
|
||||
/**
|
||||
* Returns the contents of a string-array resource. This will return the contents of
|
||||
* a string-array (comma-delimited-list) resource as a C++ array of UnicodeString
|
||||
* objects. The number of elements in the array is returned in numArrayItems.
|
||||
* Calling getStringArray on a resource of type string will return an array with one
|
||||
* element; calling it on a resource of type tagged-array results in a
|
||||
* U_MISSING_RESOURCE_ERROR error.
|
||||
*
|
||||
* @param resourceTag The resource tag of the string-array resource the caller
|
||||
* wants
|
||||
* @param numArrayItems Receives the number of items in the array the function
|
||||
* returns.
|
||||
* @param err Set to U_MISSING_RESOURCE_ERROR if a resource with the
|
||||
* specified tag couldn't be found.
|
||||
* @return The resource requested, as a pointer to an array of
|
||||
* UnicodeStrings. The caller does not own the storage and
|
||||
* must not delete it. (its lifetime is that of the resource bundle.)
|
||||
* @deprecated to be removed in first release in 2001. Use getStringEx() instead.
|
||||
*/
|
||||
const UnicodeString* getStringArray( const char *resourceTag,
|
||||
int32_t& numArrayItems,
|
||||
UErrorCode& err) const;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a single item from a string-array resource. This will return the contents
|
||||
* of a single item in a resource of string-array (comma-delimited-list) type. If
|
||||
* the resource is not an array, a U_MISSING_RESOURCE_ERROR will be returned in err.
|
||||
*
|
||||
* @param resourceTag The resource tag of the resource the caller wants to extract
|
||||
* an item from.
|
||||
* @param index The index (zero-based) of the particular array item the user
|
||||
* wants to extract from the resource.
|
||||
* @param err Set to U_MISSING_RESOURCE_ERROR if a resource with the
|
||||
* specified tag couldn't be found, or if the index was out of range.
|
||||
* @return A pointer to the text of the array item, or NULL is there was an error.
|
||||
* (its lifetime is that of the resource bundle.)
|
||||
* @deprecated to be removed in first release in 2001. Use getStringEx() instead.
|
||||
*/
|
||||
const UnicodeString* getArrayItem( const char *resourceTag,
|
||||
int32_t index,
|
||||
UErrorCode& err) const;
|
||||
|
||||
/**
|
||||
* Return the contents of a 2-dimensional array resource. The return value will be a
|
||||
* UnicodeString** array. (This is really an array of pointers; each pointer is a
|
||||
* ROW of the data.) The number of rows and columns is returned. If the resource is
|
||||
* of the wrong type, or not present, U_MISSING_RESOURCE_ERROR is placed in err.
|
||||
*
|
||||
* @param resourceTag The resource tag of the string-array resource the caller
|
||||
* wants
|
||||
* @param rowCount Receives the number of rows in the array the function
|
||||
* returns.
|
||||
* @param columnCount Receives the number of columns in the array the function
|
||||
* returns.
|
||||
* @param err Set to U_MISSING_RESOURCE_ERROR if a resource with the
|
||||
* specified tag couldn't be found.
|
||||
* @return The resource requested, as a UnicodeStrings**. The caller
|
||||
* does not own the storage and must not delete it. (its lifetime
|
||||
* is that of the resource bundle.)
|
||||
* @deprecated to be removed in first release in 2001. Use getStringEx() instead.
|
||||
*/
|
||||
const UnicodeString** get2dArray(const char *resourceTag,
|
||||
int32_t& rowCount,
|
||||
int32_t& columnCount,
|
||||
UErrorCode& err) const;
|
||||
|
||||
|
||||
/**
|
||||
* Return a single string from a 2-dimensional array resource. If the resource does
|
||||
* not exists, or if it is not a 2-d array, or if the row or column indices are out
|
||||
* of bounds, err is set to U_MISSING_RESOURCE_ERROR.
|
||||
*
|
||||
* @param resourceTag The resource tag of the resource the caller wants to extract
|
||||
* an item from.
|
||||
* @param rowIndex The row index (zero-based) of the array item the user wants
|
||||
* to extract from the resource.
|
||||
* @param columnIndex The column index (zero-based) of the array item the user
|
||||
* wants to extract from the resource.
|
||||
* @param err Set to U_MISSING_RESOURCE_ERROR if a resource with the
|
||||
* specified tag couldn't be found, if the resource data was in
|
||||
* the wrong format, or if either index is out of bounds.
|
||||
* @return A pointer to the text of the array item, or NULL is there was an error.
|
||||
* (its lifetime is that of the resource bundle.)
|
||||
* @deprecated to be removed in first release in 2001. Use getStringEx() instead.
|
||||
*/
|
||||
const UnicodeString* get2dArrayItem( const char *resourceTag,
|
||||
int32_t rowIndex,
|
||||
int32_t columnIndex,
|
||||
UErrorCode& err) const;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a single item from a tagged-array resource This will return the contents
|
||||
* of a single item in a resource of type tagged-array. If this function is called
|
||||
* for a resource that is not of type tagged-array, it will set err to
|
||||
* MISSING_RESOUCE_ERROR.
|
||||
*
|
||||
* @param resourceTag The resource tag of the resource the caller wants to extract
|
||||
* an item from.
|
||||
* @param itemTag The item tag for the item the caller wants to extract.
|
||||
* @param err Set to U_MISSING_RESOURCE_ERROR if a resource with the
|
||||
* specified resource tag couldn't be found, or if an item
|
||||
* with the specified item tag coldn't be found in the resource.
|
||||
* @return A pointer to the text of the array item, or NULL is there was an error.
|
||||
* (its lifetime is that of the resource bundle.)
|
||||
* @deprecated to be removed in first release in 2001. Use getStringEx() instead.
|
||||
*/
|
||||
const UnicodeString* getTaggedArrayItem( const char *resourceTag,
|
||||
const UnicodeString& itemTag,
|
||||
UErrorCode& err) const;
|
||||
|
||||
/**
|
||||
* Returns a tagged-array resource. The contents of the resource is returned as two
|
||||
* separate arrays of UnicodeStrings, the addresses of which are placed in "itemTags"
|
||||
* and "items". After calling this function, the items in the resource will be in the
|
||||
* list pointed to by "items", and for each items[i], itemTags[i] will be the tag that
|
||||
* corresponds to it. The total number of entries in both arrays is returned in
|
||||
* numItems.
|
||||
*
|
||||
* @param resourceTag The resource tag of the resource the caller wants to extract
|
||||
* an item from.
|
||||
* @param itemTags Set to point to an array of UnicodeStrings representing the
|
||||
* tags in the specified resource. The caller DOES own this array,
|
||||
* and must delete it.
|
||||
* @param items Set to point to an array of UnicodeStrings containing the
|
||||
* individual resource items themselves. itemTags[i] will
|
||||
* contain the tag corresponding to items[i]. The caller DOES
|
||||
* own this array, and must delete it.
|
||||
* @param numItems Receives the number of items in the arrays pointed to by
|
||||
* items and itemTags.
|
||||
* @param err Set to U_MISSING_RESOURCE_ERROR if a resource with the
|
||||
* specified tag couldn't be found.
|
||||
* @deprecated to be removed in first release in 2001. Use getStringEx() instead.
|
||||
*/
|
||||
void getTaggedArray( const char *resourceTag,
|
||||
UnicodeString*& itemTags,
|
||||
UnicodeString*& items,
|
||||
int32_t& numItems,
|
||||
UErrorCode& err) const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return the version number associated with this ResourceBundle. This version
|
||||
|
@ -532,7 +363,7 @@ public:
|
|||
* string.
|
||||
* @draft
|
||||
*/
|
||||
const char* getVersionNumber(void) const;
|
||||
const char* getVersionNumber(void) const;
|
||||
|
||||
void getVersion(UVersionInfo versionInfo) const;
|
||||
|
||||
|
@ -548,9 +379,6 @@ private:
|
|||
UResourceBundle *resource;
|
||||
void constructForLocale(const UnicodeString& path, const Locale& locale, UErrorCode& error);
|
||||
void constructForLocale(const wchar_t* path, const Locale& locale, UErrorCode& error);
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
void initItemCache(UErrorCode& error);
|
||||
#endif
|
||||
|
||||
friend class RuleBasedCollator;
|
||||
|
||||
|
@ -566,15 +394,7 @@ private:
|
|||
private:
|
||||
Locale fRealLocale;
|
||||
|
||||
#ifdef ICU_RESBUND_USE_DEPRECATES
|
||||
static void U_CALLCONV deleteValue(UHashKey value);
|
||||
UHashtable* fItemCache;
|
||||
#endif
|
||||
|
||||
static const char* kDefaultSuffix;
|
||||
static const int32_t kDefaultSuffixLen;
|
||||
static const char* kDefaultFilename;
|
||||
static const char* kDefaultLocaleName;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -245,101 +245,6 @@ U_CAPI UResourceBundle* U_EXPORT2 ures_openU(const UChar* path,
|
|||
const char* locale,
|
||||
UErrorCode* status);
|
||||
|
||||
#ifdef ICU_URES_USE_DEPRECATES
|
||||
/**
|
||||
* returns a resource string, given a resource bundle and a key.
|
||||
*
|
||||
* @param resourceBundle: resourceBundle containing the desired string
|
||||
* @param resourceTag: key tagging the desired string
|
||||
* @param status: fills in the outgoing error code
|
||||
* could be <TT>U_MISSING_RESOURCE_ERROR</T> if the key is not found
|
||||
* could be a non-failing error
|
||||
* e.g.: <TT>U_USING_FALLBACK_ERROR</TT>,<TT>U_USING_DEFAULT_ERROR </TT>
|
||||
* @return a library-owned zero-terminated unicode string (its lifetime
|
||||
* is that of the resource bundle.)
|
||||
* @see ures_getArrayItem
|
||||
* @see ures_get2dArrayItem
|
||||
* @see ures_getTaggedItem
|
||||
* @deprecated Remove after 2000-dec-31. Use ures_getStringByKey instead.
|
||||
*/
|
||||
U_CAPI const UChar* U_EXPORT2 ures_get(const UResourceBundle* resourceBundle,
|
||||
const char* resourceTag,
|
||||
UErrorCode* status);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a resource string which is part of an array, given a resource bundle
|
||||
* a key to the array and the index of the desired string.
|
||||
*
|
||||
* @param resourceBundle: resourceBundle containing the desired string
|
||||
* @param resourceTag: key tagging the desired array
|
||||
* @param resourceIndex: index of the desired string
|
||||
* @param status: fills in the outgoing error code
|
||||
* could be <TT>U_MISSING_RESOURCE_ERROR</T> if the key is not found
|
||||
* could be a non-failing error
|
||||
* e.g.: <TT>U_USING_FALLBACK_ERROR</TT>,<TT>U_USING_DEFAULT_ERROR </TT>
|
||||
* @return: a library-owned zero-terminated unicode string (its lifetime
|
||||
* is that of the resource bundle.)
|
||||
* @see ures_get
|
||||
* @see ures_get2dArrayItem
|
||||
* @see ures_getTaggedItem
|
||||
* @deprecated Remove after 2000-dec-31. Use ures_getByKey and ures_getByIndex instead.
|
||||
*/
|
||||
U_CAPI const UChar* U_EXPORT2 ures_getArrayItem(const UResourceBundle* resourceBundle,
|
||||
const char* resourceTag,
|
||||
int32_t resourceIndex,
|
||||
UErrorCode* status);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a resource string which is part of a 2D array, given a resource bundle
|
||||
* a key to the array and the index pair of the desired string.
|
||||
*
|
||||
* @param resourceBundle: resourceBundle containing the desired string
|
||||
* @param resourceTag: key tagging the desired array
|
||||
* @param resourceIndex: x index of the desired string
|
||||
* @param resourceIndex: y index of the desired string
|
||||
* @param status: fills in the outgoing error code
|
||||
* could be <TT>U_MISSING_RESOURCE_ERROR</T> if the key is not found
|
||||
* could be a non-failing error
|
||||
* e.g.: <TT>U_USING_FALLBACK_ERROR</TT>,<TT>U_USING_DEFAULT_ERROR </TT>
|
||||
* @return: a library-owned zero-terminated unicode string (its lifetime
|
||||
* is that of the resource bundle.)
|
||||
* @see ures_get
|
||||
* @see ures_getArrayItem
|
||||
* @see ures_getTaggedItem
|
||||
* @deprecated Remove after 2000-dec-31. Use ures_getByKey and ures_getByIndex instead.
|
||||
*/
|
||||
U_CAPI const UChar* U_EXPORT2 ures_get2dArrayItem(const UResourceBundle* resourceBundle,
|
||||
const char* resourceTag,
|
||||
int32_t rowIndex,
|
||||
int32_t columnIndex,
|
||||
UErrorCode* status);
|
||||
|
||||
/**
|
||||
* Returns a resource string which is part of a tagged array, given a resource bundle
|
||||
* a key to the array and the key of the desired string.
|
||||
*
|
||||
* @param resourceBundle: resource bundle containing the desired string
|
||||
* @param resourceTag: key tagging the desired array
|
||||
* @param resourceIndex: key tagging the desired string
|
||||
* @param status: fills in the outgoing error code
|
||||
* could be <TT>U_MISSING_RESOURCE_ERROR</T> if the key is not found
|
||||
* could be a non-failing error
|
||||
* e.g.: <TT>U_USING_FALLBACK_ERROR</TT>,<TT>U_USING_DEFAULT_ERROR </TT>
|
||||
* @return: a library-owned zero-terminated unicode string (its lifetime
|
||||
* is that of the resource bundle.)
|
||||
* @see ures_get
|
||||
* @see ures_getArrayItem
|
||||
* @see ures_get2dItem
|
||||
* @deprecated Remove after 2000-dec-31. Use ures_getByKey and ures_getStringByKey instead.
|
||||
*/
|
||||
U_CAPI const UChar* U_EXPORT2 ures_getTaggedArrayItem(const UResourceBundle* resourceBundle,
|
||||
const char* resourceTag,
|
||||
const char* itemTag,
|
||||
UErrorCode* status);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns the number of strings/arrays in resource bundles.
|
||||
*
|
||||
|
|
|
@ -1085,105 +1085,6 @@ U_CAPI UBool ures_isStackObject( UResourceBundle* resB, UErrorCode *status) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef ICU_URES_USE_DEPRECATES
|
||||
|
||||
U_CAPI const UChar* ures_get( const UResourceBundle* resB,
|
||||
const char* resourceTag,
|
||||
UErrorCode* status)
|
||||
{
|
||||
int32_t len = 0;
|
||||
if(resB == NULL || U_FAILURE(*status)) {
|
||||
*status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
return ures_getStringByKey(resB, resourceTag, &len, status);
|
||||
}
|
||||
|
||||
U_CAPI const UChar* ures_getArrayItem(const UResourceBundle* resB,
|
||||
const char* resourceTag,
|
||||
int32_t resourceIndex,
|
||||
UErrorCode* status)
|
||||
{
|
||||
UResourceBundle res;
|
||||
ures_setIsStackObject(&res, TRUE);
|
||||
if (status==NULL || U_FAILURE(*status)) {
|
||||
return NULL;
|
||||
}
|
||||
if(resB == NULL) {
|
||||
*status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
ures_getByKey(resB, resourceTag, &res, status);
|
||||
if(U_SUCCESS(*status)) {
|
||||
int32_t len = 0;
|
||||
const UChar *r = ures_getStringByIndex(&res, resourceIndex, &len, status);
|
||||
ures_close(&res);
|
||||
return r;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
U_CAPI const UChar* ures_get2dArrayItem(const UResourceBundle* resB,
|
||||
const char* resourceTag,
|
||||
int32_t rowIndex,
|
||||
int32_t columnIndex,
|
||||
UErrorCode* status)
|
||||
{
|
||||
UResourceBundle res;
|
||||
ures_setIsStackObject(&res, TRUE);
|
||||
if (status==NULL || U_FAILURE(*status)) {
|
||||
return NULL;
|
||||
}
|
||||
if(resB == NULL) {
|
||||
*status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
ures_getByKey(resB, resourceTag, &res, status);
|
||||
if(U_SUCCESS(*status)) {
|
||||
UResourceBundle res2;
|
||||
ures_setIsStackObject(&res2, TRUE);
|
||||
ures_getByIndex(&res, rowIndex, &res2, status);
|
||||
ures_close(&res);
|
||||
if(U_SUCCESS(*status)) {
|
||||
int32_t len = 0;
|
||||
const UChar *r = ures_getStringByIndex(&res2, columnIndex, &len, status);
|
||||
ures_close(&res2);
|
||||
return r;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
U_CAPI const UChar* ures_getTaggedArrayItem(const UResourceBundle* resB,
|
||||
const char* resourceTag,
|
||||
const char* itemTag,
|
||||
UErrorCode* status)
|
||||
{
|
||||
UResourceBundle res;
|
||||
ures_setIsStackObject(&res, TRUE);
|
||||
if (status==NULL || U_FAILURE(*status)) {
|
||||
return NULL;
|
||||
}
|
||||
if(resB == NULL) {
|
||||
*status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
ures_getByKey(resB, resourceTag, &res, status);
|
||||
if(U_SUCCESS(*status)) {
|
||||
int32_t len = 0;
|
||||
const UChar *r = ures_getStringByKey(&res, itemTag, &len, status);
|
||||
ures_close(&res);
|
||||
return r;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* API: Counts members. For arrays and tables, returns number of resources.
|
||||
* For strings, returns 1.
|
||||
|
|
|
@ -31,41 +31,6 @@ void TestFallback(void);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifdef ICU_URES_USE_DEPRECATES
|
||||
/**
|
||||
* Convert an integer, positive or negative, to a character string radix 10.
|
||||
*/
|
||||
static char*
|
||||
itoa1(int32_t i, char* buf)
|
||||
{
|
||||
char *p = 0;
|
||||
char* result = buf;
|
||||
/* Handle negative */
|
||||
if(i < 0) {
|
||||
*buf++ = '-';
|
||||
i = -i;
|
||||
}
|
||||
|
||||
/* Output digits in reverse order */
|
||||
p = buf;
|
||||
do {
|
||||
*p++ = (char)('0' + (i % 10));
|
||||
i /= 10;
|
||||
}
|
||||
while(i);
|
||||
*p-- = 0;
|
||||
|
||||
/* Reverse the string */
|
||||
while(buf < p) {
|
||||
char c = *buf;
|
||||
*buf++ = *p;
|
||||
*p-- = c;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
const UChar kERROR[] = { 0x0045 /*E*/, 0x0052 /*'R'*/, 0x0052 /*'R'*/,
|
||||
0x004F /*'O'*/, 0x0052/*'R'*/, 0x0000 /*'\0'*/};
|
||||
|
||||
|
@ -301,17 +266,6 @@ UBool testTag(const char* frag,
|
|||
int32_t actual_bundle;
|
||||
int32_t resultLen;
|
||||
char testdatapath[256];
|
||||
|
||||
#ifdef ICU_URES_USE_DEPRECATES
|
||||
int32_t row_count=0;
|
||||
int32_t column_count=0;
|
||||
int32_t count = 0;
|
||||
int32_t index = 0;
|
||||
UErrorCode expected_status;
|
||||
int32_t k,row,col;
|
||||
char buf[5];
|
||||
#endif
|
||||
|
||||
const char *directory= u_getDataDirectory();
|
||||
|
||||
uprv_strcpy(testdatapath, directory);
|
||||
|
@ -449,161 +403,8 @@ UBool testTag(const char* frag,
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
CONFIRM_EQ(string, expected_string);
|
||||
|
||||
|
||||
#ifdef ICU_URES_USE_DEPRECATES
|
||||
|
||||
/*-------------------------------------------------------------------- */
|
||||
/*-------------------------------------------------------------------- */
|
||||
/* arrayItem */
|
||||
|
||||
strcpy(tag,"array_");
|
||||
strcat(tag,frag);
|
||||
|
||||
strcpy(action,param[i].name);
|
||||
strcat(action, ".ures_getArrayItem(");
|
||||
strcat(action, tag);
|
||||
strcat(action, ")");
|
||||
count=ures_countArrayItems(theBundle, tag, &status);
|
||||
|
||||
|
||||
for(j = 0; j < count; j++)
|
||||
{
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
string = kERROR;
|
||||
|
||||
index=j;
|
||||
ures_getArrayItem(theBundle, tag,index , &status);
|
||||
if(U_SUCCESS(status))
|
||||
string=ures_getArrayItem(theBundle, tag, index, &status);
|
||||
|
||||
|
||||
/* how could 'index==j' ever be >= count ? */
|
||||
expected_status = (index >= 0 && index < count) ? expected_resource_status : U_MISSING_RESOURCE_ERROR;
|
||||
|
||||
log_verbose("Status for %s was %d, expected %d\n", action, status, expected_status);
|
||||
|
||||
CONFIRM_ErrorCode(status,expected_status);
|
||||
|
||||
if (U_SUCCESS(status))
|
||||
{
|
||||
UChar element[3];
|
||||
|
||||
u_uastrcpy(element, itoa1(index,buf));
|
||||
|
||||
u_strcpy(expected_string,base);
|
||||
u_strcat(expected_string,element);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
u_strcpy(expected_string,kERROR);
|
||||
}
|
||||
CONFIRM_EQ(string,expected_string);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------- */
|
||||
/* 2dArrayItem */
|
||||
|
||||
strcpy(tag,"array_2d_");
|
||||
strcat(tag,frag);
|
||||
|
||||
strcpy(action,param[i].name);
|
||||
strcat(action, ".get2dArrayItem(");
|
||||
strcat(action, tag);
|
||||
strcat(action, ")");
|
||||
row_count=ures_countArrayItems(theBundle, tag, &status);
|
||||
column_count=2;
|
||||
|
||||
for(k=0;k<row_count;k++){
|
||||
for (j=0; j<column_count; ++j){
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
string = kERROR;
|
||||
row=k;
|
||||
col=j;
|
||||
ures_get2dArrayItem( theBundle, tag, row, col, &status);
|
||||
if(U_SUCCESS(status))
|
||||
string=ures_get2dArrayItem(theBundle, tag, row, col, &status);
|
||||
|
||||
|
||||
expected_status = (row >= 0 && row < row_count && col >= 0 && col < column_count) ?
|
||||
expected_resource_status : U_MISSING_RESOURCE_ERROR;
|
||||
|
||||
CONFIRM_ErrorCode(status,expected_status);
|
||||
|
||||
if (U_SUCCESS(status))
|
||||
{
|
||||
UChar element[3];
|
||||
u_strcpy(expected_string,base);
|
||||
u_uastrcpy(element,itoa1(row,buf));
|
||||
u_strcat(expected_string, element);
|
||||
u_uastrcpy(element,itoa1(col,buf));
|
||||
u_strcat(expected_string, element);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
u_strcpy(expected_string,kERROR);
|
||||
}
|
||||
CONFIRM_EQ(string,expected_string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------- */
|
||||
/* taggedArrayItem */
|
||||
|
||||
strcpy(tag,"tagged_array_");
|
||||
strcat(tag,frag);
|
||||
|
||||
strcpy(action,param[i].name);
|
||||
strcat(action,".getTaggedArrayItem(");
|
||||
strcat(action, tag);
|
||||
strcat(action,")");
|
||||
|
||||
count = 0;
|
||||
for (index=-20; index<20; ++index)
|
||||
{
|
||||
strcpy(item_tag, "tag");
|
||||
strcat(item_tag, itoa1(index,buf));
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
string = kERROR;
|
||||
|
||||
|
||||
ures_getTaggedArrayItem( theBundle, tag, item_tag, &status);
|
||||
if(U_SUCCESS(status))
|
||||
string=ures_getTaggedArrayItem(theBundle, tag, item_tag, &status);
|
||||
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
CONFIRM_ErrorCode(status,U_MISSING_RESOURCE_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
UChar* element;
|
||||
if (strcmp(myErrorName(status),"U_MISSING_RESOURCE_ERROR")!=0) {
|
||||
count++;
|
||||
u_strcpy(expected_string,base);
|
||||
element=(UChar*)malloc(sizeof(UChar) * (strlen(buf)+1));
|
||||
u_uastrcpy(element,buf);
|
||||
u_strcat(expected_string,element);
|
||||
free(element);
|
||||
CONFIRM_EQ(string,expected_string);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
free(expected_string);
|
||||
ures_close(theBundle);
|
||||
}
|
||||
|
|
|
@ -505,167 +505,6 @@ ResourceBundleTest::testTag(const char* frag,
|
|||
return (UBool)(failOrig != fail);
|
||||
}
|
||||
|
||||
|
||||
// This is deprecated
|
||||
//--------------------------------------------------------------------------
|
||||
// 2dArray
|
||||
|
||||
/*
|
||||
uprv_strcpy(tag, "array_2d_");
|
||||
uprv_strcat(tag, frag);
|
||||
|
||||
action = param[i].name;
|
||||
action += ".get2dArray(";
|
||||
action += tag;
|
||||
action += ")";
|
||||
|
||||
|
||||
const UnicodeString* array = theBundle.getStringArray(tag, count, status);
|
||||
CONFIRM_UErrorCode(status, expected_resource_status, action);
|
||||
int32_t row_count = kERROR_COUNT, column_count = kERROR_COUNT;
|
||||
int32_t row, col;
|
||||
status = U_ZERO_ERROR;
|
||||
const UnicodeString** array2d = theBundle.get2dArray(tag, row_count, column_count, status);
|
||||
CONFIRM_UErrorCode(status,expected_resource_status, action);
|
||||
|
||||
if (U_SUCCESS(status))
|
||||
{
|
||||
CONFIRM_GE(row_count, 1, action);
|
||||
CONFIRM_GE(column_count, (int32_t)0, action);
|
||||
CONFIRM_NE((int32_t)(unsigned long)array, (int32_t)0, action);
|
||||
|
||||
for (row=0; row<row_count; ++row)
|
||||
{
|
||||
for (col=0; col<column_count; ++col)
|
||||
{
|
||||
char buf[32];
|
||||
expected_string = base;
|
||||
expected_string += itoa(row,buf);
|
||||
expected_string += itoa(col,buf);
|
||||
CONFIRM_EQ(array2d[row][col], expected_string, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CONFIRM_EQ(row_count, kERROR_COUNT, action);
|
||||
CONFIRM_EQ(column_count, kERROR_COUNT, action);
|
||||
CONFIRM_EQ((int32_t)(unsigned long)array, (int32_t)0, action);
|
||||
row_count = column_count = 0;
|
||||
}
|
||||
|
||||
// This is deprecated
|
||||
//--------------------------------------------------------------------------
|
||||
// 2dArrayItem
|
||||
|
||||
action = param[i].name;
|
||||
action += ".get2dArrayItem(";
|
||||
action += tag;
|
||||
action += ")";
|
||||
|
||||
for (j=0; j<200; ++j)
|
||||
{
|
||||
row = row_count ? (randi(row_count * 3) - row_count) : (randi(200) - 100);
|
||||
col = column_count ? (randi(column_count * 3) - column_count) : (randi(200) - 100);
|
||||
status = U_ZERO_ERROR;
|
||||
string = kERROR;
|
||||
const UnicodeString *t = theBundle.get2dArrayItem(tag, row, col, status);
|
||||
if(t!=NULL) {
|
||||
string = *t;
|
||||
}
|
||||
expected_status = (row >= 0 && row < row_count && col >= 0 && col < column_count) ?
|
||||
expected_resource_status: U_MISSING_RESOURCE_ERROR;
|
||||
CONFIRM_UErrorCode(status, expected_status, action);
|
||||
|
||||
if (U_SUCCESS(status))
|
||||
{
|
||||
char buf[32];
|
||||
expected_string = base;
|
||||
expected_string += itoa(row,buf);
|
||||
expected_string += itoa(col,buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
expected_string = kERROR;
|
||||
}
|
||||
CONFIRM_EQ(string, expected_string, action);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// taggedArrayItem
|
||||
|
||||
uprv_strcpy(tag, "tagged_array_");
|
||||
uprv_strcat(tag, frag);
|
||||
|
||||
action = param[i].name;
|
||||
action += ".getTaggedArray(";
|
||||
action += tag;
|
||||
action += ")";
|
||||
|
||||
UnicodeString* tags = 0;
|
||||
UnicodeString* items = 0;
|
||||
int32_t expected_count;
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
theBundle.getTaggedArray(tag, tags, items, expected_count, status);
|
||||
CONFIRM_UErrorCode(status, expected_resource_status, action);
|
||||
|
||||
if (U_SUCCESS(status)) {
|
||||
CONFIRM_GE((int32_t)expected_count, (int32_t)0, action);
|
||||
CONFIRM_NE((int32_t)(unsigned long)tags, (int32_t)0, action);
|
||||
CONFIRM_NE((int32_t)(unsigned long)items, (int32_t)0, action);
|
||||
|
||||
for (index = 0; index < expected_count; index++) {
|
||||
logln("tag = " + tags[index] + ", value = " + items[index]);
|
||||
if (tags[index].startsWith("tag") && items[index].startsWith(base))
|
||||
record_pass(tags[index]);
|
||||
else
|
||||
record_fail(tags[index]);
|
||||
}
|
||||
}
|
||||
else
|
||||
expected_count = 0;
|
||||
delete [] tags;
|
||||
delete [] items;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// taggedArrayItem
|
||||
|
||||
action = param[i].name;
|
||||
action += ".getTaggedArrayItem(";
|
||||
action += tag;
|
||||
action += ")";
|
||||
|
||||
count = 0;
|
||||
for (index=-20; index<20; ++index)
|
||||
{
|
||||
char buf[32];
|
||||
UnicodeString item_tag("tag");
|
||||
item_tag += itoa(index,buf);
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
string = kERROR;
|
||||
const UnicodeString *t = theBundle.getTaggedArrayItem(tag,item_tag,status);
|
||||
if(t!=NULL) {
|
||||
string = *t;
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
CONFIRM_UErrorCode(status, U_MISSING_RESOURCE_ERROR, action);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (status != U_MISSING_RESOURCE_ERROR) {
|
||||
count++;
|
||||
expected_string = base;
|
||||
expected_string += buf;
|
||||
CONFIRM_EQ(string, expected_string, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
CONFIRM_EQ(count, expected_count, action);
|
||||
*/
|
||||
}
|
||||
|
||||
return (UBool)(failOrig != fail);
|
||||
|
|
Loading…
Add table
Reference in a new issue