Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /** |
michael@0 | 2 | ******************************************************************************* |
michael@0 | 3 | * Copyright (C) 2001-2011, 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 | #ifndef ICULSERV_H |
michael@0 | 10 | #define ICULSERV_H |
michael@0 | 11 | |
michael@0 | 12 | #include "unicode/utypes.h" |
michael@0 | 13 | |
michael@0 | 14 | #if UCONFIG_NO_SERVICE |
michael@0 | 15 | |
michael@0 | 16 | U_NAMESPACE_BEGIN |
michael@0 | 17 | |
michael@0 | 18 | /* |
michael@0 | 19 | * Allow the declaration of APIs with pointers to ICUService |
michael@0 | 20 | * even when service is removed from the build. |
michael@0 | 21 | */ |
michael@0 | 22 | class ICULocaleService; |
michael@0 | 23 | |
michael@0 | 24 | U_NAMESPACE_END |
michael@0 | 25 | |
michael@0 | 26 | #else |
michael@0 | 27 | |
michael@0 | 28 | #include "unicode/unistr.h" |
michael@0 | 29 | #include "unicode/locid.h" |
michael@0 | 30 | #include "unicode/strenum.h" |
michael@0 | 31 | |
michael@0 | 32 | #include "hash.h" |
michael@0 | 33 | #include "uvector.h" |
michael@0 | 34 | |
michael@0 | 35 | #include "serv.h" |
michael@0 | 36 | #include "locutil.h" |
michael@0 | 37 | |
michael@0 | 38 | U_NAMESPACE_BEGIN |
michael@0 | 39 | |
michael@0 | 40 | class ICULocaleService; |
michael@0 | 41 | |
michael@0 | 42 | class LocaleKey; |
michael@0 | 43 | class LocaleKeyFactory; |
michael@0 | 44 | class SimpleLocaleKeyFactory; |
michael@0 | 45 | class ServiceListener; |
michael@0 | 46 | |
michael@0 | 47 | /* |
michael@0 | 48 | ****************************************************************** |
michael@0 | 49 | */ |
michael@0 | 50 | |
michael@0 | 51 | /** |
michael@0 | 52 | * A subclass of Key that implements a locale fallback mechanism. |
michael@0 | 53 | * The first locale to search for is the locale provided by the |
michael@0 | 54 | * client, and the fallback locale to search for is the current |
michael@0 | 55 | * default locale. If a prefix is present, the currentDescriptor |
michael@0 | 56 | * includes it before the locale proper, separated by "/". This |
michael@0 | 57 | * is the default key instantiated by ICULocaleService.</p> |
michael@0 | 58 | * |
michael@0 | 59 | * <p>Canonicalization adjusts the locale string so that the |
michael@0 | 60 | * section before the first understore is in lower case, and the rest |
michael@0 | 61 | * is in upper case, with no trailing underscores.</p> |
michael@0 | 62 | */ |
michael@0 | 63 | |
michael@0 | 64 | class U_COMMON_API LocaleKey : public ICUServiceKey { |
michael@0 | 65 | private: |
michael@0 | 66 | int32_t _kind; |
michael@0 | 67 | UnicodeString _primaryID; |
michael@0 | 68 | UnicodeString _fallbackID; |
michael@0 | 69 | UnicodeString _currentID; |
michael@0 | 70 | |
michael@0 | 71 | public: |
michael@0 | 72 | enum { |
michael@0 | 73 | KIND_ANY = -1 |
michael@0 | 74 | }; |
michael@0 | 75 | |
michael@0 | 76 | /** |
michael@0 | 77 | * Create a LocaleKey with canonical primary and fallback IDs. |
michael@0 | 78 | */ |
michael@0 | 79 | static LocaleKey* createWithCanonicalFallback(const UnicodeString* primaryID, |
michael@0 | 80 | const UnicodeString* canonicalFallbackID, |
michael@0 | 81 | UErrorCode& status); |
michael@0 | 82 | |
michael@0 | 83 | /** |
michael@0 | 84 | * Create a LocaleKey with canonical primary and fallback IDs. |
michael@0 | 85 | */ |
michael@0 | 86 | static LocaleKey* createWithCanonicalFallback(const UnicodeString* primaryID, |
michael@0 | 87 | const UnicodeString* canonicalFallbackID, |
michael@0 | 88 | int32_t kind, |
michael@0 | 89 | UErrorCode& status); |
michael@0 | 90 | |
michael@0 | 91 | protected: |
michael@0 | 92 | /** |
michael@0 | 93 | * PrimaryID is the user's requested locale string, |
michael@0 | 94 | * canonicalPrimaryID is this string in canonical form, |
michael@0 | 95 | * fallbackID is the current default locale's string in |
michael@0 | 96 | * canonical form. |
michael@0 | 97 | */ |
michael@0 | 98 | LocaleKey(const UnicodeString& primaryID, |
michael@0 | 99 | const UnicodeString& canonicalPrimaryID, |
michael@0 | 100 | const UnicodeString* canonicalFallbackID, |
michael@0 | 101 | int32_t kind); |
michael@0 | 102 | |
michael@0 | 103 | public: |
michael@0 | 104 | /** |
michael@0 | 105 | * Append the prefix associated with the kind, or nothing if the kind is KIND_ANY. |
michael@0 | 106 | */ |
michael@0 | 107 | virtual UnicodeString& prefix(UnicodeString& result) const; |
michael@0 | 108 | |
michael@0 | 109 | /** |
michael@0 | 110 | * Return the kind code associated with this key. |
michael@0 | 111 | */ |
michael@0 | 112 | virtual int32_t kind() const; |
michael@0 | 113 | |
michael@0 | 114 | /** |
michael@0 | 115 | * Return the canonicalID. |
michael@0 | 116 | */ |
michael@0 | 117 | virtual UnicodeString& canonicalID(UnicodeString& result) const; |
michael@0 | 118 | |
michael@0 | 119 | /** |
michael@0 | 120 | * Return the currentID. |
michael@0 | 121 | */ |
michael@0 | 122 | virtual UnicodeString& currentID(UnicodeString& result) const; |
michael@0 | 123 | |
michael@0 | 124 | /** |
michael@0 | 125 | * Return the (canonical) current descriptor, or null if no current id. |
michael@0 | 126 | */ |
michael@0 | 127 | virtual UnicodeString& currentDescriptor(UnicodeString& result) const; |
michael@0 | 128 | |
michael@0 | 129 | /** |
michael@0 | 130 | * Convenience method to return the locale corresponding to the (canonical) original ID. |
michael@0 | 131 | */ |
michael@0 | 132 | virtual Locale& canonicalLocale(Locale& result) const; |
michael@0 | 133 | |
michael@0 | 134 | /** |
michael@0 | 135 | * Convenience method to return the locale corresponding to the (canonical) current ID. |
michael@0 | 136 | */ |
michael@0 | 137 | virtual Locale& currentLocale(Locale& result) const; |
michael@0 | 138 | |
michael@0 | 139 | /** |
michael@0 | 140 | * If the key has a fallback, modify the key and return true, |
michael@0 | 141 | * otherwise return false.</p> |
michael@0 | 142 | * |
michael@0 | 143 | * <p>First falls back through the primary ID, then through |
michael@0 | 144 | * the fallbackID. The final fallback is the empty string, |
michael@0 | 145 | * unless the primary id was the empty string, in which case |
michael@0 | 146 | * there is no fallback. |
michael@0 | 147 | */ |
michael@0 | 148 | virtual UBool fallback(); |
michael@0 | 149 | |
michael@0 | 150 | /** |
michael@0 | 151 | * Return true if a key created from id matches, or would eventually |
michael@0 | 152 | * fallback to match, the canonical ID of this key. |
michael@0 | 153 | */ |
michael@0 | 154 | virtual UBool isFallbackOf(const UnicodeString& id) const; |
michael@0 | 155 | |
michael@0 | 156 | public: |
michael@0 | 157 | /** |
michael@0 | 158 | * UObject boilerplate. |
michael@0 | 159 | */ |
michael@0 | 160 | static UClassID U_EXPORT2 getStaticClassID(); |
michael@0 | 161 | |
michael@0 | 162 | virtual UClassID getDynamicClassID() const; |
michael@0 | 163 | |
michael@0 | 164 | /** |
michael@0 | 165 | * Destructor. |
michael@0 | 166 | */ |
michael@0 | 167 | virtual ~LocaleKey(); |
michael@0 | 168 | |
michael@0 | 169 | #ifdef SERVICE_DEBUG |
michael@0 | 170 | public: |
michael@0 | 171 | virtual UnicodeString& debug(UnicodeString& result) const; |
michael@0 | 172 | virtual UnicodeString& debugClass(UnicodeString& result) const; |
michael@0 | 173 | #endif |
michael@0 | 174 | |
michael@0 | 175 | }; |
michael@0 | 176 | |
michael@0 | 177 | /* |
michael@0 | 178 | ****************************************************************** |
michael@0 | 179 | */ |
michael@0 | 180 | |
michael@0 | 181 | /** |
michael@0 | 182 | * A subclass of ICUServiceFactory that uses LocaleKeys, and is able to |
michael@0 | 183 | * 'cover' more specific locales with more general locales that it |
michael@0 | 184 | * supports. |
michael@0 | 185 | * |
michael@0 | 186 | * <p>Coverage may be either of the values VISIBLE or INVISIBLE. |
michael@0 | 187 | * |
michael@0 | 188 | * <p>'Visible' indicates that the specific locale(s) supported by |
michael@0 | 189 | * the factory are registered in getSupportedIDs, 'Invisible' |
michael@0 | 190 | * indicates that they are not. |
michael@0 | 191 | * |
michael@0 | 192 | * <p>Localization of visible ids is handled |
michael@0 | 193 | * by the handling factory, regardless of kind. |
michael@0 | 194 | */ |
michael@0 | 195 | class U_COMMON_API LocaleKeyFactory : public ICUServiceFactory { |
michael@0 | 196 | protected: |
michael@0 | 197 | const UnicodeString _name; |
michael@0 | 198 | const int32_t _coverage; |
michael@0 | 199 | |
michael@0 | 200 | public: |
michael@0 | 201 | enum { |
michael@0 | 202 | /** |
michael@0 | 203 | * Coverage value indicating that the factory makes |
michael@0 | 204 | * its locales visible, and does not cover more specific |
michael@0 | 205 | * locales. |
michael@0 | 206 | */ |
michael@0 | 207 | VISIBLE = 0, |
michael@0 | 208 | |
michael@0 | 209 | /** |
michael@0 | 210 | * Coverage value indicating that the factory does not make |
michael@0 | 211 | * its locales visible, and does not cover more specific |
michael@0 | 212 | * locales. |
michael@0 | 213 | */ |
michael@0 | 214 | INVISIBLE = 1 |
michael@0 | 215 | }; |
michael@0 | 216 | |
michael@0 | 217 | /** |
michael@0 | 218 | * Destructor. |
michael@0 | 219 | */ |
michael@0 | 220 | virtual ~LocaleKeyFactory(); |
michael@0 | 221 | |
michael@0 | 222 | protected: |
michael@0 | 223 | /** |
michael@0 | 224 | * Constructor used by subclasses. |
michael@0 | 225 | */ |
michael@0 | 226 | LocaleKeyFactory(int32_t coverage); |
michael@0 | 227 | |
michael@0 | 228 | /** |
michael@0 | 229 | * Constructor used by subclasses. |
michael@0 | 230 | */ |
michael@0 | 231 | LocaleKeyFactory(int32_t coverage, const UnicodeString& name); |
michael@0 | 232 | |
michael@0 | 233 | /** |
michael@0 | 234 | * Implement superclass abstract method. This checks the currentID of |
michael@0 | 235 | * the key against the supported IDs, and passes the canonicalLocale and |
michael@0 | 236 | * kind off to handleCreate (which subclasses must implement). |
michael@0 | 237 | */ |
michael@0 | 238 | public: |
michael@0 | 239 | virtual UObject* create(const ICUServiceKey& key, const ICUService* service, UErrorCode& status) const; |
michael@0 | 240 | |
michael@0 | 241 | protected: |
michael@0 | 242 | virtual UBool handlesKey(const ICUServiceKey& key, UErrorCode& status) const; |
michael@0 | 243 | |
michael@0 | 244 | public: |
michael@0 | 245 | /** |
michael@0 | 246 | * Override of superclass method. This adjusts the result based |
michael@0 | 247 | * on the coverage rule for this factory. |
michael@0 | 248 | */ |
michael@0 | 249 | virtual void updateVisibleIDs(Hashtable& result, UErrorCode& status) const; |
michael@0 | 250 | |
michael@0 | 251 | /** |
michael@0 | 252 | * Return a localized name for the locale represented by id. |
michael@0 | 253 | */ |
michael@0 | 254 | virtual UnicodeString& getDisplayName(const UnicodeString& id, const Locale& locale, UnicodeString& result) const; |
michael@0 | 255 | |
michael@0 | 256 | protected: |
michael@0 | 257 | /** |
michael@0 | 258 | * Utility method used by create(ICUServiceKey, ICUService). Subclasses can implement |
michael@0 | 259 | * this instead of create. The default returns NULL. |
michael@0 | 260 | */ |
michael@0 | 261 | virtual UObject* handleCreate(const Locale& loc, int32_t kind, const ICUService* service, UErrorCode& status) const; |
michael@0 | 262 | |
michael@0 | 263 | /** |
michael@0 | 264 | * Return true if this id is one the factory supports (visible or |
michael@0 | 265 | * otherwise). |
michael@0 | 266 | */ |
michael@0 | 267 | // virtual UBool isSupportedID(const UnicodeString& id, UErrorCode& status) const; |
michael@0 | 268 | |
michael@0 | 269 | /** |
michael@0 | 270 | * Return the set of ids that this factory supports (visible or |
michael@0 | 271 | * otherwise). This can be called often and might need to be |
michael@0 | 272 | * cached if it is expensive to create. |
michael@0 | 273 | */ |
michael@0 | 274 | virtual const Hashtable* getSupportedIDs(UErrorCode& status) const; |
michael@0 | 275 | |
michael@0 | 276 | public: |
michael@0 | 277 | /** |
michael@0 | 278 | * UObject boilerplate. |
michael@0 | 279 | */ |
michael@0 | 280 | static UClassID U_EXPORT2 getStaticClassID(); |
michael@0 | 281 | |
michael@0 | 282 | virtual UClassID getDynamicClassID() const; |
michael@0 | 283 | |
michael@0 | 284 | #ifdef SERVICE_DEBUG |
michael@0 | 285 | public: |
michael@0 | 286 | virtual UnicodeString& debug(UnicodeString& result) const; |
michael@0 | 287 | virtual UnicodeString& debugClass(UnicodeString& result) const; |
michael@0 | 288 | #endif |
michael@0 | 289 | |
michael@0 | 290 | }; |
michael@0 | 291 | |
michael@0 | 292 | /* |
michael@0 | 293 | ****************************************************************** |
michael@0 | 294 | */ |
michael@0 | 295 | |
michael@0 | 296 | /** |
michael@0 | 297 | * A LocaleKeyFactory that just returns a single object for a kind/locale. |
michael@0 | 298 | */ |
michael@0 | 299 | |
michael@0 | 300 | class U_COMMON_API SimpleLocaleKeyFactory : public LocaleKeyFactory { |
michael@0 | 301 | private: |
michael@0 | 302 | UObject* _obj; |
michael@0 | 303 | UnicodeString _id; |
michael@0 | 304 | const int32_t _kind; |
michael@0 | 305 | |
michael@0 | 306 | public: |
michael@0 | 307 | SimpleLocaleKeyFactory(UObject* objToAdopt, |
michael@0 | 308 | const UnicodeString& locale, |
michael@0 | 309 | int32_t kind, |
michael@0 | 310 | int32_t coverage); |
michael@0 | 311 | |
michael@0 | 312 | SimpleLocaleKeyFactory(UObject* objToAdopt, |
michael@0 | 313 | const Locale& locale, |
michael@0 | 314 | int32_t kind, |
michael@0 | 315 | int32_t coverage); |
michael@0 | 316 | |
michael@0 | 317 | /** |
michael@0 | 318 | * Destructor. |
michael@0 | 319 | */ |
michael@0 | 320 | virtual ~SimpleLocaleKeyFactory(); |
michael@0 | 321 | |
michael@0 | 322 | /** |
michael@0 | 323 | * Override of superclass method. Returns the service object if kind/locale match. Service is not used. |
michael@0 | 324 | */ |
michael@0 | 325 | virtual UObject* create(const ICUServiceKey& key, const ICUService* service, UErrorCode& status) const; |
michael@0 | 326 | |
michael@0 | 327 | /** |
michael@0 | 328 | * Override of superclass method. This adjusts the result based |
michael@0 | 329 | * on the coverage rule for this factory. |
michael@0 | 330 | */ |
michael@0 | 331 | virtual void updateVisibleIDs(Hashtable& result, UErrorCode& status) const; |
michael@0 | 332 | |
michael@0 | 333 | protected: |
michael@0 | 334 | /** |
michael@0 | 335 | * Return true if this id is equal to the locale name. |
michael@0 | 336 | */ |
michael@0 | 337 | //virtual UBool isSupportedID(const UnicodeString& id, UErrorCode& status) const; |
michael@0 | 338 | |
michael@0 | 339 | |
michael@0 | 340 | public: |
michael@0 | 341 | /** |
michael@0 | 342 | * UObject boilerplate. |
michael@0 | 343 | */ |
michael@0 | 344 | static UClassID U_EXPORT2 getStaticClassID(); |
michael@0 | 345 | |
michael@0 | 346 | virtual UClassID getDynamicClassID() const; |
michael@0 | 347 | |
michael@0 | 348 | #ifdef SERVICE_DEBUG |
michael@0 | 349 | public: |
michael@0 | 350 | virtual UnicodeString& debug(UnicodeString& result) const; |
michael@0 | 351 | virtual UnicodeString& debugClass(UnicodeString& result) const; |
michael@0 | 352 | #endif |
michael@0 | 353 | |
michael@0 | 354 | }; |
michael@0 | 355 | |
michael@0 | 356 | /* |
michael@0 | 357 | ****************************************************************** |
michael@0 | 358 | */ |
michael@0 | 359 | |
michael@0 | 360 | /** |
michael@0 | 361 | * A LocaleKeyFactory that creates a service based on the ICU locale data. |
michael@0 | 362 | * This is a base class for most ICU factories. Subclasses instantiate it |
michael@0 | 363 | * with a constructor that takes a bundle name, which determines the supported |
michael@0 | 364 | * IDs. Subclasses then override handleCreate to create the actual service |
michael@0 | 365 | * object. The default implementation returns a resource bundle. |
michael@0 | 366 | */ |
michael@0 | 367 | class U_COMMON_API ICUResourceBundleFactory : public LocaleKeyFactory |
michael@0 | 368 | { |
michael@0 | 369 | protected: |
michael@0 | 370 | UnicodeString _bundleName; |
michael@0 | 371 | |
michael@0 | 372 | public: |
michael@0 | 373 | /** |
michael@0 | 374 | * Convenience constructor that uses the main ICU bundle name. |
michael@0 | 375 | */ |
michael@0 | 376 | ICUResourceBundleFactory(); |
michael@0 | 377 | |
michael@0 | 378 | /** |
michael@0 | 379 | * A service factory based on ICU resource data in resources with |
michael@0 | 380 | * the given name. This should be a 'path' that can be passed to |
michael@0 | 381 | * ures_openAvailableLocales, such as U_ICUDATA or U_ICUDATA_COLL. |
michael@0 | 382 | * The empty string is equivalent to U_ICUDATA. |
michael@0 | 383 | */ |
michael@0 | 384 | ICUResourceBundleFactory(const UnicodeString& bundleName); |
michael@0 | 385 | |
michael@0 | 386 | /** |
michael@0 | 387 | * Destructor |
michael@0 | 388 | */ |
michael@0 | 389 | virtual ~ICUResourceBundleFactory(); |
michael@0 | 390 | |
michael@0 | 391 | protected: |
michael@0 | 392 | /** |
michael@0 | 393 | * Return the supported IDs. This is the set of all locale names in ICULocaleData. |
michael@0 | 394 | */ |
michael@0 | 395 | virtual const Hashtable* getSupportedIDs(UErrorCode& status) const; |
michael@0 | 396 | |
michael@0 | 397 | /** |
michael@0 | 398 | * Create the service. The default implementation returns the resource bundle |
michael@0 | 399 | * for the locale, ignoring kind, and service. |
michael@0 | 400 | */ |
michael@0 | 401 | virtual UObject* handleCreate(const Locale& loc, int32_t kind, const ICUService* service, UErrorCode& status) const; |
michael@0 | 402 | |
michael@0 | 403 | public: |
michael@0 | 404 | /** |
michael@0 | 405 | * UObject boilerplate. |
michael@0 | 406 | */ |
michael@0 | 407 | static UClassID U_EXPORT2 getStaticClassID(); |
michael@0 | 408 | virtual UClassID getDynamicClassID() const; |
michael@0 | 409 | |
michael@0 | 410 | |
michael@0 | 411 | #ifdef SERVICE_DEBUG |
michael@0 | 412 | public: |
michael@0 | 413 | virtual UnicodeString& debug(UnicodeString& result) const; |
michael@0 | 414 | virtual UnicodeString& debugClass(UnicodeString& result) const; |
michael@0 | 415 | #endif |
michael@0 | 416 | |
michael@0 | 417 | }; |
michael@0 | 418 | |
michael@0 | 419 | /* |
michael@0 | 420 | ****************************************************************** |
michael@0 | 421 | */ |
michael@0 | 422 | |
michael@0 | 423 | class U_COMMON_API ICULocaleService : public ICUService |
michael@0 | 424 | { |
michael@0 | 425 | private: |
michael@0 | 426 | Locale fallbackLocale; |
michael@0 | 427 | UnicodeString fallbackLocaleName; |
michael@0 | 428 | |
michael@0 | 429 | public: |
michael@0 | 430 | /** |
michael@0 | 431 | * Construct an ICULocaleService. |
michael@0 | 432 | */ |
michael@0 | 433 | ICULocaleService(); |
michael@0 | 434 | |
michael@0 | 435 | /** |
michael@0 | 436 | * Construct an ICULocaleService with a name (useful for debugging). |
michael@0 | 437 | */ |
michael@0 | 438 | ICULocaleService(const UnicodeString& name); |
michael@0 | 439 | |
michael@0 | 440 | /** |
michael@0 | 441 | * Destructor. |
michael@0 | 442 | */ |
michael@0 | 443 | virtual ~ICULocaleService(); |
michael@0 | 444 | |
michael@0 | 445 | #if 0 |
michael@0 | 446 | // redeclare because of overload resolution rules? |
michael@0 | 447 | // no, causes ambiguities since both UnicodeString and Locale have constructors that take a const char* |
michael@0 | 448 | // need some compiler flag to remove warnings |
michael@0 | 449 | UObject* get(const UnicodeString& descriptor, UErrorCode& status) const { |
michael@0 | 450 | return ICUService::get(descriptor, status); |
michael@0 | 451 | } |
michael@0 | 452 | |
michael@0 | 453 | UObject* get(const UnicodeString& descriptor, UnicodeString* actualReturn, UErrorCode& status) const { |
michael@0 | 454 | return ICUService::get(descriptor, actualReturn, status); |
michael@0 | 455 | } |
michael@0 | 456 | #endif |
michael@0 | 457 | |
michael@0 | 458 | /** |
michael@0 | 459 | * Convenience override for callers using locales. This calls |
michael@0 | 460 | * get(Locale, int, Locale[]) with KIND_ANY for kind and null for |
michael@0 | 461 | * actualReturn. |
michael@0 | 462 | */ |
michael@0 | 463 | UObject* get(const Locale& locale, UErrorCode& status) const; |
michael@0 | 464 | |
michael@0 | 465 | /** |
michael@0 | 466 | * Convenience override for callers using locales. This calls |
michael@0 | 467 | * get(Locale, int, Locale[]) with a null actualReturn. |
michael@0 | 468 | */ |
michael@0 | 469 | UObject* get(const Locale& locale, int32_t kind, UErrorCode& status) const; |
michael@0 | 470 | |
michael@0 | 471 | /** |
michael@0 | 472 | * Convenience override for callers using locales. This calls |
michael@0 | 473 | * get(Locale, String, Locale[]) with a null kind. |
michael@0 | 474 | */ |
michael@0 | 475 | UObject* get(const Locale& locale, Locale* actualReturn, UErrorCode& status) const; |
michael@0 | 476 | |
michael@0 | 477 | /** |
michael@0 | 478 | * Convenience override for callers using locales. This uses |
michael@0 | 479 | * createKey(Locale.toString(), kind) to create a key, calls getKey, and then |
michael@0 | 480 | * if actualReturn is not null, returns the actualResult from |
michael@0 | 481 | * getKey (stripping any prefix) into a Locale. |
michael@0 | 482 | */ |
michael@0 | 483 | UObject* get(const Locale& locale, int32_t kind, Locale* actualReturn, UErrorCode& status) const; |
michael@0 | 484 | |
michael@0 | 485 | /** |
michael@0 | 486 | * Convenience override for callers using locales. This calls |
michael@0 | 487 | * registerObject(Object, Locale, int32_t kind, int coverage) |
michael@0 | 488 | * passing KIND_ANY for the kind, and VISIBLE for the coverage. |
michael@0 | 489 | */ |
michael@0 | 490 | virtual URegistryKey registerInstance(UObject* objToAdopt, const Locale& locale, UErrorCode& status); |
michael@0 | 491 | |
michael@0 | 492 | /** |
michael@0 | 493 | * Convenience function for callers using locales. This calls |
michael@0 | 494 | * registerObject(Object, Locale, int kind, int coverage) |
michael@0 | 495 | * passing VISIBLE for the coverage. |
michael@0 | 496 | */ |
michael@0 | 497 | virtual URegistryKey registerInstance(UObject* objToAdopt, const Locale& locale, int32_t kind, UErrorCode& status); |
michael@0 | 498 | |
michael@0 | 499 | /** |
michael@0 | 500 | * Convenience function for callers using locales. This instantiates |
michael@0 | 501 | * a SimpleLocaleKeyFactory, and registers the factory. |
michael@0 | 502 | */ |
michael@0 | 503 | virtual URegistryKey registerInstance(UObject* objToAdopt, const Locale& locale, int32_t kind, int32_t coverage, UErrorCode& status); |
michael@0 | 504 | |
michael@0 | 505 | |
michael@0 | 506 | /** |
michael@0 | 507 | * (Stop compiler from complaining about hidden overrides.) |
michael@0 | 508 | * Since both UnicodeString and Locale have constructors that take const char*, adding a public |
michael@0 | 509 | * method that takes UnicodeString causes ambiguity at call sites that use const char*. |
michael@0 | 510 | * We really need a flag that is understood by all compilers that will suppress the warning about |
michael@0 | 511 | * hidden overrides. |
michael@0 | 512 | */ |
michael@0 | 513 | virtual URegistryKey registerInstance(UObject* objToAdopt, const UnicodeString& locale, UBool visible, UErrorCode& status); |
michael@0 | 514 | |
michael@0 | 515 | /** |
michael@0 | 516 | * Convenience method for callers using locales. This returns the standard |
michael@0 | 517 | * service ID enumeration. |
michael@0 | 518 | */ |
michael@0 | 519 | virtual StringEnumeration* getAvailableLocales(void) const; |
michael@0 | 520 | |
michael@0 | 521 | protected: |
michael@0 | 522 | |
michael@0 | 523 | /** |
michael@0 | 524 | * Return the name of the current fallback locale. If it has changed since this was |
michael@0 | 525 | * last accessed, the service cache is cleared. |
michael@0 | 526 | */ |
michael@0 | 527 | const UnicodeString& validateFallbackLocale() const; |
michael@0 | 528 | |
michael@0 | 529 | /** |
michael@0 | 530 | * Override superclass createKey method. |
michael@0 | 531 | */ |
michael@0 | 532 | virtual ICUServiceKey* createKey(const UnicodeString* id, UErrorCode& status) const; |
michael@0 | 533 | |
michael@0 | 534 | /** |
michael@0 | 535 | * Additional createKey that takes a kind. |
michael@0 | 536 | */ |
michael@0 | 537 | virtual ICUServiceKey* createKey(const UnicodeString* id, int32_t kind, UErrorCode& status) const; |
michael@0 | 538 | |
michael@0 | 539 | friend class ServiceEnumeration; |
michael@0 | 540 | }; |
michael@0 | 541 | |
michael@0 | 542 | U_NAMESPACE_END |
michael@0 | 543 | |
michael@0 | 544 | /* UCONFIG_NO_SERVICE */ |
michael@0 | 545 | #endif |
michael@0 | 546 | |
michael@0 | 547 | /* ICULSERV_H */ |
michael@0 | 548 | #endif |
michael@0 | 549 |