From d52f9ef512185576e08fdd837ca20c0a019df20a Mon Sep 17 00:00:00 2001 From: Ram Viswanadha Date: Sat, 15 May 2004 00:16:32 +0000 Subject: [PATCH] ICU-3699 add getWithFallback API for CLDR tools X-SVN-Rev: 15321 --- icu4c/source/common/resbund.cpp | 10 ++++++++++ icu4c/source/common/unicode/resbund.h | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/icu4c/source/common/resbund.cpp b/icu4c/source/common/resbund.cpp index ce0efabcb9b..4ecf6332047 100644 --- a/icu4c/source/common/resbund.cpp +++ b/icu4c/source/common/resbund.cpp @@ -371,6 +371,16 @@ ResourceBundle ResourceBundle::get(const char* key, UErrorCode& status) const { return res; } +ResourceBundle ResourceBundle::getWithFallback(const char* key, UErrorCode& status){ + UResourceBundle r; + ures_initStackObject(&r); + ures_getByKeyWithFallback(fResource, key, &r, &status); + ResourceBundle res(&r, status); + if(U_SUCCESS(status)){ + ures_close(&r); + } + return res; +} UnicodeString ResourceBundle::getStringEx(const char* key, UErrorCode& status) const { int32_t len = 0; const UChar* r = ures_getStringByKey(fResource, key, &len, &status); diff --git a/icu4c/source/common/unicode/resbund.h b/icu4c/source/common/unicode/resbund.h index d412b2959d3..83090c80465 100644 --- a/icu4c/source/common/unicode/resbund.h +++ b/icu4c/source/common/unicode/resbund.h @@ -439,7 +439,12 @@ public: */ const Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const; - + /** + * This API implements multilevel fallback + * @internal + */ + ResourceBundle + getWithFallback(const char* key, UErrorCode& status); /** * ICU "poor man's RTTI", returns a UClassID for the actual class. *