UErrorCode *pErrorCode)
{
/* char localeBuffer[ULOC_FULLNAME_CAPACITY*4];*/
- UResourceBundle *rb=NULL, table, subTable;
const UChar *item=NULL;
UErrorCode errorCode;
char explicitFallbackName[ULOC_FULLNAME_CAPACITY] = {0};
* this falls back through the locale's chain to root
*/
errorCode=U_ZERO_ERROR;
- rb=ures_open(path, locale, &errorCode);
+ icu::LocalUResourceBundlePointer rb(ures_open(path, locale, &errorCode));
if(U_FAILURE(errorCode)) {
/* total failure, not even root could be opened */
}
for(;;){
- ures_initStackObject(&table);
- ures_initStackObject(&subTable);
- ures_getByKeyWithFallback(rb, tableKey, &table, &errorCode);
+ icu::StackUResourceBundle table;
+ icu::StackUResourceBundle subTable;
+ ures_getByKeyWithFallback(rb.getAlias(), tableKey, table.getAlias(), &errorCode);
if (subTableKey != NULL) {
/*
- ures_getByKeyWithFallback(&table,subTableKey, &subTable, &errorCode);
- item = ures_getStringByKeyWithFallback(&subTable, itemKey, pLength, &errorCode);
+ ures_getByKeyWithFallback(table.getAlias(), subTableKey, subTable.getAlias(), &errorCode);
+ item = ures_getStringByKeyWithFallback(subTable.getAlias(), itemKey, pLength, &errorCode);
if(U_FAILURE(errorCode)){
*pErrorCode = errorCode;
}
break;*/
- ures_getByKeyWithFallback(&table,subTableKey, &table, &errorCode);
+ ures_getByKeyWithFallback(table.getAlias(), subTableKey, table.getAlias(), &errorCode);
}
if(U_SUCCESS(errorCode)){
- item = ures_getStringByKeyWithFallback(&table, itemKey, pLength, &errorCode);
+ item = ures_getStringByKeyWithFallback(table.getAlias(), itemKey, pLength, &errorCode);
if(U_FAILURE(errorCode)){
const char* replacement = NULL;
*pErrorCode = errorCode; /*save the errorCode*/
}
/*pointer comparison is ok since uloc_getCurrentCountryID & uloc_getCurrentLanguageID return the key itself is replacement is not found*/
if(replacement!=NULL && itemKey != replacement){
- item = ures_getStringByKeyWithFallback(&table, replacement, pLength, &errorCode);
+ item = ures_getStringByKeyWithFallback(table.getAlias(), replacement, pLength, &errorCode);
if(U_SUCCESS(errorCode)){
*pErrorCode = errorCode;
break;
*pErrorCode = errorCode;
errorCode = U_ZERO_ERROR;
- fallbackLocale = ures_getStringByKeyWithFallback(&table, "Fallback", &len, &errorCode);
+ fallbackLocale = ures_getStringByKeyWithFallback(table.getAlias(), "Fallback", &len, &errorCode);
if(U_FAILURE(errorCode)){
*pErrorCode = errorCode;
break;
*pErrorCode = U_INTERNAL_PROGRAM_ERROR;
break;
}
- ures_close(rb);
- rb = ures_open(path, explicitFallbackName, &errorCode);
+ rb.adoptInstead(ures_open(path, explicitFallbackName, &errorCode));
if(U_FAILURE(errorCode)){
*pErrorCode = errorCode;
break;
break;
}
}
- /* done with the locale string - ready to close table and rb */
- ures_close(&subTable);
- ures_close(&table);
- ures_close(rb);
+
return item;
}