]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/servlkf.cpp
2 *******************************************************************************
3 * Copyright (C) 2001-2005, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
7 *******************************************************************************
9 #include "unicode/utypes.h"
11 #if !UCONFIG_NO_SERVICE
13 #include "unicode/resbund.h"
23 #define UNDERSCORE_CHAR ((UChar)0x005f)
24 #define AT_SIGN_CHAR ((UChar)64)
25 #define PERIOD_CHAR ((UChar)46)
30 LocaleKeyFactory::LocaleKeyFactory(int32_t coverage
)
36 LocaleKeyFactory::LocaleKeyFactory(int32_t coverage
, const UnicodeString
& name
)
42 LocaleKeyFactory::~LocaleKeyFactory() {
46 LocaleKeyFactory::create(const ICUServiceKey
& key
, const ICUService
* service
, UErrorCode
& status
) const {
47 if (handlesKey(key
, status
)) {
48 const LocaleKey
& lkey
= (const LocaleKey
&)key
;
49 int32_t kind
= lkey
.kind();
51 lkey
.currentLocale(loc
);
53 return handleCreate(loc
, kind
, service
, status
);
59 LocaleKeyFactory::handlesKey(const ICUServiceKey
& key
, UErrorCode
& status
) const {
60 const Hashtable
* supported
= getSupportedIDs(status
);
64 return supported
->get(id
) != NULL
;
70 LocaleKeyFactory::updateVisibleIDs(Hashtable
& result
, UErrorCode
& status
) const {
71 const Hashtable
* supported
= getSupportedIDs(status
);
73 UBool visible
= (_coverage
& 0x1) == 0;
75 const UHashElement
* elem
= NULL
;
77 while ((elem
= supported
->nextElement(pos
)) != NULL
) {
78 const UnicodeString
& id
= *((const UnicodeString
*)elem
->key
.pointer
);
82 result
.put(id
, (void*)this, status
); // this is dummy non-void marker used for set semantics
83 if (U_FAILURE(status
)) {
92 LocaleKeyFactory::getDisplayName(const UnicodeString
& id
, const Locale
& locale
, UnicodeString
& result
) const {
93 if ((_coverage
& 0x1) == 0) {
94 //UErrorCode status = U_ZERO_ERROR;
95 // assume if this is called on us, we support some fallback of this id
96 // if (isSupportedID(id, status)) {
98 LocaleUtility::initLocaleFromName(id
, loc
);
99 return loc
.getDisplayName(locale
, result
);
107 LocaleKeyFactory::handleCreate(const Locale
& /* loc */,
109 const ICUService
* /* service */,
110 UErrorCode
& /* status */) const {
115 //LocaleKeyFactory::isSupportedID(const UnicodeString& id, UErrorCode& status) const {
116 // const Hashtable* ids = getSupportedIDs(status);
117 // return ids && ids->get(id);
121 LocaleKeyFactory::getSupportedIDs(UErrorCode
& /* status */) const {
127 LocaleKeyFactory::debug(UnicodeString
& result
) const
130 result
.append(", name: ");
131 result
.append(_name
);
132 result
.append(", coverage: ");
133 result
.append(_coverage
);
138 LocaleKeyFactory::debugClass(UnicodeString
& result
) const
140 return result
.append("LocaleKeyFactory");
144 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(LocaleKeyFactory
)
148 /* !UCONFIG_NO_SERVICE */