xref: /aosp_15_r20/external/icu/libicu/cts_headers/uresimp.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
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) 2000-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 
10*0e209d39SAndroid Build Coastguard Worker #ifndef URESIMP_H
11*0e209d39SAndroid Build Coastguard Worker #define URESIMP_H
12*0e209d39SAndroid Build Coastguard Worker 
13*0e209d39SAndroid Build Coastguard Worker #include "unicode/ures.h"
14*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h"
15*0e209d39SAndroid Build Coastguard Worker 
16*0e209d39SAndroid Build Coastguard Worker #include "uresdata.h"
17*0e209d39SAndroid Build Coastguard Worker 
18*0e209d39SAndroid Build Coastguard Worker #define kRootLocaleName         "root"
19*0e209d39SAndroid Build Coastguard Worker #define kPoolBundleName         "pool"
20*0e209d39SAndroid Build Coastguard Worker 
21*0e209d39SAndroid Build Coastguard Worker /*
22*0e209d39SAndroid Build Coastguard Worker  The default minor version and the version separator must be exactly one
23*0e209d39SAndroid Build Coastguard Worker  character long.
24*0e209d39SAndroid Build Coastguard Worker */
25*0e209d39SAndroid Build Coastguard Worker 
26*0e209d39SAndroid Build Coastguard Worker #define kDefaultMinorVersion    "0"
27*0e209d39SAndroid Build Coastguard Worker #define kVersionSeparator       "."
28*0e209d39SAndroid Build Coastguard Worker #define kVersionTag             "Version"
29*0e209d39SAndroid Build Coastguard Worker 
30*0e209d39SAndroid Build Coastguard Worker #define MAGIC1 19700503
31*0e209d39SAndroid Build Coastguard Worker #define MAGIC2 19641227
32*0e209d39SAndroid Build Coastguard Worker 
33*0e209d39SAndroid Build Coastguard Worker #define URES_MAX_ALIAS_LEVEL 256
34*0e209d39SAndroid Build Coastguard Worker 
35*0e209d39SAndroid Build Coastguard Worker #define EMPTY_SET 0x2205
36*0e209d39SAndroid Build Coastguard Worker 
37*0e209d39SAndroid Build Coastguard Worker struct UResourceDataEntry;
38*0e209d39SAndroid Build Coastguard Worker typedef struct UResourceDataEntry UResourceDataEntry;
39*0e209d39SAndroid Build Coastguard Worker 
40*0e209d39SAndroid Build Coastguard Worker /*
41*0e209d39SAndroid Build Coastguard Worker  * Note: If we wanted to make this structure smaller, then we could try
42*0e209d39SAndroid Build Coastguard Worker  * to use one UResourceDataEntry pointer for fAlias and fPool, with a separate
43*0e209d39SAndroid Build Coastguard Worker  * flag to distinguish whether this struct is for a real bundle with a pool,
44*0e209d39SAndroid Build Coastguard Worker  * or for an alias entry for which we won't use the pool after loading.
45*0e209d39SAndroid Build Coastguard Worker  */
46*0e209d39SAndroid Build Coastguard Worker struct UResourceDataEntry {
47*0e209d39SAndroid Build Coastguard Worker     char *fName; /* name of the locale for bundle - still to decide whether it is original or fallback */
48*0e209d39SAndroid Build Coastguard Worker     char *fPath; /* path to bundle - used for distinguishing between resources with the same name */
49*0e209d39SAndroid Build Coastguard Worker     UResourceDataEntry *fParent; /*next resource in fallback chain*/
50*0e209d39SAndroid Build Coastguard Worker     UResourceDataEntry *fAlias;
51*0e209d39SAndroid Build Coastguard Worker     UResourceDataEntry *fPool;
52*0e209d39SAndroid Build Coastguard Worker     ResourceData fData; /* data for low level access */
53*0e209d39SAndroid Build Coastguard Worker     char fNameBuffer[3]; /* A small buffer of free space for fName. The free space is due to struct padding. */
54*0e209d39SAndroid Build Coastguard Worker     uint32_t fCountExisting; /* how much is this resource used */
55*0e209d39SAndroid Build Coastguard Worker     UErrorCode fBogus;
56*0e209d39SAndroid Build Coastguard Worker     /* int32_t fHashKey;*/ /* for faster access in the hashtable */
57*0e209d39SAndroid Build Coastguard Worker };
58*0e209d39SAndroid Build Coastguard Worker 
59*0e209d39SAndroid Build Coastguard Worker #define RES_BUFSIZE 64
60*0e209d39SAndroid Build Coastguard Worker #define RES_PATH_SEPARATOR   '/'
61*0e209d39SAndroid Build Coastguard Worker #define RES_PATH_SEPARATOR_S   "/"
62*0e209d39SAndroid Build Coastguard Worker 
63*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 ures_initStackObject(UResourceBundle* resB);
64*0e209d39SAndroid Build Coastguard Worker 
65*0e209d39SAndroid Build Coastguard Worker #ifdef __cplusplus
66*0e209d39SAndroid Build Coastguard Worker 
67*0e209d39SAndroid Build Coastguard Worker struct UResourceBundle {
68*0e209d39SAndroid Build Coastguard Worker     const char *fKey; /*tag*/
69*0e209d39SAndroid Build Coastguard Worker     /**
70*0e209d39SAndroid Build Coastguard Worker      * The dataEntry for the actual locale in which this item lives.
71*0e209d39SAndroid Build Coastguard Worker      * Used for accessing the item's data.
72*0e209d39SAndroid Build Coastguard Worker      * Non-const pointer for reference counting via entryIncrease().
73*0e209d39SAndroid Build Coastguard Worker      */
74*0e209d39SAndroid Build Coastguard Worker     UResourceDataEntry *fData; /*for low-level access*/
75*0e209d39SAndroid Build Coastguard Worker     char *fVersion;
76*0e209d39SAndroid Build Coastguard Worker     /**
77*0e209d39SAndroid Build Coastguard Worker      * The dataEntry for the valid locale.
78*0e209d39SAndroid Build Coastguard Worker      * Used for /LOCALE/path alias resolution that starts back from the valid locale,
79*0e209d39SAndroid Build Coastguard Worker      * rather than from the actual locale of this item which might live in
80*0e209d39SAndroid Build Coastguard Worker      * an ancestor bundle.
81*0e209d39SAndroid Build Coastguard Worker      */
82*0e209d39SAndroid Build Coastguard Worker     UResourceDataEntry *fValidLocaleDataEntry;
83*0e209d39SAndroid Build Coastguard Worker     char *fResPath; /* full path to the resource: "zh_TW/CollationElements/Sequence" */
84*0e209d39SAndroid Build Coastguard Worker     char fResBuf[RES_BUFSIZE];
85*0e209d39SAndroid Build Coastguard Worker     int32_t fResPathLen;
86*0e209d39SAndroid Build Coastguard Worker     Resource fRes;
87*0e209d39SAndroid Build Coastguard Worker     UBool fHasFallback;
88*0e209d39SAndroid Build Coastguard Worker     UBool fIsTopLevel;
89*0e209d39SAndroid Build Coastguard Worker     uint32_t fMagic1;   /* For determining if it's a stack object */
90*0e209d39SAndroid Build Coastguard Worker     uint32_t fMagic2;   /* For determining if it's a stack object */
91*0e209d39SAndroid Build Coastguard Worker     int32_t fIndex;
92*0e209d39SAndroid Build Coastguard Worker     int32_t fSize;
93*0e209d39SAndroid Build Coastguard Worker 
getResDataUResourceBundle94*0e209d39SAndroid Build Coastguard Worker     inline const ResourceData &getResData() const { return fData->fData; }
95*0e209d39SAndroid Build Coastguard Worker };
96*0e209d39SAndroid Build Coastguard Worker 
97*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN
98*0e209d39SAndroid Build Coastguard Worker 
99*0e209d39SAndroid Build Coastguard Worker /**
100*0e209d39SAndroid Build Coastguard Worker  * \class StackUResourceBundle
101*0e209d39SAndroid Build Coastguard Worker  * "Smart pointer" like class, closes a UResourceBundle via ures_close().
102*0e209d39SAndroid Build Coastguard Worker  *
103*0e209d39SAndroid Build Coastguard Worker  * This code:
104*0e209d39SAndroid Build Coastguard Worker  *
105*0e209d39SAndroid Build Coastguard Worker  *   StackUResourceBundle bundle;
106*0e209d39SAndroid Build Coastguard Worker  *   foo(bundle.getAlias());
107*0e209d39SAndroid Build Coastguard Worker  *
108*0e209d39SAndroid Build Coastguard Worker  * Is equivalent to this code:
109*0e209d39SAndroid Build Coastguard Worker  *
110*0e209d39SAndroid Build Coastguard Worker  *   UResourceBundle bundle;
111*0e209d39SAndroid Build Coastguard Worker  *   ures_initStackObject(&bundle);
112*0e209d39SAndroid Build Coastguard Worker  *   foo(&bundle);
113*0e209d39SAndroid Build Coastguard Worker  *   ures_close(&bundle);
114*0e209d39SAndroid Build Coastguard Worker  *
115*0e209d39SAndroid Build Coastguard Worker  * @see LocalUResourceBundlePointer
116*0e209d39SAndroid Build Coastguard Worker  * @internal
117*0e209d39SAndroid Build Coastguard Worker  */
118*0e209d39SAndroid Build Coastguard Worker class U_COMMON_API StackUResourceBundle {
119*0e209d39SAndroid Build Coastguard Worker public:
120*0e209d39SAndroid Build Coastguard Worker     // No heap allocation. Use only on the stack.
121*0e209d39SAndroid Build Coastguard Worker     static void* U_EXPORT2 operator new(size_t) noexcept = delete;
122*0e209d39SAndroid Build Coastguard Worker     static void* U_EXPORT2 operator new[](size_t) noexcept = delete;
123*0e209d39SAndroid Build Coastguard Worker #if U_HAVE_PLACEMENT_NEW
124*0e209d39SAndroid Build Coastguard Worker     static void* U_EXPORT2 operator new(size_t, void*) noexcept = delete;
125*0e209d39SAndroid Build Coastguard Worker #endif
126*0e209d39SAndroid Build Coastguard Worker 
127*0e209d39SAndroid Build Coastguard Worker     StackUResourceBundle();
128*0e209d39SAndroid Build Coastguard Worker     ~StackUResourceBundle();
129*0e209d39SAndroid Build Coastguard Worker 
getAlias()130*0e209d39SAndroid Build Coastguard Worker     UResourceBundle* getAlias() { return &bundle; }
131*0e209d39SAndroid Build Coastguard Worker 
ref()132*0e209d39SAndroid Build Coastguard Worker     UResourceBundle& ref() { return bundle; }
ref()133*0e209d39SAndroid Build Coastguard Worker     const UResourceBundle& ref() const { return bundle; }
134*0e209d39SAndroid Build Coastguard Worker 
135*0e209d39SAndroid Build Coastguard Worker     StackUResourceBundle(const StackUResourceBundle&) = delete;
136*0e209d39SAndroid Build Coastguard Worker     StackUResourceBundle& operator=(const StackUResourceBundle&) = delete;
137*0e209d39SAndroid Build Coastguard Worker 
138*0e209d39SAndroid Build Coastguard Worker     StackUResourceBundle(StackUResourceBundle&&) = delete;
139*0e209d39SAndroid Build Coastguard Worker     StackUResourceBundle& operator=(StackUResourceBundle&&) = delete;
140*0e209d39SAndroid Build Coastguard Worker 
141*0e209d39SAndroid Build Coastguard Worker private:
142*0e209d39SAndroid Build Coastguard Worker     UResourceBundle bundle;
143*0e209d39SAndroid Build Coastguard Worker };
144*0e209d39SAndroid Build Coastguard Worker 
145*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END
146*0e209d39SAndroid Build Coastguard Worker 
147*0e209d39SAndroid Build Coastguard Worker #endif  /* __cplusplus */
148*0e209d39SAndroid Build Coastguard Worker 
149*0e209d39SAndroid Build Coastguard Worker /**
150*0e209d39SAndroid Build Coastguard Worker  * Opens a resource bundle for the locale;
151*0e209d39SAndroid Build Coastguard Worker  * if there is not even a base language bundle, then loads the root bundle;
152*0e209d39SAndroid Build Coastguard Worker  * never falls back to the default locale.
153*0e209d39SAndroid Build Coastguard Worker  *
154*0e209d39SAndroid Build Coastguard Worker  * This is used for algorithms that have good pan-Unicode default behavior,
155*0e209d39SAndroid Build Coastguard Worker  * such as case mappings, collation, and segmentation (BreakIterator).
156*0e209d39SAndroid Build Coastguard Worker  */
157*0e209d39SAndroid Build Coastguard Worker U_CAPI UResourceBundle* U_EXPORT2
158*0e209d39SAndroid Build Coastguard Worker ures_openNoDefault(const char* path, const char* localeID, UErrorCode* status);
159*0e209d39SAndroid Build Coastguard Worker 
160*0e209d39SAndroid Build Coastguard Worker /* Some getters used by the copy constructor */
161*0e209d39SAndroid Build Coastguard Worker U_CFUNC const char* ures_getName(const UResourceBundle* resB);
162*0e209d39SAndroid Build Coastguard Worker #ifdef URES_DEBUG
163*0e209d39SAndroid Build Coastguard Worker U_CFUNC const char* ures_getPath(const UResourceBundle* resB);
164*0e209d39SAndroid Build Coastguard Worker /**
165*0e209d39SAndroid Build Coastguard Worker  * If anything was in the RB cache, dump it to the screen.
166*0e209d39SAndroid Build Coastguard Worker  * @return true if there was anything into the cache
167*0e209d39SAndroid Build Coastguard Worker  */
168*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 ures_dumpCacheContents(void);
169*0e209d39SAndroid Build Coastguard Worker #endif
170*0e209d39SAndroid Build Coastguard Worker 
171*0e209d39SAndroid Build Coastguard Worker /* Candidates for export */
172*0e209d39SAndroid Build Coastguard Worker U_CFUNC UResourceBundle *ures_copyResb(UResourceBundle *r, const UResourceBundle *original, UErrorCode *status);
173*0e209d39SAndroid Build Coastguard Worker 
174*0e209d39SAndroid Build Coastguard Worker /**
175*0e209d39SAndroid Build Coastguard Worker  * Returns a resource that can be located using the pathToResource argument. One needs optional package, locale
176*0e209d39SAndroid Build Coastguard Worker  * and path inside the locale, for example: "/myData/en/zoneStrings/3". Keys and indexes are supported. Keys
177*0e209d39SAndroid Build Coastguard Worker  * need to reference data in named structures, while indexes can reference both named and anonymous resources.
178*0e209d39SAndroid Build Coastguard Worker  * Features a fill-in parameter.
179*0e209d39SAndroid Build Coastguard Worker  *
180*0e209d39SAndroid Build Coastguard Worker  * Note, this function does NOT have a syntax for specifying items within a tree.  May want to consider a
181*0e209d39SAndroid Build Coastguard Worker  * syntax that delineates between package/tree and resource.
182*0e209d39SAndroid Build Coastguard Worker  *
183*0e209d39SAndroid Build Coastguard Worker  * @param pathToResource    a path that will lead to the requested resource
184*0e209d39SAndroid Build Coastguard Worker  * @param fillIn            if NULL a new UResourceBundle struct is allocated and must be deleted by the caller.
185*0e209d39SAndroid Build Coastguard Worker  *                          Alternatively, you can supply a struct to be filled by this function.
186*0e209d39SAndroid Build Coastguard Worker  * @param status            fills in the outgoing error code.
187*0e209d39SAndroid Build Coastguard Worker  * @return                  a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it
188*0e209d39SAndroid Build Coastguard Worker  */
189*0e209d39SAndroid Build Coastguard Worker U_CAPI UResourceBundle* U_EXPORT2
190*0e209d39SAndroid Build Coastguard Worker ures_findResource(const char* pathToResource,
191*0e209d39SAndroid Build Coastguard Worker                   UResourceBundle *fillIn, UErrorCode *status);
192*0e209d39SAndroid Build Coastguard Worker 
193*0e209d39SAndroid Build Coastguard Worker /**
194*0e209d39SAndroid Build Coastguard Worker  * Returns a sub resource that can be located using the pathToResource argument. One needs a path inside
195*0e209d39SAndroid Build Coastguard Worker  * the supplied resource, for example, if you have "en_US" resource bundle opened, you might ask for
196*0e209d39SAndroid Build Coastguard Worker  * "zoneStrings/3". Keys and indexes are supported. Keys
197*0e209d39SAndroid Build Coastguard Worker  * need to reference data in named structures, while indexes can reference both
198*0e209d39SAndroid Build Coastguard Worker  * named and anonymous resources.
199*0e209d39SAndroid Build Coastguard Worker  * Features a fill-in parameter.
200*0e209d39SAndroid Build Coastguard Worker  *
201*0e209d39SAndroid Build Coastguard Worker  * @param resourceBundle    a resource
202*0e209d39SAndroid Build Coastguard Worker  * @param pathToResource    a path that will lead to the requested resource
203*0e209d39SAndroid Build Coastguard Worker  * @param fillIn            if NULL a new UResourceBundle struct is allocated and must be deleted by the caller.
204*0e209d39SAndroid Build Coastguard Worker  *                          Alternatively, you can supply a struct to be filled by this function.
205*0e209d39SAndroid Build Coastguard Worker  * @param status            fills in the outgoing error code.
206*0e209d39SAndroid Build Coastguard Worker  * @return                  a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it
207*0e209d39SAndroid Build Coastguard Worker  */
208*0e209d39SAndroid Build Coastguard Worker U_CAPI UResourceBundle* U_EXPORT2
209*0e209d39SAndroid Build Coastguard Worker ures_findSubResource(const UResourceBundle *resB,
210*0e209d39SAndroid Build Coastguard Worker                      char* pathToResource,
211*0e209d39SAndroid Build Coastguard Worker                      UResourceBundle *fillIn, UErrorCode *status);
212*0e209d39SAndroid Build Coastguard Worker 
213*0e209d39SAndroid Build Coastguard Worker /**
214*0e209d39SAndroid Build Coastguard Worker  * Returns a functionally equivalent locale (considering keywords) for the specified keyword.
215*0e209d39SAndroid Build Coastguard Worker  * @param result fillin for the equivalent locale
216*0e209d39SAndroid Build Coastguard Worker  * @param resultCapacity capacity of the fillin buffer
217*0e209d39SAndroid Build Coastguard Worker  * @param path path to the tree, or NULL for ICU data
218*0e209d39SAndroid Build Coastguard Worker  * @param resName top level resource. Example: "collations"
219*0e209d39SAndroid Build Coastguard Worker  * @param keyword locale keyword. Example: "collation"
220*0e209d39SAndroid Build Coastguard Worker  * @param locid The requested locale
221*0e209d39SAndroid Build Coastguard Worker  * @param isAvailable If non-null, pointer to fillin parameter that indicates whether the
222*0e209d39SAndroid Build Coastguard Worker  * requested locale was available. The locale is defined as 'available' if it physically
223*0e209d39SAndroid Build Coastguard Worker  * exists within the specified tree.
224*0e209d39SAndroid Build Coastguard Worker  * @param omitDefault if true, omit keyword and value if default. 'de_DE\@collation=standard' -> 'de_DE'
225*0e209d39SAndroid Build Coastguard Worker  * @param status error code
226*0e209d39SAndroid Build Coastguard Worker  * @return  the actual buffer size needed for the full locale.  If it's greater
227*0e209d39SAndroid Build Coastguard Worker  * than resultCapacity, the returned full name will be truncated and an error code will be returned.
228*0e209d39SAndroid Build Coastguard Worker  */
229*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
230*0e209d39SAndroid Build Coastguard Worker ures_getFunctionalEquivalent(char *result, int32_t resultCapacity,
231*0e209d39SAndroid Build Coastguard Worker                              const char *path, const char *resName, const char *keyword, const char *locid,
232*0e209d39SAndroid Build Coastguard Worker                              UBool *isAvailable, UBool omitDefault, UErrorCode *status);
233*0e209d39SAndroid Build Coastguard Worker 
234*0e209d39SAndroid Build Coastguard Worker /**
235*0e209d39SAndroid Build Coastguard Worker  * Given a tree path and keyword, return a string enumeration of all possible values for that keyword.
236*0e209d39SAndroid Build Coastguard Worker  * @param path path to the tree, or NULL for ICU data
237*0e209d39SAndroid Build Coastguard Worker  * @param keyword a particular keyword to consider, must match a top level resource name
238*0e209d39SAndroid Build Coastguard Worker  * within the tree.
239*0e209d39SAndroid Build Coastguard Worker  * @param status error code
240*0e209d39SAndroid Build Coastguard Worker  */
241*0e209d39SAndroid Build Coastguard Worker U_CAPI UEnumeration* U_EXPORT2
242*0e209d39SAndroid Build Coastguard Worker ures_getKeywordValues(const char *path, const char *keyword, UErrorCode *status);
243*0e209d39SAndroid Build Coastguard Worker 
244*0e209d39SAndroid Build Coastguard Worker 
245*0e209d39SAndroid Build Coastguard Worker /**
246*0e209d39SAndroid Build Coastguard Worker  * Get a resource with multi-level fallback. Normally only the top level resources will
247*0e209d39SAndroid Build Coastguard Worker  * fallback to its parent. This performs fallback on subresources. For example, when a table
248*0e209d39SAndroid Build Coastguard Worker  * is defined in a resource bundle and a parent resource bundle, normally no fallback occurs
249*0e209d39SAndroid Build Coastguard Worker  * on the sub-resources because the table is defined in the current resource bundle, but this
250*0e209d39SAndroid Build Coastguard Worker  * function can perform fallback on the sub-resources of the table.
251*0e209d39SAndroid Build Coastguard Worker  * @param resB              a resource
252*0e209d39SAndroid Build Coastguard Worker  * @param inKey             a key associated with the requested resource
253*0e209d39SAndroid Build Coastguard Worker  * @param fillIn            if NULL a new UResourceBundle struct is allocated and must be deleted by the caller.
254*0e209d39SAndroid Build Coastguard Worker  *                          Alternatively, you can supply a struct to be filled by this function.
255*0e209d39SAndroid Build Coastguard Worker  * @param status: fills in the outgoing error code
256*0e209d39SAndroid Build Coastguard Worker  *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
257*0e209d39SAndroid Build Coastguard Worker  *                could be a non-failing error
258*0e209d39SAndroid Build Coastguard Worker  *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
259*0e209d39SAndroid Build Coastguard Worker  * @return                  a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it
260*0e209d39SAndroid Build Coastguard Worker  */
261*0e209d39SAndroid Build Coastguard Worker U_CAPI UResourceBundle* U_EXPORT2
262*0e209d39SAndroid Build Coastguard Worker ures_getByKeyWithFallback(const UResourceBundle *resB,
263*0e209d39SAndroid Build Coastguard Worker                           const char* inKey,
264*0e209d39SAndroid Build Coastguard Worker                           UResourceBundle *fillIn,
265*0e209d39SAndroid Build Coastguard Worker                           UErrorCode *status);
266*0e209d39SAndroid Build Coastguard Worker 
267*0e209d39SAndroid Build Coastguard Worker /**
268*0e209d39SAndroid Build Coastguard Worker  * Get a String with multi-level fallback. Normally only the top level resources will
269*0e209d39SAndroid Build Coastguard Worker  * fallback to its parent. This performs fallback on subresources. For example, when a table
270*0e209d39SAndroid Build Coastguard Worker  * is defined in a resource bundle and a parent resource bundle, normally no fallback occurs
271*0e209d39SAndroid Build Coastguard Worker  * on the sub-resources because the table is defined in the current resource bundle, but this
272*0e209d39SAndroid Build Coastguard Worker  * function can perform fallback on the sub-resources of the table.
273*0e209d39SAndroid Build Coastguard Worker  * @param resB              a resource
274*0e209d39SAndroid Build Coastguard Worker  * @param inKey             a key associated with the requested resource
275*0e209d39SAndroid Build Coastguard Worker  * @param len               if not NULL, used to return the length of the string
276*0e209d39SAndroid Build Coastguard Worker  * @param status: fills in the outgoing error code
277*0e209d39SAndroid Build Coastguard Worker  *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
278*0e209d39SAndroid Build Coastguard Worker  *                could be a non-failing error
279*0e209d39SAndroid Build Coastguard Worker  *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
280*0e209d39SAndroid Build Coastguard Worker  * @return returns a pointer to a zero-terminated UChar array which lives in a
281*0e209d39SAndroid Build Coastguard Worker  *         memory mapped/DLL file.
282*0e209d39SAndroid Build Coastguard Worker  */
283*0e209d39SAndroid Build Coastguard Worker U_CAPI const UChar* U_EXPORT2
284*0e209d39SAndroid Build Coastguard Worker ures_getStringByKeyWithFallback(const UResourceBundle *resB,
285*0e209d39SAndroid Build Coastguard Worker                           const char* inKey,
286*0e209d39SAndroid Build Coastguard Worker                           int32_t* len,
287*0e209d39SAndroid Build Coastguard Worker                           UErrorCode *status);
288*0e209d39SAndroid Build Coastguard Worker 
289*0e209d39SAndroid Build Coastguard Worker #ifdef __cplusplus
290*0e209d39SAndroid Build Coastguard Worker 
291*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
292*0e209d39SAndroid Build Coastguard Worker ures_getValueWithFallback(const UResourceBundle *bundle, const char *path,
293*0e209d39SAndroid Build Coastguard Worker                           UResourceBundle *tempFillIn,
294*0e209d39SAndroid Build Coastguard Worker                           icu::ResourceDataValue &value, UErrorCode &errorCode);
295*0e209d39SAndroid Build Coastguard Worker 
296*0e209d39SAndroid Build Coastguard Worker /**
297*0e209d39SAndroid Build Coastguard Worker  * Locates the resource specified by `path` in the resource bundle specified by `bundle` (performing any
298*0e209d39SAndroid Build Coastguard Worker  * necessary fallback and following any aliases) and calls the specified `sink`'s `put()` method with that
299*0e209d39SAndroid Build Coastguard Worker  * resource.  Then walks the bundle's parent chain, calling `put()` on the sink for each item in the
300*0e209d39SAndroid Build Coastguard Worker  * parent chain.
301*0e209d39SAndroid Build Coastguard Worker  * @param bundle The bundle to search
302*0e209d39SAndroid Build Coastguard Worker  * @param path The path of the desired resource
303*0e209d39SAndroid Build Coastguard Worker  * @param sink A `ResourceSink` that gets called for each resource in the parent chain
304*0e209d39SAndroid Build Coastguard Worker  * @param errorCode The error code
305*0e209d39SAndroid Build Coastguard Worker  */
306*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
307*0e209d39SAndroid Build Coastguard Worker ures_getAllItemsWithFallback(const UResourceBundle *bundle, const char *path,
308*0e209d39SAndroid Build Coastguard Worker                              icu::ResourceSink &sink, UErrorCode &errorCode);
309*0e209d39SAndroid Build Coastguard Worker 
310*0e209d39SAndroid Build Coastguard Worker /**
311*0e209d39SAndroid Build Coastguard Worker  * Locates the resource specified by `path` in the resource bundle specified by `bundle` (performing any
312*0e209d39SAndroid Build Coastguard Worker  * necessary fallback and following any aliases) and, if the resource is a table resource, iterates over its
313*0e209d39SAndroid Build Coastguard Worker  * immediate child resources (again, following any aliases to get the individual resource values), and calls the specified
314*0e209d39SAndroid Build Coastguard Worker  * `sink`'s `put()` method for each child resource (passing it that resource's key and either its actual value or,
315*0e209d39SAndroid Build Coastguard Worker  * if that value is an alias, the value you get by following the alias).  Then walks back over the bundle's
316*0e209d39SAndroid Build Coastguard Worker  * parent chain, similarly iterating over each parent table resource's child resources.
317*0e209d39SAndroid Build Coastguard Worker  * Does not descend beyond one level of table children.
318*0e209d39SAndroid Build Coastguard Worker  * @param bundle The bundle to search
319*0e209d39SAndroid Build Coastguard Worker  * @param path The path of the desired resource
320*0e209d39SAndroid Build Coastguard Worker  * @param sink A `ResourceSink` that gets called for each child resource of the specified resource (and each child
321*0e209d39SAndroid Build Coastguard Worker  * of the resources in its parent chain).
322*0e209d39SAndroid Build Coastguard Worker  * @param errorCode The error code.  This will be U_RESOURCE_TYPE_MISMATCH if the resource the caller
323*0e209d39SAndroid Build Coastguard Worker  * is asking for isn't a table resource.
324*0e209d39SAndroid Build Coastguard Worker  */
325*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
326*0e209d39SAndroid Build Coastguard Worker ures_getAllChildrenWithFallback(const UResourceBundle *bundle, const char *path,
327*0e209d39SAndroid Build Coastguard Worker                                 icu::ResourceSink &sink, UErrorCode &errorCode);
328*0e209d39SAndroid Build Coastguard Worker 
329*0e209d39SAndroid Build Coastguard Worker #endif  /* __cplusplus */
330*0e209d39SAndroid Build Coastguard Worker 
331*0e209d39SAndroid Build Coastguard Worker /**
332*0e209d39SAndroid Build Coastguard Worker  * Get a version number by key
333*0e209d39SAndroid Build Coastguard Worker  * @param resB bundle containing version number
334*0e209d39SAndroid Build Coastguard Worker  * @param key the key for the version number
335*0e209d39SAndroid Build Coastguard Worker  * @param ver fillin for the version number
336*0e209d39SAndroid Build Coastguard Worker  * @param status error code
337*0e209d39SAndroid Build Coastguard Worker  */
338*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
339*0e209d39SAndroid Build Coastguard Worker ures_getVersionByKey(const UResourceBundle *resB,
340*0e209d39SAndroid Build Coastguard Worker                      const char *key,
341*0e209d39SAndroid Build Coastguard Worker                      UVersionInfo ver,
342*0e209d39SAndroid Build Coastguard Worker                      UErrorCode *status);
343*0e209d39SAndroid Build Coastguard Worker 
344*0e209d39SAndroid Build Coastguard Worker 
345*0e209d39SAndroid Build Coastguard Worker /**
346*0e209d39SAndroid Build Coastguard Worker  * Internal function.
347*0e209d39SAndroid Build Coastguard Worker  * Return the version number associated with this ResourceBundle as a string.
348*0e209d39SAndroid Build Coastguard Worker  *
349*0e209d39SAndroid Build Coastguard Worker  * @param resourceBundle The resource bundle for which the version is checked.
350*0e209d39SAndroid Build Coastguard Worker  * @return  A version number string as specified in the resource bundle or its parent.
351*0e209d39SAndroid Build Coastguard Worker  *          The caller does not own this string.
352*0e209d39SAndroid Build Coastguard Worker  * @see ures_getVersion
353*0e209d39SAndroid Build Coastguard Worker  */
354*0e209d39SAndroid Build Coastguard Worker U_CAPI const char* U_EXPORT2
355*0e209d39SAndroid Build Coastguard Worker ures_getVersionNumberInternal(const UResourceBundle *resourceBundle);
356*0e209d39SAndroid Build Coastguard Worker 
357*0e209d39SAndroid Build Coastguard Worker /**
358*0e209d39SAndroid Build Coastguard Worker  * Return the name of the Locale associated with this ResourceBundle. This API allows
359*0e209d39SAndroid Build Coastguard Worker  * you to query for the real locale of the resource. For example, if you requested
360*0e209d39SAndroid Build Coastguard Worker  * "en_US_CALIFORNIA" and only "en_US" bundle exists, "en_US" will be returned.
361*0e209d39SAndroid Build Coastguard Worker  * For subresources, the locale where this resource comes from will be returned.
362*0e209d39SAndroid Build Coastguard Worker  * If fallback has occurred, getLocale will reflect this.
363*0e209d39SAndroid Build Coastguard Worker  *
364*0e209d39SAndroid Build Coastguard Worker  * This internal version avoids deprecated-warnings in ICU code.
365*0e209d39SAndroid Build Coastguard Worker  *
366*0e209d39SAndroid Build Coastguard Worker  * @param resourceBundle resource bundle in question
367*0e209d39SAndroid Build Coastguard Worker  * @param status just for catching illegal arguments
368*0e209d39SAndroid Build Coastguard Worker  * @return  A Locale name
369*0e209d39SAndroid Build Coastguard Worker  */
370*0e209d39SAndroid Build Coastguard Worker U_CAPI const char* U_EXPORT2
371*0e209d39SAndroid Build Coastguard Worker ures_getLocaleInternal(const UResourceBundle* resourceBundle,
372*0e209d39SAndroid Build Coastguard Worker                UErrorCode* status);
373*0e209d39SAndroid Build Coastguard Worker 
374*0e209d39SAndroid Build Coastguard Worker /**
375*0e209d39SAndroid Build Coastguard Worker  * Same as ures_openDirect() but uses the fill-in parameter instead of allocating a new bundle.
376*0e209d39SAndroid Build Coastguard Worker  *
377*0e209d39SAndroid Build Coastguard Worker  * @param r The existing UResourceBundle to fill in. If NULL then status will be
378*0e209d39SAndroid Build Coastguard Worker  *          set to U_ILLEGAL_ARGUMENT_ERROR.
379*0e209d39SAndroid Build Coastguard Worker  * @param packageName   The packageName and locale together point to an ICU udata object,
380*0e209d39SAndroid Build Coastguard Worker  *                      as defined by <code> udata_open( packageName, "res", locale, err) </code>
381*0e209d39SAndroid Build Coastguard Worker  *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to
382*0e209d39SAndroid Build Coastguard Worker  *                      a package registered with udata_setAppData(). Using a full file or directory
383*0e209d39SAndroid Build Coastguard Worker  *                      pathname for packageName is deprecated. If NULL, ICU data will be used.
384*0e209d39SAndroid Build Coastguard Worker  * @param locale  specifies the locale for which we want to open the resource
385*0e209d39SAndroid Build Coastguard Worker  *                if NULL, the default locale will be used. If strlen(locale) == 0
386*0e209d39SAndroid Build Coastguard Worker  *                root locale will be used.
387*0e209d39SAndroid Build Coastguard Worker  * @param status The error code.
388*0e209d39SAndroid Build Coastguard Worker  * @see ures_openDirect
389*0e209d39SAndroid Build Coastguard Worker  * @internal
390*0e209d39SAndroid Build Coastguard Worker  */
391*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
392*0e209d39SAndroid Build Coastguard Worker ures_openDirectFillIn(UResourceBundle *r,
393*0e209d39SAndroid Build Coastguard Worker                       const char *packageName,
394*0e209d39SAndroid Build Coastguard Worker                       const char *locale,
395*0e209d39SAndroid Build Coastguard Worker                       UErrorCode *status);
396*0e209d39SAndroid Build Coastguard Worker 
397*0e209d39SAndroid Build Coastguard Worker #endif /*URESIMP_H*/
398