|
1 /* |
|
2 ********************************************************************** |
|
3 * Copyright (C) 1997-2005, International Business Machines |
|
4 * Corporation and others. All Rights Reserved. |
|
5 ********************************************************************** |
|
6 * |
|
7 * File URES.H (formerly CRESBUND.H) |
|
8 * |
|
9 * Modification History: |
|
10 * |
|
11 * Date Name Description |
|
12 * 04/01/97 aliu Creation. |
|
13 * 02/22/99 damiba overhaul. |
|
14 * 04/04/99 helena Fixed internal header inclusion. |
|
15 * 04/15/99 Madhu Updated Javadoc |
|
16 * 06/14/99 stephen Removed functions taking a filename suffix. |
|
17 * 07/20/99 stephen Language-independent ypedef to void* |
|
18 * 11/09/99 weiv Added ures_getLocale() |
|
19 * 06/24/02 weiv Added support for resource sharing |
|
20 ****************************************************************************** |
|
21 */ |
|
22 |
|
23 #ifndef URES_H |
|
24 #define URES_H |
|
25 |
|
26 #include "unicode/utypes.h" |
|
27 #include "unicode/uloc.h" |
|
28 |
|
29 /** |
|
30 * \file |
|
31 * \brief C API: Resource Bundle |
|
32 * |
|
33 * <h2>C API: Resource Bundle</h2> |
|
34 * |
|
35 * C API representing a collection of resource information pertaining to a given |
|
36 * locale. A resource bundle provides a way of accessing locale- specific information in |
|
37 * a data file. You create a resource bundle that manages the resources for a given |
|
38 * locale and then ask it for individual resources. |
|
39 * <P> |
|
40 * Resource bundles in ICU4C are currently defined using text files which conform to the following |
|
41 * <a href="http://dev.icu-project.org/cgi-bin/viewcvs.cgi/~checkout~/icuhtml/design/bnf_rb.txt">BNF definition</a>. |
|
42 * More on resource bundle concepts and syntax can be found in the |
|
43 * <a href="http://icu.sourceforge.net/userguide/ResourceManagement.html">Users Guide</a>. |
|
44 * <P> |
|
45 */ |
|
46 |
|
47 /** |
|
48 * UResourceBundle is an opaque type for handles for resource bundles in C APIs. |
|
49 * @stable ICU 2.0 |
|
50 */ |
|
51 struct UResourceBundle; |
|
52 |
|
53 /** |
|
54 * @stable ICU 2.0 |
|
55 */ |
|
56 typedef struct UResourceBundle UResourceBundle; |
|
57 |
|
58 /** |
|
59 * Numeric constants for types of resource items. |
|
60 * @see ures_getType |
|
61 * @stable ICU 2.0 |
|
62 */ |
|
63 typedef enum { |
|
64 /** Resource type constant for "no resource". @stable ICU 2.6 */ |
|
65 URES_NONE=-1, |
|
66 |
|
67 /** Resource type constant for 16-bit Unicode strings. @stable ICU 2.6 */ |
|
68 URES_STRING=0, |
|
69 |
|
70 /** Resource type constant for binary data. @stable ICU 2.6 */ |
|
71 URES_BINARY=1, |
|
72 |
|
73 /** Resource type constant for tables of key-value pairs. @stable ICU 2.6 */ |
|
74 URES_TABLE=2, |
|
75 |
|
76 /** |
|
77 * Resource type constant for aliases; |
|
78 * internally stores a string which identifies the actual resource |
|
79 * storing the data (can be in a different resource bundle). |
|
80 * Resolved internally before delivering the actual resource through the API. |
|
81 * @stable ICU 2.6 |
|
82 */ |
|
83 URES_ALIAS=3, |
|
84 |
|
85 /** |
|
86 * Internal use only. |
|
87 * Alternative resource type constant for tables of key-value pairs. |
|
88 * Never returned by ures_getType(). |
|
89 * @internal |
|
90 */ |
|
91 URES_TABLE32=4, |
|
92 |
|
93 /** |
|
94 * Resource type constant for a single 28-bit integer, interpreted as |
|
95 * signed or unsigned by the ures_getInt() or ures_getUInt() function. |
|
96 * @see ures_getInt |
|
97 * @see ures_getUInt |
|
98 * @stable ICU 2.6 |
|
99 */ |
|
100 URES_INT=7, |
|
101 |
|
102 /** Resource type constant for arrays of resources. @stable ICU 2.6 */ |
|
103 URES_ARRAY=8, |
|
104 |
|
105 /** |
|
106 * Resource type constant for vectors of 32-bit integers. |
|
107 * @see ures_getIntVector |
|
108 * @stable ICU 2.6 |
|
109 */ |
|
110 URES_INT_VECTOR=14, |
|
111 |
|
112 #ifndef U_HIDE_DEPRECATED_API |
|
113 /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
|
114 RES_NONE=URES_NONE, |
|
115 /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
|
116 RES_STRING=URES_STRING, |
|
117 /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
|
118 RES_BINARY=URES_BINARY, |
|
119 /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
|
120 RES_TABLE=URES_TABLE, |
|
121 /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
|
122 RES_ALIAS=URES_ALIAS, |
|
123 /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
|
124 RES_INT=URES_INT, |
|
125 /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
|
126 RES_ARRAY=URES_ARRAY, |
|
127 /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
|
128 RES_INT_VECTOR=URES_INT_VECTOR, |
|
129 #endif /* U_HIDE_DEPRECATED_API */ |
|
130 |
|
131 /** @deprecated ICU 2.6 Not used. */ |
|
132 RES_RESERVED=15 |
|
133 } UResType; |
|
134 |
|
135 /* |
|
136 * Functions to create and destroy resource bundles. |
|
137 */ |
|
138 |
|
139 /** |
|
140 * Opens a UResourceBundle, from which users can extract strings by using |
|
141 * their corresponding keys. |
|
142 * Note that the caller is responsible of calling <TT>ures_close</TT> on each succesfully |
|
143 * opened resource bundle. |
|
144 * @param packageName The packageName and locale together point to an ICU udata object, |
|
145 * as defined by <code> udata_open( packageName, "res", locale, err) </code> |
|
146 * or equivalent. Typically, packageName will refer to a (.dat) file, or to |
|
147 * a package registered with udata_setAppData(). Using a full file or directory |
|
148 * pathname for packageName is deprecated. If NULL, ICU data will be used. |
|
149 * @param locale specifies the locale for which we want to open the resource |
|
150 * if NULL, the default locale will be used. If strlen(locale) == 0 |
|
151 * root locale will be used. |
|
152 * |
|
153 * @param status fills in the outgoing error code. |
|
154 * The UErrorCode err parameter is used to return status information to the user. To |
|
155 * check whether the construction succeeded or not, you should check the value of |
|
156 * U_SUCCESS(err). If you wish more detailed information, you can check for |
|
157 * informational status results which still indicate success. U_USING_FALLBACK_WARNING |
|
158 * indicates that a fall back locale was used. For example, 'de_CH' was requested, |
|
159 * but nothing was found there, so 'de' was used. U_USING_DEFAULT_WARNING indicates that |
|
160 * the default locale data or root locale data was used; neither the requested locale |
|
161 * nor any of its fall back locales could be found. Please see the users guide for more |
|
162 * information on this topic. |
|
163 * @return a newly allocated resource bundle. |
|
164 * @see ures_close |
|
165 * @stable ICU 2.0 |
|
166 */ |
|
167 U_STABLE UResourceBundle* U_EXPORT2 |
|
168 ures_open(const char* packageName, |
|
169 const char* locale, |
|
170 UErrorCode* status); |
|
171 |
|
172 |
|
173 /** This function does not care what kind of localeID is passed in. It simply opens a bundle with |
|
174 * that name. Fallback mechanism is disabled for the new bundle. If the requested bundle contains |
|
175 * an %%ALIAS directive, the results are undefined. |
|
176 * @param packageName The packageName and locale together point to an ICU udata object, |
|
177 * as defined by <code> udata_open( packageName, "res", locale, err) </code> |
|
178 * or equivalent. Typically, packageName will refer to a (.dat) file, or to |
|
179 * a package registered with udata_setAppData(). Using a full file or directory |
|
180 * pathname for packageName is deprecated. If NULL, ICU data will be used. |
|
181 * @param locale specifies the locale for which we want to open the resource |
|
182 * if NULL, the default locale will be used. If strlen(locale) == 0 |
|
183 * root locale will be used. |
|
184 * |
|
185 * @param status fills in the outgoing error code. Either U_ZERO_ERROR or U_MISSING_RESOURCE_ERROR |
|
186 * @return a newly allocated resource bundle or NULL if it doesn't exist. |
|
187 * @see ures_close |
|
188 * @stable ICU 2.0 |
|
189 */ |
|
190 U_STABLE UResourceBundle* U_EXPORT2 |
|
191 ures_openDirect(const char* packageName, |
|
192 const char* locale, |
|
193 UErrorCode* status); |
|
194 |
|
195 /** |
|
196 * Same as ures_open() but takes a const UChar *path. |
|
197 * This path will be converted to char * using the default converter, |
|
198 * then ures_open() is called. |
|
199 * |
|
200 * @param packageName The packageName and locale together point to an ICU udata object, |
|
201 * as defined by <code> udata_open( packageName, "res", locale, err) </code> |
|
202 * or equivalent. Typically, packageName will refer to a (.dat) file, or to |
|
203 * a package registered with udata_setAppData(). Using a full file or directory |
|
204 * pathname for packageName is deprecated. If NULL, ICU data will be used. |
|
205 * @param locale specifies the locale for which we want to open the resource |
|
206 * if NULL, the default locale will be used. If strlen(locale) == 0 |
|
207 * root locale will be used. |
|
208 * @param status fills in the outgoing error code. |
|
209 * @return a newly allocated resource bundle. |
|
210 * @see ures_open |
|
211 * @stable ICU 2.0 |
|
212 */ |
|
213 U_STABLE UResourceBundle* U_EXPORT2 |
|
214 ures_openU(const UChar* packageName, |
|
215 const char* locale, |
|
216 UErrorCode* status); |
|
217 |
|
218 /** |
|
219 * Returns the number of strings/arrays in resource bundles. |
|
220 * Better to use ures_getSize, as this function will be deprecated. |
|
221 * |
|
222 *@param resourceBundle resource bundle containing the desired strings |
|
223 *@param resourceKey key tagging the resource |
|
224 *@param err fills in the outgoing error code |
|
225 * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found |
|
226 * could be a non-failing error |
|
227 * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_FALLBACK_WARNING </TT> |
|
228 *@return: for <STRONG>Arrays</STRONG>: returns the number of resources in the array |
|
229 * <STRONG>Tables</STRONG>: returns the number of resources in the table |
|
230 * <STRONG>single string</STRONG>: returns 1 |
|
231 *@see ures_getSize |
|
232 * @deprecated ICU 2.8 User ures_getSize instead |
|
233 */ |
|
234 U_DEPRECATED int32_t U_EXPORT2 |
|
235 ures_countArrayItems(const UResourceBundle* resourceBundle, |
|
236 const char* resourceKey, |
|
237 UErrorCode* err); |
|
238 /** |
|
239 * Close a resource bundle, all pointers returned from the various ures_getXXX calls |
|
240 * on this particular bundle should be considered invalid henceforth. |
|
241 * |
|
242 * @param resourceBundle a pointer to a resourceBundle struct. Can be NULL. |
|
243 * @see ures_open |
|
244 * @stable ICU 2.0 |
|
245 */ |
|
246 U_STABLE void U_EXPORT2 |
|
247 ures_close(UResourceBundle* resourceBundle); |
|
248 |
|
249 /** |
|
250 * Return the version number associated with this ResourceBundle as a string. Please |
|
251 * use ures_getVersion as this function is going to be deprecated. |
|
252 * |
|
253 * @param resourceBundle The resource bundle for which the version is checked. |
|
254 * @return A version number string as specified in the resource bundle or its parent. |
|
255 * The caller does not own this string. |
|
256 * @see ures_getVersion |
|
257 * @deprecated ICU 2.8 Use ures_getVersion instead. |
|
258 */ |
|
259 U_DEPRECATED const char* U_EXPORT2 |
|
260 ures_getVersionNumber(const UResourceBundle* resourceBundle); |
|
261 |
|
262 /** |
|
263 * Return the version number associated with this ResourceBundle as an |
|
264 * UVersionInfo array. |
|
265 * |
|
266 * @param resB The resource bundle for which the version is checked. |
|
267 * @param versionInfo A UVersionInfo array that is filled with the version number |
|
268 * as specified in the resource bundle or its parent. |
|
269 * @stable ICU 2.0 |
|
270 */ |
|
271 U_STABLE void U_EXPORT2 |
|
272 ures_getVersion(const UResourceBundle* resB, |
|
273 UVersionInfo versionInfo); |
|
274 |
|
275 /** |
|
276 * Return the name of the Locale associated with this ResourceBundle. This API allows |
|
277 * you to query for the real locale of the resource. For example, if you requested |
|
278 * "en_US_CALIFORNIA" and only "en_US" bundle exists, "en_US" will be returned. |
|
279 * For subresources, the locale where this resource comes from will be returned. |
|
280 * If fallback has occured, getLocale will reflect this. |
|
281 * |
|
282 * @param resourceBundle resource bundle in question |
|
283 * @param status just for catching illegal arguments |
|
284 * @return A Locale name |
|
285 * @deprecated ICU 2.8 Use ures_getLocaleByType instead. |
|
286 */ |
|
287 U_DEPRECATED const char* U_EXPORT2 |
|
288 ures_getLocale(const UResourceBundle* resourceBundle, |
|
289 UErrorCode* status); |
|
290 |
|
291 |
|
292 /** |
|
293 * Return the name of the Locale associated with this ResourceBundle. |
|
294 * You can choose between requested, valid and real locale. |
|
295 * |
|
296 * @param resourceBundle resource bundle in question |
|
297 * @param type You can choose between requested, valid and actual |
|
298 * locale. For description see the definition of |
|
299 * ULocDataLocaleType in uloc.h |
|
300 * @param status just for catching illegal arguments |
|
301 * @return A Locale name |
|
302 * @draft ICU 2.8 likely to change in the future |
|
303 */ |
|
304 U_DRAFT const char* U_EXPORT2 |
|
305 ures_getLocaleByType(const UResourceBundle* resourceBundle, |
|
306 ULocDataLocaleType type, |
|
307 UErrorCode* status); |
|
308 |
|
309 |
|
310 /** |
|
311 * Same as ures_open() but uses the fill-in parameter instead of allocating |
|
312 * a bundle, if r!=NULL. |
|
313 * TODO need to revisit usefulness of this function |
|
314 * and usage model for fillIn parameters without knowing sizeof(UResourceBundle) |
|
315 * @param r The resourcebundle to open |
|
316 * @param packageName The packageName and locale together point to an ICU udata object, |
|
317 * as defined by <code> udata_open( packageName, "res", locale, err) </code> |
|
318 * or equivalent. Typically, packageName will refer to a (.dat) file, or to |
|
319 * a package registered with udata_setAppData(). Using a full file or directory |
|
320 * pathname for packageName is deprecated. If NULL, ICU data will be used. |
|
321 * @param localeID specifies the locale for which we want to open the resource |
|
322 * @param status The error code |
|
323 * @return a newly allocated resource bundle or NULL if it doesn't exist. |
|
324 * @internal |
|
325 */ |
|
326 U_INTERNAL void U_EXPORT2 |
|
327 ures_openFillIn(UResourceBundle *r, |
|
328 const char* packageName, |
|
329 const char* localeID, |
|
330 UErrorCode* status); |
|
331 |
|
332 /** |
|
333 * Returns a string from a string resource type |
|
334 * |
|
335 * @param resourceBundle a string resource |
|
336 * @param len fills in the length of resulting string |
|
337 * @param status fills in the outgoing error code |
|
338 * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found |
|
339 * Always check the value of status. Don't count on returning NULL. |
|
340 * could be a non-failing error |
|
341 * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT> |
|
342 * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file. |
|
343 * @see ures_getBinary |
|
344 * @see ures_getIntVector |
|
345 * @see ures_getInt |
|
346 * @see ures_getUInt |
|
347 * @stable ICU 2.0 |
|
348 */ |
|
349 U_STABLE const UChar* U_EXPORT2 |
|
350 ures_getString(const UResourceBundle* resourceBundle, |
|
351 int32_t* len, |
|
352 UErrorCode* status); |
|
353 |
|
354 /** |
|
355 * Returns a binary data from a binary resource. |
|
356 * |
|
357 * @param resourceBundle a string resource |
|
358 * @param len fills in the length of resulting byte chunk |
|
359 * @param status fills in the outgoing error code |
|
360 * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found |
|
361 * Always check the value of status. Don't count on returning NULL. |
|
362 * could be a non-failing error |
|
363 * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT> |
|
364 * @return a pointer to a chuck of unsigned bytes which live in a memory mapped/DLL file. |
|
365 * @see ures_getString |
|
366 * @see ures_getIntVector |
|
367 * @see ures_getInt |
|
368 * @see ures_getUInt |
|
369 * @stable ICU 2.0 |
|
370 */ |
|
371 U_STABLE const uint8_t* U_EXPORT2 |
|
372 ures_getBinary(const UResourceBundle* resourceBundle, |
|
373 int32_t* len, |
|
374 UErrorCode* status); |
|
375 |
|
376 /** |
|
377 * Returns a 32 bit integer array from a resource. |
|
378 * |
|
379 * @param resourceBundle an int vector resource |
|
380 * @param len fills in the length of resulting byte chunk |
|
381 * @param status fills in the outgoing error code |
|
382 * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found |
|
383 * Always check the value of status. Don't count on returning NULL. |
|
384 * could be a non-failing error |
|
385 * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT> |
|
386 * @return a pointer to a chunk of unsigned bytes which live in a memory mapped/DLL file. |
|
387 * @see ures_getBinary |
|
388 * @see ures_getString |
|
389 * @see ures_getInt |
|
390 * @see ures_getUInt |
|
391 * @stable ICU 2.0 |
|
392 */ |
|
393 U_STABLE const int32_t* U_EXPORT2 |
|
394 ures_getIntVector(const UResourceBundle* resourceBundle, |
|
395 int32_t* len, |
|
396 UErrorCode* status); |
|
397 |
|
398 /** |
|
399 * Returns an unsigned integer from a resource. |
|
400 * This integer is originally 28 bits. |
|
401 * |
|
402 * @param resourceBundle a string resource |
|
403 * @param status fills in the outgoing error code |
|
404 * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found |
|
405 * could be a non-failing error |
|
406 * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT> |
|
407 * @return an integer value |
|
408 * @see ures_getInt |
|
409 * @see ures_getIntVector |
|
410 * @see ures_getBinary |
|
411 * @see ures_getString |
|
412 * @stable ICU 2.0 |
|
413 */ |
|
414 U_STABLE uint32_t U_EXPORT2 |
|
415 ures_getUInt(const UResourceBundle* resourceBundle, |
|
416 UErrorCode *status); |
|
417 |
|
418 /** |
|
419 * Returns a signed integer from a resource. |
|
420 * This integer is originally 28 bit and the sign gets propagated. |
|
421 * |
|
422 * @param resourceBundle a string resource |
|
423 * @param status fills in the outgoing error code |
|
424 * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found |
|
425 * could be a non-failing error |
|
426 * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT> |
|
427 * @return an integer value |
|
428 * @see ures_getUInt |
|
429 * @see ures_getIntVector |
|
430 * @see ures_getBinary |
|
431 * @see ures_getString |
|
432 * @stable ICU 2.0 |
|
433 */ |
|
434 U_STABLE int32_t U_EXPORT2 |
|
435 ures_getInt(const UResourceBundle* resourceBundle, |
|
436 UErrorCode *status); |
|
437 |
|
438 /** |
|
439 * Returns the size of a resource. Size for scalar types is always 1, |
|
440 * and for vector/table types is the number of child resources. |
|
441 * @warning Integer array is treated as a scalar type. There are no |
|
442 * APIs to access individual members of an integer array. It |
|
443 * is always returned as a whole. |
|
444 * @param resourceBundle a resource |
|
445 * @return number of resources in a given resource. |
|
446 * @stable ICU 2.0 |
|
447 */ |
|
448 U_STABLE int32_t U_EXPORT2 |
|
449 ures_getSize(const UResourceBundle *resourceBundle); |
|
450 |
|
451 /** |
|
452 * Returns the type of a resource. Available types are defined in enum UResType |
|
453 * |
|
454 * @param resourceBundle a resource |
|
455 * @return type of the given resource. |
|
456 * @see UResType |
|
457 * @stable ICU 2.0 |
|
458 */ |
|
459 U_STABLE UResType U_EXPORT2 |
|
460 ures_getType(const UResourceBundle *resourceBundle); |
|
461 |
|
462 /** |
|
463 * Returns the key associated with a given resource. Not all the resources have a key - only |
|
464 * those that are members of a table. |
|
465 * |
|
466 * @param resourceBundle a resource |
|
467 * @return a key associated to this resource, or NULL if it doesn't have a key |
|
468 * @stable ICU 2.0 |
|
469 */ |
|
470 U_STABLE const char * U_EXPORT2 |
|
471 ures_getKey(const UResourceBundle *resourceBundle); |
|
472 |
|
473 /* ITERATION API |
|
474 This API provides means for iterating through a resource |
|
475 */ |
|
476 |
|
477 /** |
|
478 * Resets the internal context of a resource so that iteration starts from the first element. |
|
479 * |
|
480 * @param resourceBundle a resource |
|
481 * @stable ICU 2.0 |
|
482 */ |
|
483 U_STABLE void U_EXPORT2 |
|
484 ures_resetIterator(UResourceBundle *resourceBundle); |
|
485 |
|
486 /** |
|
487 * Checks whether the given resource has another element to iterate over. |
|
488 * |
|
489 * @param resourceBundle a resource |
|
490 * @return TRUE if there are more elements, FALSE if there is no more elements |
|
491 * @stable ICU 2.0 |
|
492 */ |
|
493 U_STABLE UBool U_EXPORT2 |
|
494 ures_hasNext(const UResourceBundle *resourceBundle); |
|
495 |
|
496 /** |
|
497 * Returns the next resource in a given resource or NULL if there are no more resources |
|
498 * to iterate over. Features a fill-in parameter. |
|
499 * |
|
500 * @param resourceBundle a resource |
|
501 * @param fillIn if NULL a new UResourceBundle struct is allocated and must be deleted by the caller. |
|
502 * Alternatively, you can supply a struct to be filled by this function. |
|
503 * @param status fills in the outgoing error code. You may still get a non NULL result even if an |
|
504 * error occured. Check status instead. |
|
505 * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it |
|
506 * @stable ICU 2.0 |
|
507 */ |
|
508 U_STABLE UResourceBundle* U_EXPORT2 |
|
509 ures_getNextResource(UResourceBundle *resourceBundle, |
|
510 UResourceBundle *fillIn, |
|
511 UErrorCode *status); |
|
512 |
|
513 /** |
|
514 * Returns the next string in a given resource or NULL if there are no more resources |
|
515 * to iterate over. |
|
516 * |
|
517 * @param resourceBundle a resource |
|
518 * @param len fill in length of the string |
|
519 * @param key fill in for key associated with this string. NULL if no key |
|
520 * @param status fills in the outgoing error code. If an error occured, we may return NULL, but don't |
|
521 * count on it. Check status instead! |
|
522 * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file. |
|
523 * @stable ICU 2.0 |
|
524 */ |
|
525 U_STABLE const UChar* U_EXPORT2 |
|
526 ures_getNextString(UResourceBundle *resourceBundle, |
|
527 int32_t* len, |
|
528 const char ** key, |
|
529 UErrorCode *status); |
|
530 |
|
531 /** |
|
532 * Returns the resource in a given resource at the specified index. Features a fill-in parameter. |
|
533 * |
|
534 * @param resourceBundle the resource bundle from which to get a sub-resource |
|
535 * @param indexR an index to the wanted resource. |
|
536 * @param fillIn if NULL a new UResourceBundle struct is allocated and must be deleted by the caller. |
|
537 * Alternatively, you can supply a struct to be filled by this function. |
|
538 * @param status fills in the outgoing error code. Don't count on NULL being returned if an error has |
|
539 * occured. Check status instead. |
|
540 * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it |
|
541 * @stable ICU 2.0 |
|
542 */ |
|
543 U_STABLE UResourceBundle* U_EXPORT2 |
|
544 ures_getByIndex(const UResourceBundle *resourceBundle, |
|
545 int32_t indexR, |
|
546 UResourceBundle *fillIn, |
|
547 UErrorCode *status); |
|
548 |
|
549 /** |
|
550 * Returns the string in a given resource at the specified index. |
|
551 * |
|
552 * @param resourceBundle a resource |
|
553 * @param indexS an index to the wanted string. |
|
554 * @param len fill in length of the string |
|
555 * @param status fills in the outgoing error code. If an error occured, we may return NULL, but don't |
|
556 * count on it. Check status instead! |
|
557 * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file. |
|
558 * @stable ICU 2.0 |
|
559 */ |
|
560 U_STABLE const UChar* U_EXPORT2 |
|
561 ures_getStringByIndex(const UResourceBundle *resourceBundle, |
|
562 int32_t indexS, |
|
563 int32_t* len, |
|
564 UErrorCode *status); |
|
565 |
|
566 /** |
|
567 * Returns a resource in a given resource that has a given key. This procedure works only with table |
|
568 * resources. Features a fill-in parameter. |
|
569 * |
|
570 * @param resourceBundle a resource |
|
571 * @param key a key associated with the wanted resource |
|
572 * @param fillIn if NULL a new UResourceBundle struct is allocated and must be deleted by the caller. |
|
573 * Alternatively, you can supply a struct to be filled by this function. |
|
574 * @param status fills in the outgoing error code. |
|
575 * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it |
|
576 * @stable ICU 2.0 |
|
577 */ |
|
578 U_STABLE UResourceBundle* U_EXPORT2 |
|
579 ures_getByKey(const UResourceBundle *resourceBundle, |
|
580 const char* key, |
|
581 UResourceBundle *fillIn, |
|
582 UErrorCode *status); |
|
583 |
|
584 /** |
|
585 * Returns a string in a given resource that has a given key. This procedure works only with table |
|
586 * resources. |
|
587 * |
|
588 * @param resB a resource |
|
589 * @param key a key associated with the wanted string |
|
590 * @param len fill in length of the string |
|
591 * @param status fills in the outgoing error code. If an error occured, we may return NULL, but don't |
|
592 * count on it. Check status instead! |
|
593 * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file. |
|
594 * @stable ICU 2.0 |
|
595 */ |
|
596 U_STABLE const UChar* U_EXPORT2 |
|
597 ures_getStringByKey(const UResourceBundle *resB, |
|
598 const char* key, |
|
599 int32_t* len, |
|
600 UErrorCode *status); |
|
601 |
|
602 #ifdef XP_CPLUSPLUS |
|
603 #include "unicode/unistr.h" |
|
604 |
|
605 U_NAMESPACE_BEGIN |
|
606 /** |
|
607 * returns a string from a string resource type |
|
608 * |
|
609 * @param resB a resource |
|
610 * @param status: fills in the outgoing error code |
|
611 * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found |
|
612 * could be a non-failing error |
|
613 * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT> |
|
614 * @return an UnicodeString object. If there is an error, string is bogus |
|
615 * @stable ICU 2.0 |
|
616 */ |
|
617 inline UnicodeString |
|
618 ures_getUnicodeString(const UResourceBundle *resB, |
|
619 UErrorCode* status) |
|
620 { |
|
621 int32_t len = 0; |
|
622 const UChar *r = ures_getString(resB, &len, status); |
|
623 return UnicodeString(TRUE, r, len); |
|
624 } |
|
625 |
|
626 /** |
|
627 * Returns the next string in a resource or NULL if there are no more resources |
|
628 * to iterate over. |
|
629 * |
|
630 * @param resB a resource |
|
631 * @param key fill in for key associated with this string |
|
632 * @param status fills in the outgoing error code |
|
633 * @return an UnicodeString object. |
|
634 * @stable ICU 2.0 |
|
635 */ |
|
636 inline UnicodeString |
|
637 ures_getNextUnicodeString(UResourceBundle *resB, |
|
638 const char ** key, |
|
639 UErrorCode* status) |
|
640 { |
|
641 int32_t len = 0; |
|
642 const UChar* r = ures_getNextString(resB, &len, key, status); |
|
643 return UnicodeString(TRUE, r, len); |
|
644 } |
|
645 |
|
646 /** |
|
647 * Returns the string in a given resource at the specified index. |
|
648 * |
|
649 * @param resB a resource |
|
650 * @param index an index to the wanted string. |
|
651 * @param status fills in the outgoing error code |
|
652 * @return an UnicodeString object. If there is an error, string is bogus |
|
653 * @stable ICU 2.0 |
|
654 */ |
|
655 inline UnicodeString |
|
656 ures_getUnicodeStringByIndex(const UResourceBundle *resB, |
|
657 int32_t indexS, |
|
658 UErrorCode* status) |
|
659 { |
|
660 int32_t len = 0; |
|
661 const UChar* r = ures_getStringByIndex(resB, indexS, &len, status); |
|
662 return UnicodeString(TRUE, r, len); |
|
663 } |
|
664 |
|
665 /** |
|
666 * Returns a string in a resource that has a given key. This procedure works only with table |
|
667 * resources. |
|
668 * |
|
669 * @param resB a resource |
|
670 * @param key a key associated with the wanted string |
|
671 * @param status fills in the outgoing error code |
|
672 * @return an UnicodeString object. If there is an error, string is bogus |
|
673 * @stable ICU 2.0 |
|
674 */ |
|
675 inline UnicodeString |
|
676 ures_getUnicodeStringByKey(const UResourceBundle *resB, |
|
677 const char* key, |
|
678 UErrorCode* status) |
|
679 { |
|
680 int32_t len = 0; |
|
681 const UChar* r = ures_getStringByKey(resB, key, &len, status); |
|
682 return UnicodeString(TRUE, r, len); |
|
683 } |
|
684 |
|
685 U_NAMESPACE_END |
|
686 |
|
687 #endif |
|
688 |
|
689 |
|
690 /** |
|
691 * Get a resource with multi-level fallback. Normally only the top level resources will |
|
692 * fallback to its parent. This performs fallback on subresources. For example, when a table |
|
693 * is defined in a resource bundle and a parent resource bundle, normally no fallback occurs |
|
694 * on the sub-resources because the table is defined in the current resource bundle, but this |
|
695 * function can perform fallback on the sub-resources of the table. |
|
696 * @param resB a resource |
|
697 * @param inKey a key associated with the requested resource |
|
698 * @param fillIn if NULL a new UResourceBundle struct is allocated and must be deleted by the caller. |
|
699 * Alternatively, you can supply a struct to be filled by this function. |
|
700 * @param status: fills in the outgoing error code |
|
701 * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found |
|
702 * could be a non-failing error |
|
703 * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT> |
|
704 * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it |
|
705 * @internal ICU 3.0 |
|
706 */ |
|
707 U_INTERNAL UResourceBundle* U_EXPORT2 |
|
708 ures_getByKeyWithFallback(const UResourceBundle *resB, |
|
709 const char* inKey, |
|
710 UResourceBundle *fillIn, |
|
711 UErrorCode *status); |
|
712 |
|
713 |
|
714 /** |
|
715 * Create a string enumerator, owned by the caller, of all locales located within |
|
716 * the specified resource tree. |
|
717 * @param packageName name of the tree, such as (NULL) or U_ICUDATA_ALIAS or or "ICUDATA-coll" |
|
718 * This call is similar to uloc_getAvailable(). |
|
719 * @param status error code |
|
720 * @draft ICU 3.2 |
|
721 */ |
|
722 U_DRAFT UEnumeration* U_EXPORT2 |
|
723 ures_openAvailableLocales(const char *packageName, UErrorCode *status); |
|
724 |
|
725 |
|
726 #endif /*_URES*/ |
|
727 /*eof*/ |