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