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