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