1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2001-2014, International Business Machines Corporation and *
6 * others. All Rights Reserved. *
7 *******************************************************************************
9 *******************************************************************************
11 #include "unicode/utypes.h"
13 #if !UCONFIG_NO_SERVICE
15 #include "unicode/resbund.h"
25 #define UNDERSCORE_CHAR ((UChar)0x005f)
26 #define AT_SIGN_CHAR ((UChar)64)
27 #define PERIOD_CHAR ((UChar)46)
31 ICUResourceBundleFactory::ICUResourceBundleFactory()
32 : LocaleKeyFactory(VISIBLE)
37 ICUResourceBundleFactory::ICUResourceBundleFactory(const UnicodeString& bundleName)
38 : LocaleKeyFactory(VISIBLE)
39 , _bundleName(bundleName)
43 ICUResourceBundleFactory::~ICUResourceBundleFactory() {}
46 ICUResourceBundleFactory::getSupportedIDs(UErrorCode& status) const
48 if (U_SUCCESS(status)) {
49 return LocaleUtility::getAvailableLocaleNames(_bundleName);
55 ICUResourceBundleFactory::handleCreate(const Locale& loc, int32_t /* kind */, const ICUService* /* service */, UErrorCode& status) const
57 if (U_SUCCESS(status)) {
58 // _bundleName is a package name
59 // and should only contain invariant characters
60 // ??? is it always true that the max length of the bundle name is 19?
61 // who made this change? -- dlf
64 length=_bundleName.extract(0, INT32_MAX, pkg, (int32_t)sizeof(pkg), US_INV);
65 if(length>=(int32_t)sizeof(pkg)) {
68 return new ResourceBundle(pkg, loc, status);
75 ICUResourceBundleFactory::debug(UnicodeString& result) const
77 LocaleKeyFactory::debug(result);
78 result.append((UnicodeString)", bundle: ");
79 return result.append(_bundleName);
83 ICUResourceBundleFactory::debugClass(UnicodeString& result) const
85 return result.append((UnicodeString)"ICUResourceBundleFactory");
89 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ICUResourceBundleFactory)
93 /* !UCONFIG_NO_SERVICE */