1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others.
2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html
3*0e209d39SAndroid Build Coastguard Worker /*
4*0e209d39SAndroid Build Coastguard Worker **********************************************************************
5*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 1997-2016, International Business Machines
6*0e209d39SAndroid Build Coastguard Worker * Corporation and others. All Rights Reserved.
7*0e209d39SAndroid Build Coastguard Worker **********************************************************************
8*0e209d39SAndroid Build Coastguard Worker *
9*0e209d39SAndroid Build Coastguard Worker * File URES.H (formerly CRESBUND.H)
10*0e209d39SAndroid Build Coastguard Worker *
11*0e209d39SAndroid Build Coastguard Worker * Modification History:
12*0e209d39SAndroid Build Coastguard Worker *
13*0e209d39SAndroid Build Coastguard Worker * Date Name Description
14*0e209d39SAndroid Build Coastguard Worker * 04/01/97 aliu Creation.
15*0e209d39SAndroid Build Coastguard Worker * 02/22/99 damiba overhaul.
16*0e209d39SAndroid Build Coastguard Worker * 04/04/99 helena Fixed internal header inclusion.
17*0e209d39SAndroid Build Coastguard Worker * 04/15/99 Madhu Updated Javadoc
18*0e209d39SAndroid Build Coastguard Worker * 06/14/99 stephen Removed functions taking a filename suffix.
19*0e209d39SAndroid Build Coastguard Worker * 07/20/99 stephen Language-independent typedef to void*
20*0e209d39SAndroid Build Coastguard Worker * 11/09/99 weiv Added ures_getLocale()
21*0e209d39SAndroid Build Coastguard Worker * 06/24/02 weiv Added support for resource sharing
22*0e209d39SAndroid Build Coastguard Worker ******************************************************************************
23*0e209d39SAndroid Build Coastguard Worker */
24*0e209d39SAndroid Build Coastguard Worker
25*0e209d39SAndroid Build Coastguard Worker #ifndef URES_H
26*0e209d39SAndroid Build Coastguard Worker #define URES_H
27*0e209d39SAndroid Build Coastguard Worker
28*0e209d39SAndroid Build Coastguard Worker #include "unicode/char16ptr.h"
29*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h"
30*0e209d39SAndroid Build Coastguard Worker #include "unicode/uloc.h"
31*0e209d39SAndroid Build Coastguard Worker
32*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API
33*0e209d39SAndroid Build Coastguard Worker #include "unicode/localpointer.h"
34*0e209d39SAndroid Build Coastguard Worker #endif // U_SHOW_CPLUSPLUS_API
35*0e209d39SAndroid Build Coastguard Worker
36*0e209d39SAndroid Build Coastguard Worker /**
37*0e209d39SAndroid Build Coastguard Worker * \file
38*0e209d39SAndroid Build Coastguard Worker * \brief C API: Resource Bundle
39*0e209d39SAndroid Build Coastguard Worker *
40*0e209d39SAndroid Build Coastguard Worker * <h2>C API: Resource Bundle</h2>
41*0e209d39SAndroid Build Coastguard Worker *
42*0e209d39SAndroid Build Coastguard Worker * C API representing a collection of resource information pertaining to a given
43*0e209d39SAndroid Build Coastguard Worker * locale. A resource bundle provides a way of accessing locale- specific information in
44*0e209d39SAndroid Build Coastguard Worker * a data file. You create a resource bundle that manages the resources for a given
45*0e209d39SAndroid Build Coastguard Worker * locale and then ask it for individual resources.
46*0e209d39SAndroid Build Coastguard Worker * <P>
47*0e209d39SAndroid Build Coastguard Worker * Resource bundles in ICU4C are currently defined using text files which conform to the following
48*0e209d39SAndroid Build Coastguard Worker * <a href="https://github.com/unicode-org/icu-docs/blob/main/design/bnf_rb.txt">BNF definition</a>.
49*0e209d39SAndroid Build Coastguard Worker * More on resource bundle concepts and syntax can be found in the
50*0e209d39SAndroid Build Coastguard Worker * <a href="https://unicode-org.github.io/icu/userguide/locale/resources">Users Guide</a>.
51*0e209d39SAndroid Build Coastguard Worker * <P>
52*0e209d39SAndroid Build Coastguard Worker */
53*0e209d39SAndroid Build Coastguard Worker
54*0e209d39SAndroid Build Coastguard Worker /**
55*0e209d39SAndroid Build Coastguard Worker * UResourceBundle is an opaque type for handles for resource bundles in C APIs.
56*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
57*0e209d39SAndroid Build Coastguard Worker */
58*0e209d39SAndroid Build Coastguard Worker struct UResourceBundle;
59*0e209d39SAndroid Build Coastguard Worker
60*0e209d39SAndroid Build Coastguard Worker /**
61*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
62*0e209d39SAndroid Build Coastguard Worker */
63*0e209d39SAndroid Build Coastguard Worker typedef struct UResourceBundle UResourceBundle;
64*0e209d39SAndroid Build Coastguard Worker
65*0e209d39SAndroid Build Coastguard Worker /**
66*0e209d39SAndroid Build Coastguard Worker * Numeric constants for types of resource items.
67*0e209d39SAndroid Build Coastguard Worker * @see ures_getType
68*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
69*0e209d39SAndroid Build Coastguard Worker */
70*0e209d39SAndroid Build Coastguard Worker typedef enum {
71*0e209d39SAndroid Build Coastguard Worker /** Resource type constant for "no resource". @stable ICU 2.6 */
72*0e209d39SAndroid Build Coastguard Worker URES_NONE=-1,
73*0e209d39SAndroid Build Coastguard Worker
74*0e209d39SAndroid Build Coastguard Worker /** Resource type constant for 16-bit Unicode strings. @stable ICU 2.6 */
75*0e209d39SAndroid Build Coastguard Worker URES_STRING=0,
76*0e209d39SAndroid Build Coastguard Worker
77*0e209d39SAndroid Build Coastguard Worker /** Resource type constant for binary data. @stable ICU 2.6 */
78*0e209d39SAndroid Build Coastguard Worker URES_BINARY=1,
79*0e209d39SAndroid Build Coastguard Worker
80*0e209d39SAndroid Build Coastguard Worker /** Resource type constant for tables of key-value pairs. @stable ICU 2.6 */
81*0e209d39SAndroid Build Coastguard Worker URES_TABLE=2,
82*0e209d39SAndroid Build Coastguard Worker
83*0e209d39SAndroid Build Coastguard Worker /**
84*0e209d39SAndroid Build Coastguard Worker * Resource type constant for aliases;
85*0e209d39SAndroid Build Coastguard Worker * internally stores a string which identifies the actual resource
86*0e209d39SAndroid Build Coastguard Worker * storing the data (can be in a different resource bundle).
87*0e209d39SAndroid Build Coastguard Worker * Resolved internally before delivering the actual resource through the API.
88*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.6
89*0e209d39SAndroid Build Coastguard Worker */
90*0e209d39SAndroid Build Coastguard Worker URES_ALIAS=3,
91*0e209d39SAndroid Build Coastguard Worker
92*0e209d39SAndroid Build Coastguard Worker /**
93*0e209d39SAndroid Build Coastguard Worker * Resource type constant for a single 28-bit integer, interpreted as
94*0e209d39SAndroid Build Coastguard Worker * signed or unsigned by the ures_getInt() or ures_getUInt() function.
95*0e209d39SAndroid Build Coastguard Worker * @see ures_getInt
96*0e209d39SAndroid Build Coastguard Worker * @see ures_getUInt
97*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.6
98*0e209d39SAndroid Build Coastguard Worker */
99*0e209d39SAndroid Build Coastguard Worker URES_INT=7,
100*0e209d39SAndroid Build Coastguard Worker
101*0e209d39SAndroid Build Coastguard Worker /** Resource type constant for arrays of resources. @stable ICU 2.6 */
102*0e209d39SAndroid Build Coastguard Worker URES_ARRAY=8,
103*0e209d39SAndroid Build Coastguard Worker
104*0e209d39SAndroid Build Coastguard Worker /**
105*0e209d39SAndroid Build Coastguard Worker * Resource type constant for vectors of 32-bit integers.
106*0e209d39SAndroid Build Coastguard Worker * @see ures_getIntVector
107*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.6
108*0e209d39SAndroid Build Coastguard Worker */
109*0e209d39SAndroid Build Coastguard Worker URES_INT_VECTOR = 14,
110*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API
111*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.6 Use the URES_ constant instead. */
112*0e209d39SAndroid Build Coastguard Worker RES_NONE=URES_NONE,
113*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.6 Use the URES_ constant instead. */
114*0e209d39SAndroid Build Coastguard Worker RES_STRING=URES_STRING,
115*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.6 Use the URES_ constant instead. */
116*0e209d39SAndroid Build Coastguard Worker RES_BINARY=URES_BINARY,
117*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.6 Use the URES_ constant instead. */
118*0e209d39SAndroid Build Coastguard Worker RES_TABLE=URES_TABLE,
119*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.6 Use the URES_ constant instead. */
120*0e209d39SAndroid Build Coastguard Worker RES_ALIAS=URES_ALIAS,
121*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.6 Use the URES_ constant instead. */
122*0e209d39SAndroid Build Coastguard Worker RES_INT=URES_INT,
123*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.6 Use the URES_ constant instead. */
124*0e209d39SAndroid Build Coastguard Worker RES_ARRAY=URES_ARRAY,
125*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.6 Use the URES_ constant instead. */
126*0e209d39SAndroid Build Coastguard Worker RES_INT_VECTOR=URES_INT_VECTOR,
127*0e209d39SAndroid Build Coastguard Worker /** @deprecated ICU 2.6 Not used. */
128*0e209d39SAndroid Build Coastguard Worker RES_RESERVED=15,
129*0e209d39SAndroid Build Coastguard Worker
130*0e209d39SAndroid Build Coastguard Worker /**
131*0e209d39SAndroid Build Coastguard Worker * One more than the highest normal UResType value.
132*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
133*0e209d39SAndroid Build Coastguard Worker */
134*0e209d39SAndroid Build Coastguard Worker URES_LIMIT = 16
135*0e209d39SAndroid Build Coastguard Worker #endif // U_HIDE_DEPRECATED_API
136*0e209d39SAndroid Build Coastguard Worker } UResType;
137*0e209d39SAndroid Build Coastguard Worker
138*0e209d39SAndroid Build Coastguard Worker /*
139*0e209d39SAndroid Build Coastguard Worker * Functions to create and destroy resource bundles.
140*0e209d39SAndroid Build Coastguard Worker */
141*0e209d39SAndroid Build Coastguard Worker
142*0e209d39SAndroid Build Coastguard Worker /**
143*0e209d39SAndroid Build Coastguard Worker * Opens a UResourceBundle, from which users can extract strings by using
144*0e209d39SAndroid Build Coastguard Worker * their corresponding keys.
145*0e209d39SAndroid Build Coastguard Worker * Note that the caller is responsible of calling <TT>ures_close</TT> on each successfully
146*0e209d39SAndroid Build Coastguard Worker * opened resource bundle.
147*0e209d39SAndroid Build Coastguard Worker * @param packageName The packageName and locale together point to an ICU udata object,
148*0e209d39SAndroid Build Coastguard Worker * as defined by <code> udata_open( packageName, "res", locale, err) </code>
149*0e209d39SAndroid Build Coastguard Worker * or equivalent. Typically, packageName will refer to a (.dat) file, or to
150*0e209d39SAndroid Build Coastguard Worker * a package registered with udata_setAppData(). Using a full file or directory
151*0e209d39SAndroid Build Coastguard Worker * pathname for packageName is deprecated. If NULL, ICU data will be used.
152*0e209d39SAndroid Build Coastguard Worker * @param locale specifies the locale for which we want to open the resource
153*0e209d39SAndroid Build Coastguard Worker * if NULL, the default locale will be used. If strlen(locale) == 0
154*0e209d39SAndroid Build Coastguard Worker * root locale will be used.
155*0e209d39SAndroid Build Coastguard Worker *
156*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code.
157*0e209d39SAndroid Build Coastguard Worker * The UErrorCode err parameter is used to return status information to the user. To
158*0e209d39SAndroid Build Coastguard Worker * check whether the construction succeeded or not, you should check the value of
159*0e209d39SAndroid Build Coastguard Worker * U_SUCCESS(err). If you wish more detailed information, you can check for
160*0e209d39SAndroid Build Coastguard Worker * informational status results which still indicate success. U_USING_FALLBACK_WARNING
161*0e209d39SAndroid Build Coastguard Worker * indicates that a fall back locale was used. For example, 'de_CH' was requested,
162*0e209d39SAndroid Build Coastguard Worker * but nothing was found there, so 'de' was used. U_USING_DEFAULT_WARNING indicates that
163*0e209d39SAndroid Build Coastguard Worker * the default locale data or root locale data was used; neither the requested locale
164*0e209d39SAndroid Build Coastguard Worker * nor any of its fall back locales could be found. Please see the users guide for more
165*0e209d39SAndroid Build Coastguard Worker * information on this topic.
166*0e209d39SAndroid Build Coastguard Worker * @return a newly allocated resource bundle.
167*0e209d39SAndroid Build Coastguard Worker * @see ures_close
168*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
169*0e209d39SAndroid Build Coastguard Worker */
170*0e209d39SAndroid Build Coastguard Worker U_CAPI UResourceBundle* U_EXPORT2
171*0e209d39SAndroid Build Coastguard Worker ures_open(const char* packageName,
172*0e209d39SAndroid Build Coastguard Worker const char* locale,
173*0e209d39SAndroid Build Coastguard Worker UErrorCode* status);
174*0e209d39SAndroid Build Coastguard Worker
175*0e209d39SAndroid Build Coastguard Worker
176*0e209d39SAndroid Build Coastguard Worker /** This function does not care what kind of localeID is passed in. It simply opens a bundle with
177*0e209d39SAndroid Build Coastguard Worker * that name. Fallback mechanism is disabled for the new bundle. If the requested bundle contains
178*0e209d39SAndroid Build Coastguard Worker * an %%ALIAS directive, the results are undefined.
179*0e209d39SAndroid Build Coastguard Worker * @param packageName The packageName and locale together point to an ICU udata object,
180*0e209d39SAndroid Build Coastguard Worker * as defined by <code> udata_open( packageName, "res", locale, err) </code>
181*0e209d39SAndroid Build Coastguard Worker * or equivalent. Typically, packageName will refer to a (.dat) file, or to
182*0e209d39SAndroid Build Coastguard Worker * a package registered with udata_setAppData(). Using a full file or directory
183*0e209d39SAndroid Build Coastguard Worker * pathname for packageName is deprecated. If NULL, ICU data will be used.
184*0e209d39SAndroid Build Coastguard Worker * @param locale specifies the locale for which we want to open the resource
185*0e209d39SAndroid Build Coastguard Worker * if NULL, the default locale will be used. If strlen(locale) == 0
186*0e209d39SAndroid Build Coastguard Worker * root locale will be used.
187*0e209d39SAndroid Build Coastguard Worker *
188*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code. Either U_ZERO_ERROR or U_MISSING_RESOURCE_ERROR
189*0e209d39SAndroid Build Coastguard Worker * @return a newly allocated resource bundle or NULL if it doesn't exist.
190*0e209d39SAndroid Build Coastguard Worker * @see ures_close
191*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
192*0e209d39SAndroid Build Coastguard Worker */
193*0e209d39SAndroid Build Coastguard Worker U_CAPI UResourceBundle* U_EXPORT2
194*0e209d39SAndroid Build Coastguard Worker ures_openDirect(const char* packageName,
195*0e209d39SAndroid Build Coastguard Worker const char* locale,
196*0e209d39SAndroid Build Coastguard Worker UErrorCode* status);
197*0e209d39SAndroid Build Coastguard Worker
198*0e209d39SAndroid Build Coastguard Worker /**
199*0e209d39SAndroid Build Coastguard Worker * Same as ures_open() but takes a const UChar *path.
200*0e209d39SAndroid Build Coastguard Worker * This path will be converted to char * using the default converter,
201*0e209d39SAndroid Build Coastguard Worker * then ures_open() is called.
202*0e209d39SAndroid Build Coastguard Worker *
203*0e209d39SAndroid Build Coastguard Worker * @param packageName The packageName and locale together point to an ICU udata object,
204*0e209d39SAndroid Build Coastguard Worker * as defined by <code> udata_open( packageName, "res", locale, err) </code>
205*0e209d39SAndroid Build Coastguard Worker * or equivalent. Typically, packageName will refer to a (.dat) file, or to
206*0e209d39SAndroid Build Coastguard Worker * a package registered with udata_setAppData(). Using a full file or directory
207*0e209d39SAndroid Build Coastguard Worker * pathname for packageName is deprecated. If NULL, ICU data will be used.
208*0e209d39SAndroid Build Coastguard Worker * @param locale specifies the locale for which we want to open the resource
209*0e209d39SAndroid Build Coastguard Worker * if NULL, the default locale will be used. If strlen(locale) == 0
210*0e209d39SAndroid Build Coastguard Worker * root locale will be used.
211*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code.
212*0e209d39SAndroid Build Coastguard Worker * @return a newly allocated resource bundle.
213*0e209d39SAndroid Build Coastguard Worker * @see ures_open
214*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
215*0e209d39SAndroid Build Coastguard Worker */
216*0e209d39SAndroid Build Coastguard Worker U_CAPI UResourceBundle* U_EXPORT2
217*0e209d39SAndroid Build Coastguard Worker ures_openU(const UChar* packageName,
218*0e209d39SAndroid Build Coastguard Worker const char* locale,
219*0e209d39SAndroid Build Coastguard Worker UErrorCode* status);
220*0e209d39SAndroid Build Coastguard Worker
221*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API
222*0e209d39SAndroid Build Coastguard Worker /**
223*0e209d39SAndroid Build Coastguard Worker * Returns the number of strings/arrays in resource bundles.
224*0e209d39SAndroid Build Coastguard Worker * Better to use ures_getSize, as this function will be deprecated.
225*0e209d39SAndroid Build Coastguard Worker *
226*0e209d39SAndroid Build Coastguard Worker *@param resourceBundle resource bundle containing the desired strings
227*0e209d39SAndroid Build Coastguard Worker *@param resourceKey key tagging the resource
228*0e209d39SAndroid Build Coastguard Worker *@param err fills in the outgoing error code
229*0e209d39SAndroid Build Coastguard Worker * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
230*0e209d39SAndroid Build Coastguard Worker * could be a non-failing error
231*0e209d39SAndroid Build Coastguard Worker * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_FALLBACK_WARNING </TT>
232*0e209d39SAndroid Build Coastguard Worker *@return: for <STRONG>Arrays</STRONG>: returns the number of resources in the array
233*0e209d39SAndroid Build Coastguard Worker * <STRONG>Tables</STRONG>: returns the number of resources in the table
234*0e209d39SAndroid Build Coastguard Worker * <STRONG>single string</STRONG>: returns 1
235*0e209d39SAndroid Build Coastguard Worker *@see ures_getSize
236*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 2.8 User ures_getSize instead
237*0e209d39SAndroid Build Coastguard Worker */
238*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED int32_t U_EXPORT2
239*0e209d39SAndroid Build Coastguard Worker ures_countArrayItems(const UResourceBundle* resourceBundle,
240*0e209d39SAndroid Build Coastguard Worker const char* resourceKey,
241*0e209d39SAndroid Build Coastguard Worker UErrorCode* err);
242*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */
243*0e209d39SAndroid Build Coastguard Worker
244*0e209d39SAndroid Build Coastguard Worker /**
245*0e209d39SAndroid Build Coastguard Worker * Close a resource bundle, all pointers returned from the various ures_getXXX calls
246*0e209d39SAndroid Build Coastguard Worker * on this particular bundle should be considered invalid henceforth.
247*0e209d39SAndroid Build Coastguard Worker *
248*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle a pointer to a resourceBundle struct. Can be NULL.
249*0e209d39SAndroid Build Coastguard Worker * @see ures_open
250*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
251*0e209d39SAndroid Build Coastguard Worker */
252*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
253*0e209d39SAndroid Build Coastguard Worker ures_close(UResourceBundle* resourceBundle);
254*0e209d39SAndroid Build Coastguard Worker
255*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API
256*0e209d39SAndroid Build Coastguard Worker
257*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN
258*0e209d39SAndroid Build Coastguard Worker
259*0e209d39SAndroid Build Coastguard Worker /**
260*0e209d39SAndroid Build Coastguard Worker * \class LocalUResourceBundlePointer
261*0e209d39SAndroid Build Coastguard Worker * "Smart pointer" class, closes a UResourceBundle via ures_close().
262*0e209d39SAndroid Build Coastguard Worker * For most methods see the LocalPointerBase base class.
263*0e209d39SAndroid Build Coastguard Worker *
264*0e209d39SAndroid Build Coastguard Worker * @see LocalPointerBase
265*0e209d39SAndroid Build Coastguard Worker * @see LocalPointer
266*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.4
267*0e209d39SAndroid Build Coastguard Worker */
268*0e209d39SAndroid Build Coastguard Worker U_DEFINE_LOCAL_OPEN_POINTER(LocalUResourceBundlePointer, UResourceBundle, ures_close);
269*0e209d39SAndroid Build Coastguard Worker
270*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END
271*0e209d39SAndroid Build Coastguard Worker
272*0e209d39SAndroid Build Coastguard Worker #endif
273*0e209d39SAndroid Build Coastguard Worker
274*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API
275*0e209d39SAndroid Build Coastguard Worker /**
276*0e209d39SAndroid Build Coastguard Worker * Return the version number associated with this ResourceBundle as a string. Please
277*0e209d39SAndroid Build Coastguard Worker * use ures_getVersion as this function is going to be deprecated.
278*0e209d39SAndroid Build Coastguard Worker *
279*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle The resource bundle for which the version is checked.
280*0e209d39SAndroid Build Coastguard Worker * @return A version number string as specified in the resource bundle or its parent.
281*0e209d39SAndroid Build Coastguard Worker * The caller does not own this string.
282*0e209d39SAndroid Build Coastguard Worker * @see ures_getVersion
283*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 2.8 Use ures_getVersion instead.
284*0e209d39SAndroid Build Coastguard Worker */
285*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED const char* U_EXPORT2
286*0e209d39SAndroid Build Coastguard Worker ures_getVersionNumber(const UResourceBundle* resourceBundle);
287*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */
288*0e209d39SAndroid Build Coastguard Worker
289*0e209d39SAndroid Build Coastguard Worker /**
290*0e209d39SAndroid Build Coastguard Worker * Return the version number associated with this ResourceBundle as an
291*0e209d39SAndroid Build Coastguard Worker * UVersionInfo array.
292*0e209d39SAndroid Build Coastguard Worker *
293*0e209d39SAndroid Build Coastguard Worker * @param resB The resource bundle for which the version is checked.
294*0e209d39SAndroid Build Coastguard Worker * @param versionInfo A UVersionInfo array that is filled with the version number
295*0e209d39SAndroid Build Coastguard Worker * as specified in the resource bundle or its parent.
296*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
297*0e209d39SAndroid Build Coastguard Worker */
298*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
299*0e209d39SAndroid Build Coastguard Worker ures_getVersion(const UResourceBundle* resB,
300*0e209d39SAndroid Build Coastguard Worker UVersionInfo versionInfo);
301*0e209d39SAndroid Build Coastguard Worker
302*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API
303*0e209d39SAndroid Build Coastguard Worker /**
304*0e209d39SAndroid Build Coastguard Worker * Return the name of the Locale associated with this ResourceBundle. This API allows
305*0e209d39SAndroid Build Coastguard Worker * you to query for the real locale of the resource. For example, if you requested
306*0e209d39SAndroid Build Coastguard Worker * "en_US_CALIFORNIA" and only "en_US" bundle exists, "en_US" will be returned.
307*0e209d39SAndroid Build Coastguard Worker * For subresources, the locale where this resource comes from will be returned.
308*0e209d39SAndroid Build Coastguard Worker * If fallback has occurred, getLocale will reflect this.
309*0e209d39SAndroid Build Coastguard Worker *
310*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle resource bundle in question
311*0e209d39SAndroid Build Coastguard Worker * @param status just for catching illegal arguments
312*0e209d39SAndroid Build Coastguard Worker * @return A Locale name
313*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 2.8 Use ures_getLocaleByType instead.
314*0e209d39SAndroid Build Coastguard Worker */
315*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED const char* U_EXPORT2
316*0e209d39SAndroid Build Coastguard Worker ures_getLocale(const UResourceBundle* resourceBundle,
317*0e209d39SAndroid Build Coastguard Worker UErrorCode* status);
318*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */
319*0e209d39SAndroid Build Coastguard Worker
320*0e209d39SAndroid Build Coastguard Worker /**
321*0e209d39SAndroid Build Coastguard Worker * Return the name of the Locale associated with this ResourceBundle.
322*0e209d39SAndroid Build Coastguard Worker * You can choose between requested, valid and real locale.
323*0e209d39SAndroid Build Coastguard Worker *
324*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle resource bundle in question
325*0e209d39SAndroid Build Coastguard Worker * @param type You can choose between requested, valid and actual
326*0e209d39SAndroid Build Coastguard Worker * locale. For description see the definition of
327*0e209d39SAndroid Build Coastguard Worker * ULocDataLocaleType in uloc.h
328*0e209d39SAndroid Build Coastguard Worker * @param status just for catching illegal arguments
329*0e209d39SAndroid Build Coastguard Worker * @return A Locale name
330*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.8
331*0e209d39SAndroid Build Coastguard Worker */
332*0e209d39SAndroid Build Coastguard Worker U_CAPI const char* U_EXPORT2
333*0e209d39SAndroid Build Coastguard Worker ures_getLocaleByType(const UResourceBundle* resourceBundle,
334*0e209d39SAndroid Build Coastguard Worker ULocDataLocaleType type,
335*0e209d39SAndroid Build Coastguard Worker UErrorCode* status);
336*0e209d39SAndroid Build Coastguard Worker
337*0e209d39SAndroid Build Coastguard Worker
338*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API
339*0e209d39SAndroid Build Coastguard Worker /**
340*0e209d39SAndroid Build Coastguard Worker * Same as ures_open() but uses the fill-in parameter instead of allocating a new bundle.
341*0e209d39SAndroid Build Coastguard Worker *
342*0e209d39SAndroid Build Coastguard Worker * TODO need to revisit usefulness of this function
343*0e209d39SAndroid Build Coastguard Worker * and usage model for fillIn parameters without knowing sizeof(UResourceBundle)
344*0e209d39SAndroid Build Coastguard Worker * @param r The existing UResourceBundle to fill in. If NULL then status will be
345*0e209d39SAndroid Build Coastguard Worker * set to U_ILLEGAL_ARGUMENT_ERROR.
346*0e209d39SAndroid Build Coastguard Worker * @param packageName The packageName and locale together point to an ICU udata object,
347*0e209d39SAndroid Build Coastguard Worker * as defined by <code> udata_open( packageName, "res", locale, err) </code>
348*0e209d39SAndroid Build Coastguard Worker * or equivalent. Typically, packageName will refer to a (.dat) file, or to
349*0e209d39SAndroid Build Coastguard Worker * a package registered with udata_setAppData(). Using a full file or directory
350*0e209d39SAndroid Build Coastguard Worker * pathname for packageName is deprecated. If NULL, ICU data will be used.
351*0e209d39SAndroid Build Coastguard Worker * @param localeID specifies the locale for which we want to open the resource
352*0e209d39SAndroid Build Coastguard Worker * @param status The error code.
353*0e209d39SAndroid Build Coastguard Worker * @internal
354*0e209d39SAndroid Build Coastguard Worker */
355*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
356*0e209d39SAndroid Build Coastguard Worker ures_openFillIn(UResourceBundle *r,
357*0e209d39SAndroid Build Coastguard Worker const char* packageName,
358*0e209d39SAndroid Build Coastguard Worker const char* localeID,
359*0e209d39SAndroid Build Coastguard Worker UErrorCode* status);
360*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_INTERNAL_API */
361*0e209d39SAndroid Build Coastguard Worker
362*0e209d39SAndroid Build Coastguard Worker /**
363*0e209d39SAndroid Build Coastguard Worker * Returns a string from a string resource type
364*0e209d39SAndroid Build Coastguard Worker *
365*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle a string resource
366*0e209d39SAndroid Build Coastguard Worker * @param len fills in the length of resulting string
367*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code
368*0e209d39SAndroid Build Coastguard Worker * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
369*0e209d39SAndroid Build Coastguard Worker * Always check the value of status. Don't count on returning NULL.
370*0e209d39SAndroid Build Coastguard Worker * could be a non-failing error
371*0e209d39SAndroid Build Coastguard Worker * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
372*0e209d39SAndroid Build Coastguard Worker * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
373*0e209d39SAndroid Build Coastguard Worker * @see ures_getBinary
374*0e209d39SAndroid Build Coastguard Worker * @see ures_getIntVector
375*0e209d39SAndroid Build Coastguard Worker * @see ures_getInt
376*0e209d39SAndroid Build Coastguard Worker * @see ures_getUInt
377*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
378*0e209d39SAndroid Build Coastguard Worker */
379*0e209d39SAndroid Build Coastguard Worker U_CAPI const UChar* U_EXPORT2
380*0e209d39SAndroid Build Coastguard Worker ures_getString(const UResourceBundle* resourceBundle,
381*0e209d39SAndroid Build Coastguard Worker int32_t* len,
382*0e209d39SAndroid Build Coastguard Worker UErrorCode* status);
383*0e209d39SAndroid Build Coastguard Worker
384*0e209d39SAndroid Build Coastguard Worker /**
385*0e209d39SAndroid Build Coastguard Worker * Returns a UTF-8 string from a string resource.
386*0e209d39SAndroid Build Coastguard Worker * The UTF-8 string may be returnable directly as a pointer, or
387*0e209d39SAndroid Build Coastguard Worker * it may need to be copied, or transformed from UTF-16 using u_strToUTF8()
388*0e209d39SAndroid Build Coastguard Worker * or equivalent.
389*0e209d39SAndroid Build Coastguard Worker *
390*0e209d39SAndroid Build Coastguard Worker * If forceCopy==true, then the string is always written to the dest buffer
391*0e209d39SAndroid Build Coastguard Worker * and dest is returned.
392*0e209d39SAndroid Build Coastguard Worker *
393*0e209d39SAndroid Build Coastguard Worker * If forceCopy==false, then the string is returned as a pointer if possible,
394*0e209d39SAndroid Build Coastguard Worker * without needing a dest buffer (it can be NULL). If the string needs to be
395*0e209d39SAndroid Build Coastguard Worker * copied or transformed, then it may be placed into dest at an arbitrary offset.
396*0e209d39SAndroid Build Coastguard Worker *
397*0e209d39SAndroid Build Coastguard Worker * If the string is to be written to dest, then U_BUFFER_OVERFLOW_ERROR and
398*0e209d39SAndroid Build Coastguard Worker * U_STRING_NOT_TERMINATED_WARNING are set if appropriate, as usual.
399*0e209d39SAndroid Build Coastguard Worker *
400*0e209d39SAndroid Build Coastguard Worker * If the string is transformed from UTF-16, then a conversion error may occur
401*0e209d39SAndroid Build Coastguard Worker * if an unpaired surrogate is encountered. If the function is successful, then
402*0e209d39SAndroid Build Coastguard Worker * the output UTF-8 string is always well-formed.
403*0e209d39SAndroid Build Coastguard Worker *
404*0e209d39SAndroid Build Coastguard Worker * @param resB Resource bundle.
405*0e209d39SAndroid Build Coastguard Worker * @param dest Destination buffer. Can be NULL only if capacity=*length==0.
406*0e209d39SAndroid Build Coastguard Worker * @param length Input: Capacity of destination buffer.
407*0e209d39SAndroid Build Coastguard Worker * Output: Actual length of the UTF-8 string, not counting the
408*0e209d39SAndroid Build Coastguard Worker * terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.
409*0e209d39SAndroid Build Coastguard Worker * Can be NULL, meaning capacity=0 and the string length is not
410*0e209d39SAndroid Build Coastguard Worker * returned to the caller.
411*0e209d39SAndroid Build Coastguard Worker * @param forceCopy If true, then the output string will always be written to
412*0e209d39SAndroid Build Coastguard Worker * dest, with U_BUFFER_OVERFLOW_ERROR and
413*0e209d39SAndroid Build Coastguard Worker * U_STRING_NOT_TERMINATED_WARNING set if appropriate.
414*0e209d39SAndroid Build Coastguard Worker * If false, then the dest buffer may or may not contain a
415*0e209d39SAndroid Build Coastguard Worker * copy of the string. dest may or may not be modified.
416*0e209d39SAndroid Build Coastguard Worker * If a copy needs to be written, then the UErrorCode parameter
417*0e209d39SAndroid Build Coastguard Worker * indicates overflow etc. as usual.
418*0e209d39SAndroid Build Coastguard Worker * @param status Pointer to a standard ICU error code. Its input value must
419*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns
420*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with
421*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.)
422*0e209d39SAndroid Build Coastguard Worker * @return The pointer to the UTF-8 string. It may be dest, or at some offset
423*0e209d39SAndroid Build Coastguard Worker * from dest (only if !forceCopy), or in unrelated memory.
424*0e209d39SAndroid Build Coastguard Worker * Always NUL-terminated unless the string was written to dest and
425*0e209d39SAndroid Build Coastguard Worker * length==capacity (in which case U_STRING_NOT_TERMINATED_WARNING is set).
426*0e209d39SAndroid Build Coastguard Worker *
427*0e209d39SAndroid Build Coastguard Worker * @see ures_getString
428*0e209d39SAndroid Build Coastguard Worker * @see u_strToUTF8
429*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.6
430*0e209d39SAndroid Build Coastguard Worker */
431*0e209d39SAndroid Build Coastguard Worker U_CAPI const char * U_EXPORT2
432*0e209d39SAndroid Build Coastguard Worker ures_getUTF8String(const UResourceBundle *resB,
433*0e209d39SAndroid Build Coastguard Worker char *dest, int32_t *length,
434*0e209d39SAndroid Build Coastguard Worker UBool forceCopy,
435*0e209d39SAndroid Build Coastguard Worker UErrorCode *status);
436*0e209d39SAndroid Build Coastguard Worker
437*0e209d39SAndroid Build Coastguard Worker /**
438*0e209d39SAndroid Build Coastguard Worker * Returns a binary data from a binary resource.
439*0e209d39SAndroid Build Coastguard Worker *
440*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle a string resource
441*0e209d39SAndroid Build Coastguard Worker * @param len fills in the length of resulting byte chunk
442*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code
443*0e209d39SAndroid Build Coastguard Worker * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
444*0e209d39SAndroid Build Coastguard Worker * Always check the value of status. Don't count on returning NULL.
445*0e209d39SAndroid Build Coastguard Worker * could be a non-failing error
446*0e209d39SAndroid Build Coastguard Worker * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
447*0e209d39SAndroid Build Coastguard Worker * @return a pointer to a chunk of unsigned bytes which live in a memory mapped/DLL file.
448*0e209d39SAndroid Build Coastguard Worker * @see ures_getString
449*0e209d39SAndroid Build Coastguard Worker * @see ures_getIntVector
450*0e209d39SAndroid Build Coastguard Worker * @see ures_getInt
451*0e209d39SAndroid Build Coastguard Worker * @see ures_getUInt
452*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
453*0e209d39SAndroid Build Coastguard Worker */
454*0e209d39SAndroid Build Coastguard Worker U_CAPI const uint8_t* U_EXPORT2
455*0e209d39SAndroid Build Coastguard Worker ures_getBinary(const UResourceBundle* resourceBundle,
456*0e209d39SAndroid Build Coastguard Worker int32_t* len,
457*0e209d39SAndroid Build Coastguard Worker UErrorCode* status);
458*0e209d39SAndroid Build Coastguard Worker
459*0e209d39SAndroid Build Coastguard Worker /**
460*0e209d39SAndroid Build Coastguard Worker * Returns a 32 bit integer array from a resource.
461*0e209d39SAndroid Build Coastguard Worker *
462*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle an int vector resource
463*0e209d39SAndroid Build Coastguard Worker * @param len fills in the length of resulting byte chunk
464*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code
465*0e209d39SAndroid Build Coastguard Worker * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
466*0e209d39SAndroid Build Coastguard Worker * Always check the value of status. Don't count on returning NULL.
467*0e209d39SAndroid Build Coastguard Worker * could be a non-failing error
468*0e209d39SAndroid Build Coastguard Worker * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
469*0e209d39SAndroid Build Coastguard Worker * @return a pointer to a chunk of integers which live in a memory mapped/DLL file.
470*0e209d39SAndroid Build Coastguard Worker * @see ures_getBinary
471*0e209d39SAndroid Build Coastguard Worker * @see ures_getString
472*0e209d39SAndroid Build Coastguard Worker * @see ures_getInt
473*0e209d39SAndroid Build Coastguard Worker * @see ures_getUInt
474*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
475*0e209d39SAndroid Build Coastguard Worker */
476*0e209d39SAndroid Build Coastguard Worker U_CAPI const int32_t* U_EXPORT2
477*0e209d39SAndroid Build Coastguard Worker ures_getIntVector(const UResourceBundle* resourceBundle,
478*0e209d39SAndroid Build Coastguard Worker int32_t* len,
479*0e209d39SAndroid Build Coastguard Worker UErrorCode* status);
480*0e209d39SAndroid Build Coastguard Worker
481*0e209d39SAndroid Build Coastguard Worker /**
482*0e209d39SAndroid Build Coastguard Worker * Returns an unsigned integer from a resource.
483*0e209d39SAndroid Build Coastguard Worker * This integer is originally 28 bits.
484*0e209d39SAndroid Build Coastguard Worker *
485*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle a string resource
486*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code
487*0e209d39SAndroid Build Coastguard Worker * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
488*0e209d39SAndroid Build Coastguard Worker * could be a non-failing error
489*0e209d39SAndroid Build Coastguard Worker * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
490*0e209d39SAndroid Build Coastguard Worker * @return an integer value
491*0e209d39SAndroid Build Coastguard Worker * @see ures_getInt
492*0e209d39SAndroid Build Coastguard Worker * @see ures_getIntVector
493*0e209d39SAndroid Build Coastguard Worker * @see ures_getBinary
494*0e209d39SAndroid Build Coastguard Worker * @see ures_getString
495*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
496*0e209d39SAndroid Build Coastguard Worker */
497*0e209d39SAndroid Build Coastguard Worker U_CAPI uint32_t U_EXPORT2
498*0e209d39SAndroid Build Coastguard Worker ures_getUInt(const UResourceBundle* resourceBundle,
499*0e209d39SAndroid Build Coastguard Worker UErrorCode *status);
500*0e209d39SAndroid Build Coastguard Worker
501*0e209d39SAndroid Build Coastguard Worker /**
502*0e209d39SAndroid Build Coastguard Worker * Returns a signed integer from a resource.
503*0e209d39SAndroid Build Coastguard Worker * This integer is originally 28 bit and the sign gets propagated.
504*0e209d39SAndroid Build Coastguard Worker *
505*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle a string resource
506*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code
507*0e209d39SAndroid Build Coastguard Worker * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
508*0e209d39SAndroid Build Coastguard Worker * could be a non-failing error
509*0e209d39SAndroid Build Coastguard Worker * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
510*0e209d39SAndroid Build Coastguard Worker * @return an integer value
511*0e209d39SAndroid Build Coastguard Worker * @see ures_getUInt
512*0e209d39SAndroid Build Coastguard Worker * @see ures_getIntVector
513*0e209d39SAndroid Build Coastguard Worker * @see ures_getBinary
514*0e209d39SAndroid Build Coastguard Worker * @see ures_getString
515*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
516*0e209d39SAndroid Build Coastguard Worker */
517*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
518*0e209d39SAndroid Build Coastguard Worker ures_getInt(const UResourceBundle* resourceBundle,
519*0e209d39SAndroid Build Coastguard Worker UErrorCode *status);
520*0e209d39SAndroid Build Coastguard Worker
521*0e209d39SAndroid Build Coastguard Worker /**
522*0e209d39SAndroid Build Coastguard Worker * Returns the size of a resource. Size for scalar types is always 1,
523*0e209d39SAndroid Build Coastguard Worker * and for vector/table types is the number of child resources.
524*0e209d39SAndroid Build Coastguard Worker * @warning Integer array is treated as a scalar type. There are no
525*0e209d39SAndroid Build Coastguard Worker * APIs to access individual members of an integer array. It
526*0e209d39SAndroid Build Coastguard Worker * is always returned as a whole.
527*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle a resource
528*0e209d39SAndroid Build Coastguard Worker * @return number of resources in a given resource.
529*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
530*0e209d39SAndroid Build Coastguard Worker */
531*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
532*0e209d39SAndroid Build Coastguard Worker ures_getSize(const UResourceBundle *resourceBundle);
533*0e209d39SAndroid Build Coastguard Worker
534*0e209d39SAndroid Build Coastguard Worker /**
535*0e209d39SAndroid Build Coastguard Worker * Returns the type of a resource. Available types are defined in enum UResType
536*0e209d39SAndroid Build Coastguard Worker *
537*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle a resource
538*0e209d39SAndroid Build Coastguard Worker * @return type of the given resource.
539*0e209d39SAndroid Build Coastguard Worker * @see UResType
540*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
541*0e209d39SAndroid Build Coastguard Worker */
542*0e209d39SAndroid Build Coastguard Worker U_CAPI UResType U_EXPORT2
543*0e209d39SAndroid Build Coastguard Worker ures_getType(const UResourceBundle *resourceBundle);
544*0e209d39SAndroid Build Coastguard Worker
545*0e209d39SAndroid Build Coastguard Worker /**
546*0e209d39SAndroid Build Coastguard Worker * Returns the key associated with a given resource. Not all the resources have a key - only
547*0e209d39SAndroid Build Coastguard Worker * those that are members of a table.
548*0e209d39SAndroid Build Coastguard Worker *
549*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle a resource
550*0e209d39SAndroid Build Coastguard Worker * @return a key associated to this resource, or NULL if it doesn't have a key
551*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
552*0e209d39SAndroid Build Coastguard Worker */
553*0e209d39SAndroid Build Coastguard Worker U_CAPI const char * U_EXPORT2
554*0e209d39SAndroid Build Coastguard Worker ures_getKey(const UResourceBundle *resourceBundle);
555*0e209d39SAndroid Build Coastguard Worker
556*0e209d39SAndroid Build Coastguard Worker /* ITERATION API
557*0e209d39SAndroid Build Coastguard Worker This API provides means for iterating through a resource
558*0e209d39SAndroid Build Coastguard Worker */
559*0e209d39SAndroid Build Coastguard Worker
560*0e209d39SAndroid Build Coastguard Worker /**
561*0e209d39SAndroid Build Coastguard Worker * Resets the internal context of a resource so that iteration starts from the first element.
562*0e209d39SAndroid Build Coastguard Worker *
563*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle a resource
564*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
565*0e209d39SAndroid Build Coastguard Worker */
566*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
567*0e209d39SAndroid Build Coastguard Worker ures_resetIterator(UResourceBundle *resourceBundle);
568*0e209d39SAndroid Build Coastguard Worker
569*0e209d39SAndroid Build Coastguard Worker /**
570*0e209d39SAndroid Build Coastguard Worker * Checks whether the given resource has another element to iterate over.
571*0e209d39SAndroid Build Coastguard Worker *
572*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle a resource
573*0e209d39SAndroid Build Coastguard Worker * @return true if there are more elements, false if there is no more elements
574*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
575*0e209d39SAndroid Build Coastguard Worker */
576*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
577*0e209d39SAndroid Build Coastguard Worker ures_hasNext(const UResourceBundle *resourceBundle);
578*0e209d39SAndroid Build Coastguard Worker
579*0e209d39SAndroid Build Coastguard Worker /**
580*0e209d39SAndroid Build Coastguard Worker * Returns the next resource in a given resource or NULL if there are no more resources
581*0e209d39SAndroid Build Coastguard Worker * to iterate over. Features a fill-in parameter.
582*0e209d39SAndroid Build Coastguard Worker *
583*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle a resource
584*0e209d39SAndroid Build Coastguard Worker * @param fillIn if NULL a new UResourceBundle struct is allocated and must be closed by the caller.
585*0e209d39SAndroid Build Coastguard Worker * Alternatively, you can supply a struct to be filled by this function.
586*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code. You may still get a non NULL result even if an
587*0e209d39SAndroid Build Coastguard Worker * error occurred. Check status instead.
588*0e209d39SAndroid Build Coastguard Worker * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it
589*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
590*0e209d39SAndroid Build Coastguard Worker */
591*0e209d39SAndroid Build Coastguard Worker U_CAPI UResourceBundle* U_EXPORT2
592*0e209d39SAndroid Build Coastguard Worker ures_getNextResource(UResourceBundle *resourceBundle,
593*0e209d39SAndroid Build Coastguard Worker UResourceBundle *fillIn,
594*0e209d39SAndroid Build Coastguard Worker UErrorCode *status);
595*0e209d39SAndroid Build Coastguard Worker
596*0e209d39SAndroid Build Coastguard Worker /**
597*0e209d39SAndroid Build Coastguard Worker * Returns the next string in a given resource or NULL if there are no more resources
598*0e209d39SAndroid Build Coastguard Worker * to iterate over.
599*0e209d39SAndroid Build Coastguard Worker *
600*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle a resource
601*0e209d39SAndroid Build Coastguard Worker * @param len fill in length of the string
602*0e209d39SAndroid Build Coastguard Worker * @param key fill in for key associated with this string. NULL if no key
603*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code. If an error occurred, we may return NULL, but don't
604*0e209d39SAndroid Build Coastguard Worker * count on it. Check status instead!
605*0e209d39SAndroid Build Coastguard Worker * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
606*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
607*0e209d39SAndroid Build Coastguard Worker */
608*0e209d39SAndroid Build Coastguard Worker U_CAPI const UChar* U_EXPORT2
609*0e209d39SAndroid Build Coastguard Worker ures_getNextString(UResourceBundle *resourceBundle,
610*0e209d39SAndroid Build Coastguard Worker int32_t* len,
611*0e209d39SAndroid Build Coastguard Worker const char ** key,
612*0e209d39SAndroid Build Coastguard Worker UErrorCode *status);
613*0e209d39SAndroid Build Coastguard Worker
614*0e209d39SAndroid Build Coastguard Worker /**
615*0e209d39SAndroid Build Coastguard Worker * Returns the resource in a given resource at the specified index. Features a fill-in parameter.
616*0e209d39SAndroid Build Coastguard Worker *
617*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle the resource bundle from which to get a sub-resource
618*0e209d39SAndroid Build Coastguard Worker * @param indexR an index to the wanted resource.
619*0e209d39SAndroid Build Coastguard Worker * @param fillIn if NULL a new UResourceBundle struct is allocated and must be closed by the caller.
620*0e209d39SAndroid Build Coastguard Worker * Alternatively, you can supply a struct to be filled by this function.
621*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code. Don't count on NULL being returned if an error has
622*0e209d39SAndroid Build Coastguard Worker * occurred. Check status instead.
623*0e209d39SAndroid Build Coastguard Worker * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it
624*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
625*0e209d39SAndroid Build Coastguard Worker */
626*0e209d39SAndroid Build Coastguard Worker U_CAPI UResourceBundle* U_EXPORT2
627*0e209d39SAndroid Build Coastguard Worker ures_getByIndex(const UResourceBundle *resourceBundle,
628*0e209d39SAndroid Build Coastguard Worker int32_t indexR,
629*0e209d39SAndroid Build Coastguard Worker UResourceBundle *fillIn,
630*0e209d39SAndroid Build Coastguard Worker UErrorCode *status);
631*0e209d39SAndroid Build Coastguard Worker
632*0e209d39SAndroid Build Coastguard Worker /**
633*0e209d39SAndroid Build Coastguard Worker * Returns the string in a given resource at the specified index.
634*0e209d39SAndroid Build Coastguard Worker *
635*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle a resource
636*0e209d39SAndroid Build Coastguard Worker * @param indexS an index to the wanted string.
637*0e209d39SAndroid Build Coastguard Worker * @param len fill in length of the string
638*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code. If an error occurred, we may return NULL, but don't
639*0e209d39SAndroid Build Coastguard Worker * count on it. Check status instead!
640*0e209d39SAndroid Build Coastguard Worker * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
641*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
642*0e209d39SAndroid Build Coastguard Worker */
643*0e209d39SAndroid Build Coastguard Worker U_CAPI const UChar* U_EXPORT2
644*0e209d39SAndroid Build Coastguard Worker ures_getStringByIndex(const UResourceBundle *resourceBundle,
645*0e209d39SAndroid Build Coastguard Worker int32_t indexS,
646*0e209d39SAndroid Build Coastguard Worker int32_t* len,
647*0e209d39SAndroid Build Coastguard Worker UErrorCode *status);
648*0e209d39SAndroid Build Coastguard Worker
649*0e209d39SAndroid Build Coastguard Worker /**
650*0e209d39SAndroid Build Coastguard Worker * Returns a UTF-8 string from a resource at the specified index.
651*0e209d39SAndroid Build Coastguard Worker * The UTF-8 string may be returnable directly as a pointer, or
652*0e209d39SAndroid Build Coastguard Worker * it may need to be copied, or transformed from UTF-16 using u_strToUTF8()
653*0e209d39SAndroid Build Coastguard Worker * or equivalent.
654*0e209d39SAndroid Build Coastguard Worker *
655*0e209d39SAndroid Build Coastguard Worker * If forceCopy==true, then the string is always written to the dest buffer
656*0e209d39SAndroid Build Coastguard Worker * and dest is returned.
657*0e209d39SAndroid Build Coastguard Worker *
658*0e209d39SAndroid Build Coastguard Worker * If forceCopy==false, then the string is returned as a pointer if possible,
659*0e209d39SAndroid Build Coastguard Worker * without needing a dest buffer (it can be NULL). If the string needs to be
660*0e209d39SAndroid Build Coastguard Worker * copied or transformed, then it may be placed into dest at an arbitrary offset.
661*0e209d39SAndroid Build Coastguard Worker *
662*0e209d39SAndroid Build Coastguard Worker * If the string is to be written to dest, then U_BUFFER_OVERFLOW_ERROR and
663*0e209d39SAndroid Build Coastguard Worker * U_STRING_NOT_TERMINATED_WARNING are set if appropriate, as usual.
664*0e209d39SAndroid Build Coastguard Worker *
665*0e209d39SAndroid Build Coastguard Worker * If the string is transformed from UTF-16, then a conversion error may occur
666*0e209d39SAndroid Build Coastguard Worker * if an unpaired surrogate is encountered. If the function is successful, then
667*0e209d39SAndroid Build Coastguard Worker * the output UTF-8 string is always well-formed.
668*0e209d39SAndroid Build Coastguard Worker *
669*0e209d39SAndroid Build Coastguard Worker * @param resB Resource bundle.
670*0e209d39SAndroid Build Coastguard Worker * @param stringIndex An index to the wanted string.
671*0e209d39SAndroid Build Coastguard Worker * @param dest Destination buffer. Can be NULL only if capacity=*length==0.
672*0e209d39SAndroid Build Coastguard Worker * @param pLength Input: Capacity of destination buffer.
673*0e209d39SAndroid Build Coastguard Worker * Output: Actual length of the UTF-8 string, not counting the
674*0e209d39SAndroid Build Coastguard Worker * terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.
675*0e209d39SAndroid Build Coastguard Worker * Can be NULL, meaning capacity=0 and the string length is not
676*0e209d39SAndroid Build Coastguard Worker * returned to the caller.
677*0e209d39SAndroid Build Coastguard Worker * @param forceCopy If true, then the output string will always be written to
678*0e209d39SAndroid Build Coastguard Worker * dest, with U_BUFFER_OVERFLOW_ERROR and
679*0e209d39SAndroid Build Coastguard Worker * U_STRING_NOT_TERMINATED_WARNING set if appropriate.
680*0e209d39SAndroid Build Coastguard Worker * If false, then the dest buffer may or may not contain a
681*0e209d39SAndroid Build Coastguard Worker * copy of the string. dest may or may not be modified.
682*0e209d39SAndroid Build Coastguard Worker * If a copy needs to be written, then the UErrorCode parameter
683*0e209d39SAndroid Build Coastguard Worker * indicates overflow etc. as usual.
684*0e209d39SAndroid Build Coastguard Worker * @param status Pointer to a standard ICU error code. Its input value must
685*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns
686*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with
687*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.)
688*0e209d39SAndroid Build Coastguard Worker * @return The pointer to the UTF-8 string. It may be dest, or at some offset
689*0e209d39SAndroid Build Coastguard Worker * from dest (only if !forceCopy), or in unrelated memory.
690*0e209d39SAndroid Build Coastguard Worker * Always NUL-terminated unless the string was written to dest and
691*0e209d39SAndroid Build Coastguard Worker * length==capacity (in which case U_STRING_NOT_TERMINATED_WARNING is set).
692*0e209d39SAndroid Build Coastguard Worker *
693*0e209d39SAndroid Build Coastguard Worker * @see ures_getStringByIndex
694*0e209d39SAndroid Build Coastguard Worker * @see u_strToUTF8
695*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.6
696*0e209d39SAndroid Build Coastguard Worker */
697*0e209d39SAndroid Build Coastguard Worker U_CAPI const char * U_EXPORT2
698*0e209d39SAndroid Build Coastguard Worker ures_getUTF8StringByIndex(const UResourceBundle *resB,
699*0e209d39SAndroid Build Coastguard Worker int32_t stringIndex,
700*0e209d39SAndroid Build Coastguard Worker char *dest, int32_t *pLength,
701*0e209d39SAndroid Build Coastguard Worker UBool forceCopy,
702*0e209d39SAndroid Build Coastguard Worker UErrorCode *status);
703*0e209d39SAndroid Build Coastguard Worker
704*0e209d39SAndroid Build Coastguard Worker /**
705*0e209d39SAndroid Build Coastguard Worker * Returns a resource in a given resource that has a given key. This procedure works only with table
706*0e209d39SAndroid Build Coastguard Worker * resources. Features a fill-in parameter.
707*0e209d39SAndroid Build Coastguard Worker *
708*0e209d39SAndroid Build Coastguard Worker * @param resourceBundle a resource
709*0e209d39SAndroid Build Coastguard Worker * @param key a key associated with the wanted resource
710*0e209d39SAndroid Build Coastguard Worker * @param fillIn if NULL a new UResourceBundle struct is allocated and must be closed by the caller.
711*0e209d39SAndroid Build Coastguard Worker * Alternatively, you can supply a struct to be filled by this function.
712*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code.
713*0e209d39SAndroid Build Coastguard Worker * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it
714*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
715*0e209d39SAndroid Build Coastguard Worker */
716*0e209d39SAndroid Build Coastguard Worker U_CAPI UResourceBundle* U_EXPORT2
717*0e209d39SAndroid Build Coastguard Worker ures_getByKey(const UResourceBundle *resourceBundle,
718*0e209d39SAndroid Build Coastguard Worker const char* key,
719*0e209d39SAndroid Build Coastguard Worker UResourceBundle *fillIn,
720*0e209d39SAndroid Build Coastguard Worker UErrorCode *status);
721*0e209d39SAndroid Build Coastguard Worker
722*0e209d39SAndroid Build Coastguard Worker /**
723*0e209d39SAndroid Build Coastguard Worker * Returns a string in a given resource that has a given key. This procedure works only with table
724*0e209d39SAndroid Build Coastguard Worker * resources.
725*0e209d39SAndroid Build Coastguard Worker *
726*0e209d39SAndroid Build Coastguard Worker * @param resB a resource
727*0e209d39SAndroid Build Coastguard Worker * @param key a key associated with the wanted string
728*0e209d39SAndroid Build Coastguard Worker * @param len fill in length of the string
729*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code. If an error occurred, we may return NULL, but don't
730*0e209d39SAndroid Build Coastguard Worker * count on it. Check status instead!
731*0e209d39SAndroid Build Coastguard Worker * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
732*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
733*0e209d39SAndroid Build Coastguard Worker */
734*0e209d39SAndroid Build Coastguard Worker U_CAPI const UChar* U_EXPORT2
735*0e209d39SAndroid Build Coastguard Worker ures_getStringByKey(const UResourceBundle *resB,
736*0e209d39SAndroid Build Coastguard Worker const char* key,
737*0e209d39SAndroid Build Coastguard Worker int32_t* len,
738*0e209d39SAndroid Build Coastguard Worker UErrorCode *status);
739*0e209d39SAndroid Build Coastguard Worker
740*0e209d39SAndroid Build Coastguard Worker /**
741*0e209d39SAndroid Build Coastguard Worker * Returns a UTF-8 string from a resource and a key.
742*0e209d39SAndroid Build Coastguard Worker * This function works only with table resources.
743*0e209d39SAndroid Build Coastguard Worker *
744*0e209d39SAndroid Build Coastguard Worker * The UTF-8 string may be returnable directly as a pointer, or
745*0e209d39SAndroid Build Coastguard Worker * it may need to be copied, or transformed from UTF-16 using u_strToUTF8()
746*0e209d39SAndroid Build Coastguard Worker * or equivalent.
747*0e209d39SAndroid Build Coastguard Worker *
748*0e209d39SAndroid Build Coastguard Worker * If forceCopy==true, then the string is always written to the dest buffer
749*0e209d39SAndroid Build Coastguard Worker * and dest is returned.
750*0e209d39SAndroid Build Coastguard Worker *
751*0e209d39SAndroid Build Coastguard Worker * If forceCopy==false, then the string is returned as a pointer if possible,
752*0e209d39SAndroid Build Coastguard Worker * without needing a dest buffer (it can be NULL). If the string needs to be
753*0e209d39SAndroid Build Coastguard Worker * copied or transformed, then it may be placed into dest at an arbitrary offset.
754*0e209d39SAndroid Build Coastguard Worker *
755*0e209d39SAndroid Build Coastguard Worker * If the string is to be written to dest, then U_BUFFER_OVERFLOW_ERROR and
756*0e209d39SAndroid Build Coastguard Worker * U_STRING_NOT_TERMINATED_WARNING are set if appropriate, as usual.
757*0e209d39SAndroid Build Coastguard Worker *
758*0e209d39SAndroid Build Coastguard Worker * If the string is transformed from UTF-16, then a conversion error may occur
759*0e209d39SAndroid Build Coastguard Worker * if an unpaired surrogate is encountered. If the function is successful, then
760*0e209d39SAndroid Build Coastguard Worker * the output UTF-8 string is always well-formed.
761*0e209d39SAndroid Build Coastguard Worker *
762*0e209d39SAndroid Build Coastguard Worker * @param resB Resource bundle.
763*0e209d39SAndroid Build Coastguard Worker * @param key A key associated with the wanted resource
764*0e209d39SAndroid Build Coastguard Worker * @param dest Destination buffer. Can be NULL only if capacity=*length==0.
765*0e209d39SAndroid Build Coastguard Worker * @param pLength Input: Capacity of destination buffer.
766*0e209d39SAndroid Build Coastguard Worker * Output: Actual length of the UTF-8 string, not counting the
767*0e209d39SAndroid Build Coastguard Worker * terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.
768*0e209d39SAndroid Build Coastguard Worker * Can be NULL, meaning capacity=0 and the string length is not
769*0e209d39SAndroid Build Coastguard Worker * returned to the caller.
770*0e209d39SAndroid Build Coastguard Worker * @param forceCopy If true, then the output string will always be written to
771*0e209d39SAndroid Build Coastguard Worker * dest, with U_BUFFER_OVERFLOW_ERROR and
772*0e209d39SAndroid Build Coastguard Worker * U_STRING_NOT_TERMINATED_WARNING set if appropriate.
773*0e209d39SAndroid Build Coastguard Worker * If false, then the dest buffer may or may not contain a
774*0e209d39SAndroid Build Coastguard Worker * copy of the string. dest may or may not be modified.
775*0e209d39SAndroid Build Coastguard Worker * If a copy needs to be written, then the UErrorCode parameter
776*0e209d39SAndroid Build Coastguard Worker * indicates overflow etc. as usual.
777*0e209d39SAndroid Build Coastguard Worker * @param status Pointer to a standard ICU error code. Its input value must
778*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns
779*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with
780*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.)
781*0e209d39SAndroid Build Coastguard Worker * @return The pointer to the UTF-8 string. It may be dest, or at some offset
782*0e209d39SAndroid Build Coastguard Worker * from dest (only if !forceCopy), or in unrelated memory.
783*0e209d39SAndroid Build Coastguard Worker * Always NUL-terminated unless the string was written to dest and
784*0e209d39SAndroid Build Coastguard Worker * length==capacity (in which case U_STRING_NOT_TERMINATED_WARNING is set).
785*0e209d39SAndroid Build Coastguard Worker *
786*0e209d39SAndroid Build Coastguard Worker * @see ures_getStringByKey
787*0e209d39SAndroid Build Coastguard Worker * @see u_strToUTF8
788*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.6
789*0e209d39SAndroid Build Coastguard Worker */
790*0e209d39SAndroid Build Coastguard Worker U_CAPI const char * U_EXPORT2
791*0e209d39SAndroid Build Coastguard Worker ures_getUTF8StringByKey(const UResourceBundle *resB,
792*0e209d39SAndroid Build Coastguard Worker const char *key,
793*0e209d39SAndroid Build Coastguard Worker char *dest, int32_t *pLength,
794*0e209d39SAndroid Build Coastguard Worker UBool forceCopy,
795*0e209d39SAndroid Build Coastguard Worker UErrorCode *status);
796*0e209d39SAndroid Build Coastguard Worker
797*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API
798*0e209d39SAndroid Build Coastguard Worker #include "unicode/unistr.h"
799*0e209d39SAndroid Build Coastguard Worker
800*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN
801*0e209d39SAndroid Build Coastguard Worker /**
802*0e209d39SAndroid Build Coastguard Worker * Returns the string value from a string resource bundle.
803*0e209d39SAndroid Build Coastguard Worker *
804*0e209d39SAndroid Build Coastguard Worker * @param resB a resource, should have type URES_STRING
805*0e209d39SAndroid Build Coastguard Worker * @param status: fills in the outgoing error code
806*0e209d39SAndroid Build Coastguard Worker * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
807*0e209d39SAndroid Build Coastguard Worker * could be a non-failing error
808*0e209d39SAndroid Build Coastguard Worker * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
809*0e209d39SAndroid Build Coastguard Worker * @return The string value, or a bogus string if there is a failure UErrorCode.
810*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
811*0e209d39SAndroid Build Coastguard Worker */
812*0e209d39SAndroid Build Coastguard Worker inline UnicodeString
ures_getUnicodeString(const UResourceBundle * resB,UErrorCode * status)813*0e209d39SAndroid Build Coastguard Worker ures_getUnicodeString(const UResourceBundle *resB, UErrorCode* status) {
814*0e209d39SAndroid Build Coastguard Worker UnicodeString result;
815*0e209d39SAndroid Build Coastguard Worker int32_t len = 0;
816*0e209d39SAndroid Build Coastguard Worker const char16_t *r = ConstChar16Ptr(ures_getString(resB, &len, status));
817*0e209d39SAndroid Build Coastguard Worker if(U_SUCCESS(*status)) {
818*0e209d39SAndroid Build Coastguard Worker result.setTo(true, r, len);
819*0e209d39SAndroid Build Coastguard Worker } else {
820*0e209d39SAndroid Build Coastguard Worker result.setToBogus();
821*0e209d39SAndroid Build Coastguard Worker }
822*0e209d39SAndroid Build Coastguard Worker return result;
823*0e209d39SAndroid Build Coastguard Worker }
824*0e209d39SAndroid Build Coastguard Worker
825*0e209d39SAndroid Build Coastguard Worker /**
826*0e209d39SAndroid Build Coastguard Worker * Returns the next string in a resource, or an empty string if there are no more resources
827*0e209d39SAndroid Build Coastguard Worker * to iterate over.
828*0e209d39SAndroid Build Coastguard Worker * Use ures_getNextString() instead to distinguish between
829*0e209d39SAndroid Build Coastguard Worker * the end of the iteration and a real empty string value.
830*0e209d39SAndroid Build Coastguard Worker *
831*0e209d39SAndroid Build Coastguard Worker * @param resB a resource
832*0e209d39SAndroid Build Coastguard Worker * @param key fill in for key associated with this string
833*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code
834*0e209d39SAndroid Build Coastguard Worker * @return The string value, or a bogus string if there is a failure UErrorCode.
835*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
836*0e209d39SAndroid Build Coastguard Worker */
837*0e209d39SAndroid Build Coastguard Worker inline UnicodeString
ures_getNextUnicodeString(UResourceBundle * resB,const char ** key,UErrorCode * status)838*0e209d39SAndroid Build Coastguard Worker ures_getNextUnicodeString(UResourceBundle *resB, const char ** key, UErrorCode* status) {
839*0e209d39SAndroid Build Coastguard Worker UnicodeString result;
840*0e209d39SAndroid Build Coastguard Worker int32_t len = 0;
841*0e209d39SAndroid Build Coastguard Worker const char16_t* r = ConstChar16Ptr(ures_getNextString(resB, &len, key, status));
842*0e209d39SAndroid Build Coastguard Worker if(U_SUCCESS(*status)) {
843*0e209d39SAndroid Build Coastguard Worker result.setTo(true, r, len);
844*0e209d39SAndroid Build Coastguard Worker } else {
845*0e209d39SAndroid Build Coastguard Worker result.setToBogus();
846*0e209d39SAndroid Build Coastguard Worker }
847*0e209d39SAndroid Build Coastguard Worker return result;
848*0e209d39SAndroid Build Coastguard Worker }
849*0e209d39SAndroid Build Coastguard Worker
850*0e209d39SAndroid Build Coastguard Worker /**
851*0e209d39SAndroid Build Coastguard Worker * Returns the string in a given resource array or table at the specified index.
852*0e209d39SAndroid Build Coastguard Worker *
853*0e209d39SAndroid Build Coastguard Worker * @param resB a resource
854*0e209d39SAndroid Build Coastguard Worker * @param indexS an index to the wanted string.
855*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code
856*0e209d39SAndroid Build Coastguard Worker * @return The string value, or a bogus string if there is a failure UErrorCode.
857*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
858*0e209d39SAndroid Build Coastguard Worker */
859*0e209d39SAndroid Build Coastguard Worker inline UnicodeString
ures_getUnicodeStringByIndex(const UResourceBundle * resB,int32_t indexS,UErrorCode * status)860*0e209d39SAndroid Build Coastguard Worker ures_getUnicodeStringByIndex(const UResourceBundle *resB, int32_t indexS, UErrorCode* status) {
861*0e209d39SAndroid Build Coastguard Worker UnicodeString result;
862*0e209d39SAndroid Build Coastguard Worker int32_t len = 0;
863*0e209d39SAndroid Build Coastguard Worker const char16_t* r = ConstChar16Ptr(ures_getStringByIndex(resB, indexS, &len, status));
864*0e209d39SAndroid Build Coastguard Worker if(U_SUCCESS(*status)) {
865*0e209d39SAndroid Build Coastguard Worker result.setTo(true, r, len);
866*0e209d39SAndroid Build Coastguard Worker } else {
867*0e209d39SAndroid Build Coastguard Worker result.setToBogus();
868*0e209d39SAndroid Build Coastguard Worker }
869*0e209d39SAndroid Build Coastguard Worker return result;
870*0e209d39SAndroid Build Coastguard Worker }
871*0e209d39SAndroid Build Coastguard Worker
872*0e209d39SAndroid Build Coastguard Worker /**
873*0e209d39SAndroid Build Coastguard Worker * Returns a string in a resource that has a given key.
874*0e209d39SAndroid Build Coastguard Worker * This procedure works only with table resources.
875*0e209d39SAndroid Build Coastguard Worker *
876*0e209d39SAndroid Build Coastguard Worker * @param resB a resource
877*0e209d39SAndroid Build Coastguard Worker * @param key a key associated with the wanted string
878*0e209d39SAndroid Build Coastguard Worker * @param status fills in the outgoing error code
879*0e209d39SAndroid Build Coastguard Worker * @return The string value, or a bogus string if there is a failure UErrorCode.
880*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0
881*0e209d39SAndroid Build Coastguard Worker */
882*0e209d39SAndroid Build Coastguard Worker inline UnicodeString
ures_getUnicodeStringByKey(const UResourceBundle * resB,const char * key,UErrorCode * status)883*0e209d39SAndroid Build Coastguard Worker ures_getUnicodeStringByKey(const UResourceBundle *resB, const char* key, UErrorCode* status) {
884*0e209d39SAndroid Build Coastguard Worker UnicodeString result;
885*0e209d39SAndroid Build Coastguard Worker int32_t len = 0;
886*0e209d39SAndroid Build Coastguard Worker const char16_t* r = ConstChar16Ptr(ures_getStringByKey(resB, key, &len, status));
887*0e209d39SAndroid Build Coastguard Worker if(U_SUCCESS(*status)) {
888*0e209d39SAndroid Build Coastguard Worker result.setTo(true, r, len);
889*0e209d39SAndroid Build Coastguard Worker } else {
890*0e209d39SAndroid Build Coastguard Worker result.setToBogus();
891*0e209d39SAndroid Build Coastguard Worker }
892*0e209d39SAndroid Build Coastguard Worker return result;
893*0e209d39SAndroid Build Coastguard Worker }
894*0e209d39SAndroid Build Coastguard Worker
895*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END
896*0e209d39SAndroid Build Coastguard Worker
897*0e209d39SAndroid Build Coastguard Worker #endif
898*0e209d39SAndroid Build Coastguard Worker
899*0e209d39SAndroid Build Coastguard Worker /**
900*0e209d39SAndroid Build Coastguard Worker * Create a string enumerator, owned by the caller, of all locales located within
901*0e209d39SAndroid Build Coastguard Worker * the specified resource tree.
902*0e209d39SAndroid Build Coastguard Worker * @param packageName name of the tree, such as (NULL) or U_ICUDATA_ALIAS or or "ICUDATA-coll"
903*0e209d39SAndroid Build Coastguard Worker * This call is similar to uloc_getAvailable().
904*0e209d39SAndroid Build Coastguard Worker * @param status error code
905*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.2
906*0e209d39SAndroid Build Coastguard Worker */
907*0e209d39SAndroid Build Coastguard Worker U_CAPI UEnumeration* U_EXPORT2
908*0e209d39SAndroid Build Coastguard Worker ures_openAvailableLocales(const char *packageName, UErrorCode *status);
909*0e209d39SAndroid Build Coastguard Worker
910*0e209d39SAndroid Build Coastguard Worker
911*0e209d39SAndroid Build Coastguard Worker #endif /*_URES*/
912*0e209d39SAndroid Build Coastguard Worker /*eof*/
913