1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 ******************************************************************************
5 * Copyright (C) 1999-2016, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
8 * file name: uresdata.h
9 * encoding: UTF-8
10 * tab size: 8 (not used)
11 * indentation:4
12 *
13 * created on: 1999dec08
14 * created by: Markus W. Scherer
15 * 06/24/02 weiv Added support for resource sharing
16 */
17
18 #ifndef __RESDATA_H__
19 #define __RESDATA_H__
20
21 #include "unicode/utypes.h"
22 #include "unicode/udata.h"
23 #include "unicode/ures.h"
24 #include "putilimp.h"
25 #include "udataswp.h"
26
27 /**
28 * Numeric constants for internal-only types of resource items.
29 * These must use different numeric values than UResType constants
30 * because they are used together.
31 * Internal types are never returned by ures_getType().
32 */
33 typedef enum {
34 /** Include a negative value so that the compiler uses the same int type as for UResType. */
35 URES_INTERNAL_NONE=-1,
36
37 /** Resource type constant for tables with 32-bit count, key offsets and values. */
38 URES_TABLE32=4,
39
40 /**
41 * Resource type constant for tables with 16-bit count, key offsets and values.
42 * All values are URES_STRING_V2 strings.
43 */
44 URES_TABLE16=5,
45
46 /** Resource type constant for 16-bit Unicode strings in formatVersion 2. */
47 URES_STRING_V2=6,
48
49 /**
50 * Resource type constant for arrays with 16-bit count and values.
51 * All values are URES_STRING_V2 strings.
52 */
53 URES_ARRAY16=9
54
55 /* Resource type 15 is not defined but effectively used by RES_BOGUS=0xffffffff. */
56 } UResInternalType;
57
58 /*
59 * A Resource is a 32-bit value that has 2 bit fields:
60 * 31..28 4-bit type, see enum below
61 * 27..0 28-bit four-byte-offset or value according to the type
62 */
63 typedef uint32_t Resource;
64
65 #define RES_BOGUS 0xffffffff
66 #define RES_MAX_OFFSET 0x0fffffff
67
68 #define RES_GET_TYPE(res) ((int32_t)((res)>>28UL))
69 #define RES_GET_OFFSET(res) ((res)&0x0fffffff)
70 #define RES_GET_POINTER(pRoot, res) ((pRoot)+RES_GET_OFFSET(res))
71
72 /* get signed and unsigned integer values directly from the Resource handle
73 * NOTE: For proper logging, please use the res_getInt() constexpr
74 */
75 #if U_SIGNED_RIGHT_SHIFT_IS_ARITHMETIC
76 # define RES_GET_INT_NO_TRACE(res) (((int32_t)((res)<<4L))>>4L)
77 #else
78 # define RES_GET_INT_NO_TRACE(res) (int32_t)(((res)&0x08000000) ? (res)|0xf0000000 : (res)&0x07ffffff)
79 #endif
80
81 #define RES_GET_UINT_NO_TRACE(res) ((res)&0x0fffffff)
82
83 #define URES_IS_ARRAY(type) ((int32_t)(type)==URES_ARRAY || (int32_t)(type)==URES_ARRAY16)
84 #define URES_IS_TABLE(type) ((int32_t)(type)==URES_TABLE || (int32_t)(type)==URES_TABLE16 || (int32_t)(type)==URES_TABLE32)
85 #define URES_IS_CONTAINER(type) (URES_IS_TABLE(type) || URES_IS_ARRAY(type))
86
87 #define URES_MAKE_RESOURCE(type, offset) (((Resource)(type)<<28)|(Resource)(offset))
88 #define URES_MAKE_EMPTY_RESOURCE(type) ((Resource)(type)<<28)
89
90 /* indexes[] value names; indexes are generally 32-bit (Resource) indexes */
91 enum {
92 /**
93 * [0] contains the length of indexes[]
94 * which is at most URES_INDEX_TOP of the latest format version
95 *
96 * formatVersion==1: all bits contain the length of indexes[]
97 * but the length is much less than 0xff;
98 * formatVersion>1:
99 * only bits 7..0 contain the length of indexes[],
100 * bits 31..8 are reserved and set to 0
101 * formatVersion>=3:
102 * bits 31..8 poolStringIndexLimit bits 23..0
103 */
104 URES_INDEX_LENGTH,
105 /**
106 * [1] contains the top of the key strings,
107 * same as the bottom of resources or UTF-16 strings, rounded up
108 */
109 URES_INDEX_KEYS_TOP,
110 /** [2] contains the top of all resources */
111 URES_INDEX_RESOURCES_TOP,
112 /**
113 * [3] contains the top of the bundle,
114 * in case it were ever different from [2]
115 */
116 URES_INDEX_BUNDLE_TOP,
117 /** [4] max. length of any table */
118 URES_INDEX_MAX_TABLE_LENGTH,
119 /**
120 * [5] attributes bit set, see URES_ATT_* (new in formatVersion 1.2)
121 *
122 * formatVersion>=3:
123 * bits 31..16 poolStringIndex16Limit
124 * bits 15..12 poolStringIndexLimit bits 27..24
125 */
126 URES_INDEX_ATTRIBUTES,
127 /**
128 * [6] top of the 16-bit units (UTF-16 string v2 UChars, URES_TABLE16, URES_ARRAY16),
129 * rounded up (new in formatVersion 2.0, ICU 4.4)
130 */
131 URES_INDEX_16BIT_TOP,
132 /** [7] checksum of the pool bundle (new in formatVersion 2.0, ICU 4.4) */
133 URES_INDEX_POOL_CHECKSUM,
134 URES_INDEX_TOP
135 };
136
137 /*
138 * Nofallback attribute, attribute bit 0 in indexes[URES_INDEX_ATTRIBUTES].
139 * New in formatVersion 1.2 (ICU 3.6).
140 *
141 * If set, then this resource bundle is a standalone bundle.
142 * If not set, then the bundle participates in locale fallback, eventually
143 * all the way to the root bundle.
144 * If indexes[] is missing or too short, then the attribute cannot be determined
145 * reliably. Dependency checking should ignore such bundles, and loading should
146 * use fallbacks.
147 */
148 #define URES_ATT_NO_FALLBACK 1
149
150 /*
151 * Attributes for bundles that are, or use, a pool bundle.
152 * A pool bundle provides key strings that are shared among several other bundles
153 * to reduce their total size.
154 * New in formatVersion 2 (ICU 4.4).
155 */
156 #define URES_ATT_IS_POOL_BUNDLE 2
157 #define URES_ATT_USES_POOL_BUNDLE 4
158
159 /*
160 * File format for .res resource bundle files
161 *
162 * ICU 56: New in formatVersion 3 compared with 2: -------------
163 *
164 * Resource bundles can optionally use shared string-v2 values
165 * stored in the pool bundle.
166 * If so, then the indexes[] contain two new values
167 * in previously-unused bits of existing indexes[] slots:
168 * - poolStringIndexLimit:
169 * String-v2 offsets (in 32-bit Resource words) below this limit
170 * point to pool bundle string-v2 values.
171 * - poolStringIndex16Limit:
172 * Resource16 string-v2 offsets below this limit
173 * point to pool bundle string-v2 values.
174 * Guarantee: poolStringIndex16Limit <= poolStringIndexLimit
175 *
176 * The local bundle's poolStringIndexLimit is greater than
177 * any pool bundle string index used in the local bundle.
178 * The poolStringIndexLimit should not be greater than
179 * the maximum possible pool bundle string index.
180 *
181 * The maximum possible pool bundle string index is the index to the last non-NUL
182 * pool string character, due to suffix sharing.
183 *
184 * In the pool bundle, there is no structure that lists the strings.
185 * (The root resource is an empty Table.)
186 * If the strings need to be enumerated (as genrb --usePoolBundle does),
187 * then iterate through the pool bundle's 16-bit-units array from the beginning.
188 * Stop at the end of the array, or when an explicit or implicit string length
189 * would lead beyond the end of the array,
190 * or when an apparent string is not NUL-terminated.
191 * (Future genrb version might terminate the strings with
192 * what looks like a large explicit string length.)
193 *
194 * ICU 4.4: New in formatVersion 2 compared with 1.3: -------------
195 *
196 * Three new resource types -- String-v2, Table16 and Array16 -- have their
197 * values stored in a new array of 16-bit units between the table key strings
198 * and the start of the other resources.
199 *
200 * genrb eliminates duplicates among Unicode string-v2 values.
201 * Multiple Unicode strings may use the same offset and string data,
202 * or a short string may point to the suffix of a longer string. ("Suffix sharing")
203 * For example, one string "abc" may be reused for another string "bc" by pointing
204 * to the second character. (Short strings-v2 are NUL-terminated
205 * and not preceded by an explicit length value.)
206 *
207 * It is allowed for all resource types to share values.
208 * The swapper code (ures_swap()) has been modified so that it swaps each item
209 * exactly once.
210 *
211 * A resource bundle may use a special pool bundle. Some or all of the table key strings
212 * of the using-bundle are omitted, and the key string offsets for such key strings refer
213 * to offsets in the pool bundle.
214 * The using-bundle's and the pool-bundle's indexes[URES_INDEX_POOL_CHECKSUM] values
215 * must match.
216 * Two bits in indexes[URES_INDEX_ATTRIBUTES] indicate whether a resource bundle
217 * is or uses a pool bundle.
218 *
219 * Table key strings must be compared in ASCII order, even if they are not
220 * stored in ASCII.
221 *
222 * New in formatVersion 1.3 compared with 1.2: -------------
223 *
224 * genrb eliminates duplicates among key strings.
225 * Multiple table items may share one key string, or one item may point
226 * to the suffix of another's key string. ("Suffix sharing")
227 * For example, one key "abc" may be reused for another key "bc" by pointing
228 * to the second character. (Key strings are NUL-terminated.)
229 *
230 * -------------
231 *
232 * An ICU4C resource bundle file (.res) is a binary, memory-mappable file
233 * with nested, hierarchical data structures.
234 * It physically contains the following:
235 *
236 * Resource root; -- 32-bit Resource item, root item for this bundle's tree;
237 * currently, the root item must be a table or table32 resource item
238 * int32_t indexes[indexes[0]]; -- array of indexes for friendly
239 * reading and swapping; see URES_INDEX_* above
240 * new in formatVersion 1.1 (ICU 2.8)
241 * char keys[]; -- characters for key strings
242 * (formatVersion 1.0: up to 65k of characters; 1.1: <2G)
243 * (minus the space for root and indexes[]),
244 * which consist of invariant characters (ASCII/EBCDIC) and are NUL-terminated;
245 * padded to multiple of 4 bytes for 4-alignment of the following data
246 * uint16_t 16BitUnits[]; -- resources that are stored entirely as sequences of 16-bit units
247 * (new in formatVersion 2/ICU 4.4)
248 * data is indexed by the offset values in 16-bit resource types,
249 * with offset 0 pointing to the beginning of this array;
250 * there is a 0 at offset 0, for empty resources;
251 * padded to multiple of 4 bytes for 4-alignment of the following data
252 * data; -- data directly and indirectly indexed by the root item;
253 * the structure is determined by walking the tree
254 *
255 * Each resource bundle item has a 32-bit Resource handle (see typedef above)
256 * which contains the item type number in its upper 4 bits (31..28) and either
257 * an offset or a direct value in its lower 28 bits (27..0).
258 * The order of items is undefined and only determined by walking the tree.
259 * Leaves of the tree may be stored first or last or anywhere in between,
260 * and it is in theory possible to have unreferenced holes in the file.
261 *
262 * 16-bit-unit values:
263 * Starting with formatVersion 2/ICU 4.4, some resources are stored in a special
264 * array of 16-bit units. Each resource value is a sequence of 16-bit units,
265 * with no per-resource padding to a 4-byte boundary.
266 * 16-bit container types (Table16 and Array16) contain Resource16 values
267 * which are offsets to String-v2 resources in the same 16-bit-units array.
268 *
269 * Direct values:
270 * - Empty Unicode strings have an offset value of 0 in the Resource handle itself.
271 * - Starting with formatVersion 2/ICU 4.4, an offset value of 0 for
272 * _any_ resource type indicates an empty value.
273 * - Integer values are 28-bit values stored in the Resource handle itself;
274 * the interpretation of unsigned vs. signed integers is up to the application.
275 *
276 * All other types and values use 28-bit offsets to point to the item's data.
277 * The offset is an index to the first 32-bit word of the value, relative to the
278 * start of the resource data (i.e., the root item handle is at offset 0).
279 * To get byte offsets, the offset is multiplied by 4 (or shifted left by 2 bits).
280 * All resource item values are 4-aligned.
281 *
282 * New in formatVersion 2/ICU 4.4: Some types use offsets into the 16-bit-units array,
283 * indexing 16-bit units in that array.
284 *
285 * The structures (memory layouts) for the values for each item type are listed
286 * in the table below.
287 *
288 * Nested, hierarchical structures: -------------
289 *
290 * Table items contain key-value pairs where the keys are offsets to char * key strings.
291 * The values of these pairs are either Resource handles or
292 * offsets into the 16-bit-units array, depending on the table type.
293 *
294 * Array items are simple vectors of Resource handles,
295 * or of offsets into the 16-bit-units array, depending on the array type.
296 *
297 * Table key string offsets: -------
298 *
299 * Key string offsets are relative to the start of the resource data (of the root handle),
300 * i.e., the first string has an offset of 4+sizeof(indexes).
301 * (After the 4-byte root handle and after the indexes array.)
302 *
303 * If the resource bundle uses a pool bundle, then some key strings are stored
304 * in the pool bundle rather than in the local bundle itself.
305 * - In a Table or Table16, the 16-bit key string offset is local if it is
306 * less than indexes[URES_INDEX_KEYS_TOP]<<2.
307 * Otherwise, subtract indexes[URES_INDEX_KEYS_TOP]<<2 to get the offset into
308 * the pool bundle key strings.
309 * - In a Table32, the 32-bit key string offset is local if it is non-negative.
310 * Otherwise, reset bit 31 to get the pool key string offset.
311 *
312 * Unlike the local offset, the pool key offset is relative to
313 * the start of the key strings, not to the start of the bundle.
314 *
315 * An alias item is special (and new in ICU 2.4): --------------
316 *
317 * Its memory layout is just like for a UnicodeString, but at runtime it resolves to
318 * another resource bundle's item according to the path in the string.
319 * This is used to share items across bundles that are in different lookup/fallback
320 * chains (e.g., large collation data among zh_TW and zh_HK).
321 * This saves space (for large items) and maintenance effort (less duplication of data).
322 *
323 * --------------------------------------------------------------------------
324 *
325 * Resource types:
326 *
327 * Most resources have their values stored at four-byte offsets from the start
328 * of the resource data. These values are at least 4-aligned.
329 * Some resource values are stored directly in the offset field of the Resource itself.
330 * See UResType in unicode/ures.h for enumeration constants for Resource types.
331 *
332 * Some resources have their values stored as sequences of 16-bit units,
333 * at 2-byte offsets from the start of a contiguous 16-bit-unit array between
334 * the table key strings and the other resources. (new in formatVersion 2/ICU 4.4)
335 * At offset 0 of that array is a 16-bit zero value for empty 16-bit resources.
336 *
337 * Resource16 values in Table16 and Array16 are 16-bit offsets to String-v2
338 * resources, with the offsets relative to the start of the 16-bit-units array.
339 * Starting with formatVersion 3/ICU 56, if offset<poolStringIndex16Limit
340 * then use the pool bundle's 16-bit-units array,
341 * otherwise subtract that limit and use the local 16-bit-units array.
342 *
343 * Type Name Memory layout of values
344 * (in parentheses: scalar, non-offset values)
345 *
346 * 0 Unicode String: int32_t length, UChar[length], (UChar)0, (padding)
347 * or (empty string ("") if offset==0)
348 * 1 Binary: int32_t length, uint8_t[length], (padding)
349 * - the start of the bytes is 16-aligned -
350 * 2 Table: uint16_t count, uint16_t keyStringOffsets[count], (uint16_t padding), Resource[count]
351 * 3 Alias: (physically same value layout as string, new in ICU 2.4)
352 * 4 Table32: int32_t count, int32_t keyStringOffsets[count], Resource[count]
353 * (new in formatVersion 1.1/ICU 2.8)
354 * 5 Table16: uint16_t count, uint16_t keyStringOffsets[count], Resource16[count]
355 * (stored in the 16-bit-units array; new in formatVersion 2/ICU 4.4)
356 * 6 Unicode String-v2:UChar[length], (UChar)0; length determined by the first UChar:
357 * - if first is not a trail surrogate, then the length is implicit
358 * and u_strlen() needs to be called
359 * - if first<0xdfef then length=first&0x3ff (and skip first)
360 * - if first<0xdfff then length=((first-0xdfef)<<16) | second UChar
361 * - if first==0xdfff then length=((second UChar)<<16) | third UChar
362 * (stored in the 16-bit-units array; new in formatVersion 2/ICU 4.4)
363 *
364 * Starting with formatVersion 3/ICU 56, if offset<poolStringIndexLimit
365 * then use the pool bundle's 16-bit-units array,
366 * otherwise subtract that limit and use the local 16-bit-units array.
367 * (Note different limits for Resource16 vs. Resource.)
368 *
369 * 7 Integer: (28-bit offset is integer value)
370 * 8 Array: int32_t count, Resource[count]
371 * 9 Array16: uint16_t count, Resource16[count]
372 * (stored in the 16-bit-units array; new in formatVersion 2/ICU 4.4)
373 * 14 Integer Vector: int32_t length, int32_t[length]
374 * 15 Reserved: This value denotes special purpose resources and is for internal use.
375 *
376 * Note that there are 3 types with data vector values:
377 * - Vectors of 8-bit bytes stored as type Binary.
378 * - Vectors of 16-bit words stored as type Unicode String or Unicode String-v2
379 * (no value restrictions, all values 0..ffff allowed!).
380 * - Vectors of 32-bit words stored as type Integer Vector.
381 */
382
383 /*
384 * Structure for a single, memory-mapped ResourceBundle.
385 */
386 typedef struct ResourceData {
387 UDataMemory *data;
388 const int32_t *pRoot;
389 const uint16_t *p16BitUnits;
390 const char *poolBundleKeys;
391 Resource rootRes;
392 int32_t localKeyLimit;
393 const uint16_t *poolBundleStrings;
394 int32_t poolStringIndexLimit;
395 int32_t poolStringIndex16Limit;
396 UBool noFallback; /* see URES_ATT_NO_FALLBACK */
397 UBool isPoolBundle;
398 UBool usesPoolBundle;
399 UBool useNativeStrcmp;
400 } ResourceData;
401
402 /*
403 * Read a resource bundle from memory.
404 */
405 U_CAPI void U_EXPORT2
406 res_read(ResourceData *pResData,
407 const UDataInfo *pInfo, const void *inBytes, int32_t length,
408 UErrorCode *errorCode);
409
410 /*
411 * Load a resource bundle file.
412 * The ResourceData structure must be allocated externally.
413 */
414 U_CFUNC void
415 res_load(ResourceData *pResData,
416 const char *path, const char *name, UErrorCode *errorCode);
417
418 /*
419 * Release a resource bundle file.
420 * This does not release the ResourceData structure itself.
421 */
422 U_CFUNC void
423 res_unload(ResourceData *pResData);
424
425 U_CAPI UResType U_EXPORT2
426 res_getPublicType(Resource res);
427
428 ///////////////////////////////////////////////////////////////////////////
429 // To enable tracing, use the inline versions of the res_get* functions. //
430 ///////////////////////////////////////////////////////////////////////////
431
432 /*
433 * Return a pointer to a zero-terminated, const UChar* string
434 * and set its length in *pLength.
435 * Returns NULL if not found.
436 */
437 U_CAPI const UChar * U_EXPORT2
438 res_getStringNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength);
439
440 U_CAPI const uint8_t * U_EXPORT2
441 res_getBinaryNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength);
442
443 U_CAPI const int32_t * U_EXPORT2
444 res_getIntVectorNoTrace(const ResourceData *pResData, Resource res, int32_t *pLength);
445
446 U_CAPI const UChar * U_EXPORT2
447 res_getAlias(const ResourceData *pResData, Resource res, int32_t *pLength);
448
449 U_CAPI Resource U_EXPORT2
450 res_getResource(const ResourceData *pResData, const char *key);
451
452 U_CAPI int32_t U_EXPORT2
453 res_countArrayItems(const ResourceData *pResData, Resource res);
454
455 U_CAPI Resource U_EXPORT2
456 res_getArrayItem(const ResourceData *pResData, Resource array, int32_t indexS);
457
458 U_CAPI Resource U_EXPORT2
459 res_getTableItemByIndex(const ResourceData *pResData, Resource table, int32_t indexS, const char ** key);
460
461 U_CAPI Resource U_EXPORT2
462 res_getTableItemByKey(const ResourceData *pResData, Resource table, int32_t *indexS, const char* * key);
463
464 /**
465 * Iterates over the path and stops when a scalar resource is found.
466 * Follows aliases.
467 * Modifies the contents of *path (replacing separators with NULs),
468 * and also moves *path forward while it finds items.
469 *
470 * @param path input: "CollationElements/Sequence" or "zoneStrings/3/2" etc.;
471 * output: points to the part that has not yet been processed
472 */
473 U_CFUNC Resource res_findResource(const ResourceData *pResData, Resource r,
474 char** path, const char** key);
475
476 #ifdef __cplusplus
477
478 #include "resource.h"
479 #include "restrace.h"
480
481 U_NAMESPACE_BEGIN
482
res_getString(const ResourceTracer & traceInfo,const ResourceData * pResData,Resource res,int32_t * pLength)483 inline const UChar* res_getString(const ResourceTracer& traceInfo,
484 const ResourceData *pResData, Resource res, int32_t *pLength) {
485 traceInfo.trace("string");
486 return res_getStringNoTrace(pResData, res, pLength);
487 }
488
res_getBinary(const ResourceTracer & traceInfo,const ResourceData * pResData,Resource res,int32_t * pLength)489 inline const uint8_t* res_getBinary(const ResourceTracer& traceInfo,
490 const ResourceData *pResData, Resource res, int32_t *pLength) {
491 traceInfo.trace("binary");
492 return res_getBinaryNoTrace(pResData, res, pLength);
493 }
494
res_getIntVector(const ResourceTracer & traceInfo,const ResourceData * pResData,Resource res,int32_t * pLength)495 inline const int32_t* res_getIntVector(const ResourceTracer& traceInfo,
496 const ResourceData *pResData, Resource res, int32_t *pLength) {
497 traceInfo.trace("intvector");
498 return res_getIntVectorNoTrace(pResData, res, pLength);
499 }
500
res_getInt(const ResourceTracer & traceInfo,Resource res)501 inline int32_t res_getInt(const ResourceTracer& traceInfo, Resource res) {
502 traceInfo.trace("int");
503 return RES_GET_INT_NO_TRACE(res);
504 }
505
res_getUInt(const ResourceTracer & traceInfo,Resource res)506 inline uint32_t res_getUInt(const ResourceTracer& traceInfo, Resource res) {
507 traceInfo.trace("uint");
508 return RES_GET_UINT_NO_TRACE(res);
509 }
510
511 class ResourceDataValue : public ResourceValue {
512 public:
ResourceDataValue()513 ResourceDataValue() :
514 res(static_cast<Resource>(URES_NONE)),
515 fTraceInfo() {}
516 virtual ~ResourceDataValue();
517
setData(const ResourceData * data)518 void setData(const ResourceData *data) {
519 resData = *data;
520 }
521
setResource(Resource r,ResourceTracer && traceInfo)522 void setResource(Resource r, ResourceTracer&& traceInfo) {
523 res = r;
524 fTraceInfo = traceInfo;
525 }
526
getData()527 const ResourceData &getData() const { return resData; }
528 virtual UResType getType() const;
529 virtual const UChar *getString(int32_t &length, UErrorCode &errorCode) const;
530 virtual const UChar *getAliasString(int32_t &length, UErrorCode &errorCode) const;
531 virtual int32_t getInt(UErrorCode &errorCode) const;
532 virtual uint32_t getUInt(UErrorCode &errorCode) const;
533 virtual const int32_t *getIntVector(int32_t &length, UErrorCode &errorCode) const;
534 virtual const uint8_t *getBinary(int32_t &length, UErrorCode &errorCode) const;
535 virtual ResourceArray getArray(UErrorCode &errorCode) const;
536 virtual ResourceTable getTable(UErrorCode &errorCode) const;
537 virtual UBool isNoInheritanceMarker() const;
538 virtual int32_t getStringArray(UnicodeString *dest, int32_t capacity,
539 UErrorCode &errorCode) const;
540 virtual int32_t getStringArrayOrStringAsArray(UnicodeString *dest, int32_t capacity,
541 UErrorCode &errorCode) const;
542 virtual UnicodeString getStringOrFirstOfArray(UErrorCode &errorCode) const;
543
544 private:
545 // TODO(ICU-20769): If UResourceBundle.fResData becomes a pointer,
546 // then remove this value field again and just store a pResData pointer.
547 ResourceData resData;
548 Resource res;
549 ResourceTracer fTraceInfo;
550 };
551
552 U_NAMESPACE_END
553
554 #endif /* __cplusplus */
555
556 /**
557 * Swap an ICU resource bundle. See udataswp.h.
558 * @internal
559 */
560 U_CAPI int32_t U_EXPORT2
561 ures_swap(const UDataSwapper *ds,
562 const void *inData, int32_t length, void *outData,
563 UErrorCode *pErrorCode);
564
565 #endif
566