1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/common/servrbf.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,94 @@ 1.4 +/** 1.5 + ******************************************************************************* 1.6 + * Copyright (C) 2001-2005, International Business Machines Corporation and * 1.7 + * others. All Rights Reserved. * 1.8 + ******************************************************************************* 1.9 + * 1.10 + ******************************************************************************* 1.11 + */ 1.12 +#include "unicode/utypes.h" 1.13 + 1.14 +#if !UCONFIG_NO_SERVICE 1.15 + 1.16 +#include "unicode/resbund.h" 1.17 +#include "uresimp.h" 1.18 +#include "cmemory.h" 1.19 +#include "servloc.h" 1.20 +#include "ustrfmt.h" 1.21 +#include "uhash.h" 1.22 +#include "charstr.h" 1.23 +#include "ucln_cmn.h" 1.24 +#include "uassert.h" 1.25 + 1.26 +#define UNDERSCORE_CHAR ((UChar)0x005f) 1.27 +#define AT_SIGN_CHAR ((UChar)64) 1.28 +#define PERIOD_CHAR ((UChar)46) 1.29 + 1.30 +U_NAMESPACE_BEGIN 1.31 + 1.32 +ICUResourceBundleFactory::ICUResourceBundleFactory() 1.33 + : LocaleKeyFactory(VISIBLE) 1.34 + , _bundleName() 1.35 +{ 1.36 +} 1.37 + 1.38 +ICUResourceBundleFactory::ICUResourceBundleFactory(const UnicodeString& bundleName) 1.39 + : LocaleKeyFactory(VISIBLE) 1.40 + , _bundleName(bundleName) 1.41 +{ 1.42 +} 1.43 + 1.44 +ICUResourceBundleFactory::~ICUResourceBundleFactory() {} 1.45 + 1.46 +const Hashtable* 1.47 +ICUResourceBundleFactory::getSupportedIDs(UErrorCode& status) const 1.48 +{ 1.49 + if (U_SUCCESS(status)) { 1.50 + return LocaleUtility::getAvailableLocaleNames(_bundleName); 1.51 + } 1.52 + return NULL; 1.53 +} 1.54 + 1.55 +UObject* 1.56 +ICUResourceBundleFactory::handleCreate(const Locale& loc, int32_t /* kind */, const ICUService* /* service */, UErrorCode& status) const 1.57 +{ 1.58 + if (U_SUCCESS(status)) { 1.59 + // _bundleName is a package name 1.60 + // and should only contain invariant characters 1.61 + // ??? is it always true that the max length of the bundle name is 19? 1.62 + // who made this change? -- dlf 1.63 + char pkg[20]; 1.64 + int32_t length; 1.65 + length=_bundleName.extract(0, INT32_MAX, pkg, (int32_t)sizeof(pkg), US_INV); 1.66 + if(length>=(int32_t)sizeof(pkg)) { 1.67 + return NULL; 1.68 + } 1.69 + return new ResourceBundle(pkg, loc, status); 1.70 + } 1.71 + return NULL; 1.72 +} 1.73 + 1.74 +#ifdef SERVICE_DEBUG 1.75 +UnicodeString& 1.76 +ICUResourceBundleFactory::debug(UnicodeString& result) const 1.77 +{ 1.78 + LocaleKeyFactory::debug(result); 1.79 + result.append(", bundle: "); 1.80 + return result.append(_bundleName); 1.81 +} 1.82 + 1.83 +UnicodeString& 1.84 +ICUResourceBundleFactory::debugClass(UnicodeString& result) const 1.85 +{ 1.86 + return result.append("ICUResourceBundleFactory"); 1.87 +} 1.88 +#endif 1.89 + 1.90 +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ICUResourceBundleFactory) 1.91 + 1.92 +U_NAMESPACE_END 1.93 + 1.94 +/* !UCONFIG_NO_SERVICE */ 1.95 +#endif 1.96 + 1.97 +