Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /** |
michael@0 | 2 | ******************************************************************************* |
michael@0 | 3 | * Copyright (C) 2001-2005, International Business Machines Corporation and * |
michael@0 | 4 | * others. All Rights Reserved. * |
michael@0 | 5 | ******************************************************************************* |
michael@0 | 6 | * |
michael@0 | 7 | ******************************************************************************* |
michael@0 | 8 | */ |
michael@0 | 9 | #include "unicode/utypes.h" |
michael@0 | 10 | |
michael@0 | 11 | #if !UCONFIG_NO_SERVICE |
michael@0 | 12 | |
michael@0 | 13 | #include "unicode/resbund.h" |
michael@0 | 14 | #include "uresimp.h" |
michael@0 | 15 | #include "cmemory.h" |
michael@0 | 16 | #include "servloc.h" |
michael@0 | 17 | #include "ustrfmt.h" |
michael@0 | 18 | #include "uhash.h" |
michael@0 | 19 | #include "charstr.h" |
michael@0 | 20 | #include "ucln_cmn.h" |
michael@0 | 21 | #include "uassert.h" |
michael@0 | 22 | |
michael@0 | 23 | #define UNDERSCORE_CHAR ((UChar)0x005f) |
michael@0 | 24 | #define AT_SIGN_CHAR ((UChar)64) |
michael@0 | 25 | #define PERIOD_CHAR ((UChar)46) |
michael@0 | 26 | |
michael@0 | 27 | U_NAMESPACE_BEGIN |
michael@0 | 28 | |
michael@0 | 29 | ICUResourceBundleFactory::ICUResourceBundleFactory() |
michael@0 | 30 | : LocaleKeyFactory(VISIBLE) |
michael@0 | 31 | , _bundleName() |
michael@0 | 32 | { |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | ICUResourceBundleFactory::ICUResourceBundleFactory(const UnicodeString& bundleName) |
michael@0 | 36 | : LocaleKeyFactory(VISIBLE) |
michael@0 | 37 | , _bundleName(bundleName) |
michael@0 | 38 | { |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | ICUResourceBundleFactory::~ICUResourceBundleFactory() {} |
michael@0 | 42 | |
michael@0 | 43 | const Hashtable* |
michael@0 | 44 | ICUResourceBundleFactory::getSupportedIDs(UErrorCode& status) const |
michael@0 | 45 | { |
michael@0 | 46 | if (U_SUCCESS(status)) { |
michael@0 | 47 | return LocaleUtility::getAvailableLocaleNames(_bundleName); |
michael@0 | 48 | } |
michael@0 | 49 | return NULL; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | UObject* |
michael@0 | 53 | ICUResourceBundleFactory::handleCreate(const Locale& loc, int32_t /* kind */, const ICUService* /* service */, UErrorCode& status) const |
michael@0 | 54 | { |
michael@0 | 55 | if (U_SUCCESS(status)) { |
michael@0 | 56 | // _bundleName is a package name |
michael@0 | 57 | // and should only contain invariant characters |
michael@0 | 58 | // ??? is it always true that the max length of the bundle name is 19? |
michael@0 | 59 | // who made this change? -- dlf |
michael@0 | 60 | char pkg[20]; |
michael@0 | 61 | int32_t length; |
michael@0 | 62 | length=_bundleName.extract(0, INT32_MAX, pkg, (int32_t)sizeof(pkg), US_INV); |
michael@0 | 63 | if(length>=(int32_t)sizeof(pkg)) { |
michael@0 | 64 | return NULL; |
michael@0 | 65 | } |
michael@0 | 66 | return new ResourceBundle(pkg, loc, status); |
michael@0 | 67 | } |
michael@0 | 68 | return NULL; |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | #ifdef SERVICE_DEBUG |
michael@0 | 72 | UnicodeString& |
michael@0 | 73 | ICUResourceBundleFactory::debug(UnicodeString& result) const |
michael@0 | 74 | { |
michael@0 | 75 | LocaleKeyFactory::debug(result); |
michael@0 | 76 | result.append(", bundle: "); |
michael@0 | 77 | return result.append(_bundleName); |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | UnicodeString& |
michael@0 | 81 | ICUResourceBundleFactory::debugClass(UnicodeString& result) const |
michael@0 | 82 | { |
michael@0 | 83 | return result.append("ICUResourceBundleFactory"); |
michael@0 | 84 | } |
michael@0 | 85 | #endif |
michael@0 | 86 | |
michael@0 | 87 | UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ICUResourceBundleFactory) |
michael@0 | 88 | |
michael@0 | 89 | U_NAMESPACE_END |
michael@0 | 90 | |
michael@0 | 91 | /* !UCONFIG_NO_SERVICE */ |
michael@0 | 92 | #endif |
michael@0 | 93 | |
michael@0 | 94 |