OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * | 3 * |
4 * Copyright (C) 2000-2014, International Business Machines | 4 * Copyright (C) 2000-2015, International Business Machines |
5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
6 * | 6 * |
7 ******************************************************************************* | 7 ******************************************************************************* |
8 * | 8 * |
9 * File reslist.h | 9 * File reslist.h |
10 * | 10 * |
11 * Modification History: | 11 * Modification History: |
12 * | 12 * |
13 * Date Name Description | 13 * Date Name Description |
14 * 02/21/00 weiv Creation. | 14 * 02/21/00 weiv Creation. |
15 ******************************************************************************* | 15 ******************************************************************************* |
16 */ | 16 */ |
17 | 17 |
18 #ifndef RESLIST_H | 18 #ifndef RESLIST_H |
19 #define RESLIST_H | 19 #define RESLIST_H |
20 | 20 |
21 #define KEY_SPACE_SIZE 65536 | 21 #define KEY_SPACE_SIZE 65536 |
22 #define RESLIST_MAX_INT_VECTOR 2048 | 22 #define RESLIST_MAX_INT_VECTOR 2048 |
23 | 23 |
24 #include "unicode/utypes.h" | 24 #include "unicode/utypes.h" |
| 25 #include "unicode/unistr.h" |
25 #include "unicode/ures.h" | 26 #include "unicode/ures.h" |
26 #include "unicode/ustring.h" | 27 #include "unicode/ustring.h" |
27 #include "uresdata.h" | |
28 #include "cmemory.h" | 28 #include "cmemory.h" |
29 #include "cstring.h" | 29 #include "cstring.h" |
| 30 #include "uhash.h" |
30 #include "unewdata.h" | 31 #include "unewdata.h" |
| 32 #include "uresdata.h" |
31 #include "ustr.h" | 33 #include "ustr.h" |
32 | 34 |
33 U_CDECL_BEGIN | 35 U_CDECL_BEGIN |
34 | 36 |
| 37 class PseudoListResource; |
| 38 |
| 39 struct ResFile { |
| 40 ResFile() |
| 41 : fBytes(NULL), fIndexes(NULL), |
| 42 fKeys(NULL), fKeysLength(0), fKeysCount(0), |
| 43 fStrings(NULL), fStringIndexLimit(0), |
| 44 fChecksum(0) {} |
| 45 ~ResFile() { close(); } |
| 46 |
| 47 void close(); |
| 48 |
| 49 uint8_t *fBytes; |
| 50 const int32_t *fIndexes; |
| 51 const char *fKeys; |
| 52 int32_t fKeysLength; |
| 53 int32_t fKeysCount; |
| 54 |
| 55 PseudoListResource *fStrings; |
| 56 int32_t fStringIndexLimit; |
| 57 |
| 58 int32_t fChecksum; |
| 59 }; |
| 60 |
| 61 struct SResource; |
| 62 |
35 typedef struct KeyMapEntry { | 63 typedef struct KeyMapEntry { |
36 int32_t oldpos, newpos; | 64 int32_t oldpos, newpos; |
37 } KeyMapEntry; | 65 } KeyMapEntry; |
38 | 66 |
39 /* Resource bundle root table */ | 67 /* Resource bundle root table */ |
40 struct SRBRoot { | 68 struct SRBRoot { |
41 struct SResource *fRoot; | 69 SRBRoot(const UString *comment, UBool isPoolBundle, UErrorCode &errorCode); |
| 70 ~SRBRoot(); |
| 71 |
| 72 void write(const char *outputDir, const char *outputPkg, |
| 73 char *writtenFilename, int writtenFilenameLen, UErrorCode &errorC
ode); |
| 74 |
| 75 void setLocale(UChar *locale, UErrorCode &errorCode); |
| 76 int32_t addTag(const char *tag, UErrorCode &errorCode); |
| 77 |
| 78 const char *getKeyString(int32_t key) const; |
| 79 const char *getKeyBytes(int32_t *pLength) const; |
| 80 |
| 81 int32_t addKeyBytes(const char *keyBytes, int32_t length, UErrorCode &errorC
ode); |
| 82 |
| 83 void compactKeys(UErrorCode &errorCode); |
| 84 |
| 85 int32_t makeRes16(uint32_t resWord) const; |
| 86 int32_t mapKey(int32_t oldpos) const; |
| 87 |
| 88 private: |
| 89 void compactStringsV2(UHashtable *stringSet, UErrorCode &errorCode); |
| 90 |
| 91 public: |
| 92 // TODO: private |
| 93 |
| 94 SResource *fRoot; // Normally a TableResource. |
42 char *fLocale; | 95 char *fLocale; |
43 int32_t fIndexLength; | 96 int32_t fIndexLength; |
44 int32_t fMaxTableLength; | 97 int32_t fMaxTableLength; |
45 UBool noFallback; /* see URES_ATT_NO_FALLBACK */ | 98 UBool fNoFallback; /* see URES_ATT_NO_FALLBACK */ |
46 int8_t fStringsForm; /* default STRINGS_UTF16_V1 */ | 99 int8_t fStringsForm; /* default STRINGS_UTF16_V1 */ |
47 UBool fIsPoolBundle; | 100 UBool fIsPoolBundle; |
48 | 101 |
49 char *fKeys; | 102 char *fKeys; |
50 KeyMapEntry *fKeyMap; | 103 KeyMapEntry *fKeyMap; |
51 int32_t fKeysBottom, fKeysTop; | 104 int32_t fKeysBottom, fKeysTop; |
52 int32_t fKeysCapacity; | 105 int32_t fKeysCapacity; |
53 int32_t fKeysCount; | 106 int32_t fKeysCount; |
54 int32_t fLocalKeyLimit; /* key offset < limit fits into URES_TABLE */ | 107 int32_t fLocalKeyLimit; /* key offset < limit fits into URES_TABLE */ |
55 | 108 |
56 uint16_t *f16BitUnits; | 109 icu::UnicodeString f16BitUnits; |
57 int32_t f16BitUnitsCapacity; | 110 int32_t f16BitStringsLength; |
58 int32_t f16BitUnitsLength; | |
59 | 111 |
60 const char *fPoolBundleKeys; | 112 const ResFile *fUsePoolBundle; |
61 int32_t fPoolBundleKeysLength; | 113 int32_t fPoolStringIndexLimit; |
62 int32_t fPoolBundleKeysCount; | 114 int32_t fPoolStringIndex16Limit; |
63 int32_t fPoolChecksum; | 115 int32_t fLocalStringIndexLimit; |
| 116 SRBRoot *fWritePoolBundle; |
64 }; | 117 }; |
65 | 118 |
66 struct SRBRoot *bundle_open(const struct UString* comment, UBool isPoolBundle, U
ErrorCode *status); | |
67 void bundle_write(struct SRBRoot *bundle, const char *outputDir, const char *out
putPkg, char *writtenFilename, int writtenFilenameLen, UErrorCode *status); | |
68 | |
69 /* write a java resource file */ | 119 /* write a java resource file */ |
| 120 // TODO: C++ify |
70 void bundle_write_java(struct SRBRoot *bundle, const char *outputDir, const char
* outputEnc, char *writtenFilename, | 121 void bundle_write_java(struct SRBRoot *bundle, const char *outputDir, const char
* outputEnc, char *writtenFilename, |
71 int writtenFilenameLen, const char* packageName, const ch
ar* bundleName, UErrorCode *status); | 122 int writtenFilenameLen, const char* packageName, const ch
ar* bundleName, UErrorCode *status); |
72 | 123 |
73 /* write a xml resource file */ | 124 /* write a xml resource file */ |
74 /* commented by Jing*/ | 125 // TODO: C++ify |
75 /* void bundle_write_xml(struct SRBRoot *bundle, const char *outputDir,const cha
r* outputEnc, | |
76 char *writtenFilename, int writtenFilenameLen,UErrorCode *stat
us); */ | |
77 | |
78 /* added by Jing*/ | |
79 void bundle_write_xml(struct SRBRoot *bundle, const char *outputDir,const char*
outputEnc, const char* rbname, | 126 void bundle_write_xml(struct SRBRoot *bundle, const char *outputDir,const char*
outputEnc, const char* rbname, |
80 char *writtenFilename, int writtenFilenameLen, const char* lan
guage, const char* package, UErrorCode *status); | 127 char *writtenFilename, int writtenFilenameLen, const char* lan
guage, const char* package, UErrorCode *status); |
81 | 128 |
82 void bundle_close(struct SRBRoot *bundle, UErrorCode *status); | |
83 void bundle_setlocale(struct SRBRoot *bundle, UChar *locale, UErrorCode *status)
; | |
84 int32_t bundle_addtag(struct SRBRoot *bundle, const char *tag, UErrorCode *statu
s); | |
85 | |
86 const char * | |
87 bundle_getKeyBytes(struct SRBRoot *bundle, int32_t *pLength); | |
88 | |
89 int32_t | |
90 bundle_addKeyBytes(struct SRBRoot *bundle, const char *keyBytes, int32_t length,
UErrorCode *status); | |
91 | |
92 void | |
93 bundle_compactKeys(struct SRBRoot *bundle, UErrorCode *status); | |
94 | |
95 /* Various resource types */ | 129 /* Various resource types */ |
96 | 130 |
97 /* | 131 /* |
98 * Return a unique pointer to a dummy object, | 132 * Return a unique pointer to a dummy object, |
99 * for use in non-error cases when no resource is to be added to the bundle. | 133 * for use in non-error cases when no resource is to be added to the bundle. |
100 * (NULL is used in error cases.) | 134 * (NULL is used in error cases.) |
101 */ | 135 */ |
102 struct SResource* res_none(void); | 136 struct SResource* res_none(void); |
103 | 137 |
104 struct SResTable { | 138 class ArrayResource; |
| 139 class TableResource; |
| 140 class IntVectorResource; |
| 141 |
| 142 TableResource *table_open(struct SRBRoot *bundle, const char *tag, const struct
UString* comment, UErrorCode *status); |
| 143 |
| 144 ArrayResource *array_open(struct SRBRoot *bundle, const char *tag, const struct
UString* comment, UErrorCode *status); |
| 145 |
| 146 struct SResource *string_open(struct SRBRoot *bundle, const char *tag, const UCh
ar *value, int32_t len, const struct UString* comment, UErrorCode *status); |
| 147 |
| 148 struct SResource *alias_open(struct SRBRoot *bundle, const char *tag, UChar *val
ue, int32_t len, const struct UString* comment, UErrorCode *status); |
| 149 |
| 150 IntVectorResource *intvector_open(struct SRBRoot *bundle, const char *tag, cons
t struct UString* comment, UErrorCode *status); |
| 151 |
| 152 struct SResource *int_open(struct SRBRoot *bundle, const char *tag, int32_t valu
e, const struct UString* comment, UErrorCode *status); |
| 153 |
| 154 struct SResource *bin_open(struct SRBRoot *bundle, const char *tag, uint32_t len
gth, uint8_t *data, const char* fileName, const struct UString* comment, UErrorC
ode *status); |
| 155 |
| 156 /* Resource place holder */ |
| 157 |
| 158 struct SResource { |
| 159 SResource(); |
| 160 SResource(SRBRoot *bundle, const char *tag, int8_t type, const UString* comm
ent, |
| 161 UErrorCode &errorCode); |
| 162 virtual ~SResource(); |
| 163 |
| 164 UBool isTable() const { return fType == URES_TABLE; } |
| 165 UBool isString() const { return fType == URES_STRING; } |
| 166 |
| 167 const char *getKeyString(const SRBRoot *bundle) const; |
| 168 |
| 169 /** |
| 170 * Preflights strings. |
| 171 * Finds duplicates and counts the total number of string code units |
| 172 * so that they can be written first to the 16-bit array, |
| 173 * for minimal string and container storage. |
| 174 * |
| 175 * We walk the final parse tree, rather than collecting this information whi
le building it, |
| 176 * so that we need not deal with changes to the parse tree (especially remov
ing resources). |
| 177 */ |
| 178 void preflightStrings(SRBRoot *bundle, UHashtable *stringSet, UErrorCode &er
rorCode); |
| 179 virtual void handlePreflightStrings(SRBRoot *bundle, UHashtable *stringSet,
UErrorCode &errorCode); |
| 180 |
| 181 /** |
| 182 * Writes resource values into f16BitUnits |
| 183 * and determines the resource item word, if possible. |
| 184 */ |
| 185 void write16(SRBRoot *bundle); |
| 186 virtual void handleWrite16(SRBRoot *bundle); |
| 187 |
| 188 /** |
| 189 * Calculates ("preflights") and advances the *byteOffset |
| 190 * by the size of the resource's data in the binary file and |
| 191 * determines the resource item word. |
| 192 * |
| 193 * Most handlePreWrite() functions may add any number of bytes, but preWrite
() |
| 194 * will always pad it to a multiple of 4. |
| 195 * The resource item type may be a related subtype of the fType. |
| 196 * |
| 197 * The preWrite() and write() functions start and end at the same |
| 198 * byteOffset values. |
| 199 * Prewriting allows bundle.write() to determine the root resource item word
, |
| 200 * before actually writing the bundle contents to the file, |
| 201 * which is necessary because the root item is stored at the beginning. |
| 202 */ |
| 203 void preWrite(uint32_t *byteOffset); |
| 204 virtual void handlePreWrite(uint32_t *byteOffset); |
| 205 |
| 206 /** |
| 207 * Writes the resource's data to mem and updates the byteOffset |
| 208 * in parallel. |
| 209 */ |
| 210 void write(UNewDataMemory *mem, uint32_t *byteOffset); |
| 211 virtual void handleWrite(UNewDataMemory *mem, uint32_t *byteOffset); |
| 212 |
| 213 int8_t fType; /* nominal type: fRes (when != 0xffffffff) may use subty
pe */ |
| 214 UBool fWritten; /* res_write() can exit early */ |
| 215 uint32_t fRes; /* resource item word; RES_BOGUS=0xffffffff if not known
yet */ |
| 216 int32_t fRes16; /* Res16 version of fRes for Table, Table16, Array16; -1
if it does not fit. */ |
| 217 int32_t fKey; /* Index into bundle->fKeys; -1 if no key. */ |
| 218 int32_t fKey16; /* Key16 version of fKey for Table & Table16; -1 if no k
ey or it does not fit. */ |
| 219 int line; /* used internally to report duplicate keys in tables */ |
| 220 SResource *fNext; /* This is for internal chaining while building */ |
| 221 struct UString fComment; |
| 222 }; |
| 223 |
| 224 class ContainerResource : public SResource { |
| 225 public: |
| 226 ContainerResource(SRBRoot *bundle, const char *tag, int8_t type, |
| 227 const UString* comment, UErrorCode &errorCode) |
| 228 : SResource(bundle, tag, type, comment, errorCode), |
| 229 fCount(0), fFirst(NULL) {} |
| 230 virtual ~ContainerResource(); |
| 231 |
| 232 virtual void handlePreflightStrings(SRBRoot *bundle, UHashtable *stringSet,
UErrorCode &errorCode); |
| 233 protected: |
| 234 void writeAllRes16(SRBRoot *bundle); |
| 235 void preWriteAllRes(uint32_t *byteOffset); |
| 236 void writeAllRes(UNewDataMemory *mem, uint32_t *byteOffset); |
| 237 void writeAllRes32(UNewDataMemory *mem, uint32_t *byteOffset); |
| 238 |
| 239 public: |
| 240 // TODO: private with getter? |
105 uint32_t fCount; | 241 uint32_t fCount; |
106 int8_t fType; /* determined by table_write16() for table_preWrite() & table
_write() */ | 242 SResource *fFirst; |
107 struct SResource *fFirst; | 243 }; |
108 struct SRBRoot *fRoot; | 244 |
109 }; | 245 class TableResource : public ContainerResource { |
110 | 246 public: |
111 struct SResource* table_open(struct SRBRoot *bundle, const char *tag, const stru
ct UString* comment, UErrorCode *status); | 247 TableResource(SRBRoot *bundle, const char *tag, |
112 void table_add(struct SResource *table, struct SResource *res, int linenumber, U
ErrorCode *status); | 248 const UString* comment, UErrorCode &errorCode) |
113 | 249 : ContainerResource(bundle, tag, URES_TABLE, comment, errorCode), |
114 struct SResArray { | 250 fTableType(URES_TABLE), fRoot(bundle) {} |
115 uint32_t fCount; | 251 virtual ~TableResource(); |
116 struct SResource *fFirst; | 252 |
117 struct SResource *fLast; | 253 void add(SResource *res, int linenumber, UErrorCode &errorCode); |
118 }; | 254 |
119 | 255 virtual void handleWrite16(SRBRoot *bundle); |
120 struct SResource* array_open(struct SRBRoot *bundle, const char *tag, const stru
ct UString* comment, UErrorCode *status); | 256 virtual void handlePreWrite(uint32_t *byteOffset); |
121 void array_add(struct SResource *array, struct SResource *res, UErrorCode *statu
s); | 257 virtual void handleWrite(UNewDataMemory *mem, uint32_t *byteOffset); |
122 | 258 |
123 struct SResString { | 259 int8_t fTableType; // determined by table_write16() for table_preWrite() &
table_write() |
124 struct SResource *fSame; /* used for duplicates */ | 260 SRBRoot *fRoot; |
125 UChar *fChars; | 261 }; |
126 int32_t fLength; | 262 |
127 int32_t fSuffixOffset; /* this string is a suffix of fSame at this offset *
/ | 263 class ArrayResource : public ContainerResource { |
| 264 public: |
| 265 ArrayResource(SRBRoot *bundle, const char *tag, |
| 266 const UString* comment, UErrorCode &errorCode) |
| 267 : ContainerResource(bundle, tag, URES_ARRAY, comment, errorCode), |
| 268 fLast(NULL) {} |
| 269 virtual ~ArrayResource(); |
| 270 |
| 271 void add(SResource *res); |
| 272 |
| 273 virtual void handleWrite16(SRBRoot *bundle); |
| 274 virtual void handlePreWrite(uint32_t *byteOffset); |
| 275 virtual void handleWrite(UNewDataMemory *mem, uint32_t *byteOffset); |
| 276 |
| 277 SResource *fLast; |
| 278 }; |
| 279 |
| 280 /** |
| 281 * List of resources for a pool bundle. |
| 282 * Writes an empty table resource, rather than a container structure. |
| 283 */ |
| 284 class PseudoListResource : public ContainerResource { |
| 285 public: |
| 286 PseudoListResource(SRBRoot *bundle, UErrorCode &errorCode) |
| 287 : ContainerResource(bundle, NULL, URES_TABLE, NULL, errorCode) {} |
| 288 virtual ~PseudoListResource(); |
| 289 |
| 290 void add(SResource *res); |
| 291 |
| 292 virtual void handleWrite16(SRBRoot *bundle); |
| 293 }; |
| 294 |
| 295 class StringBaseResource : public SResource { |
| 296 public: |
| 297 StringBaseResource(SRBRoot *bundle, const char *tag, int8_t type, |
| 298 const UChar *value, int32_t len, |
| 299 const UString* comment, UErrorCode &errorCode); |
| 300 StringBaseResource(SRBRoot *bundle, int8_t type, |
| 301 const icu::UnicodeString &value, UErrorCode &errorCode); |
| 302 StringBaseResource(int8_t type, const UChar *value, int32_t len, UErrorCode
&errorCode); |
| 303 virtual ~StringBaseResource(); |
| 304 |
| 305 const UChar *getBuffer() const { return fString.getBuffer(); } |
| 306 int32_t length() const { return fString.length(); } |
| 307 |
| 308 virtual void handlePreWrite(uint32_t *byteOffset); |
| 309 virtual void handleWrite(UNewDataMemory *mem, uint32_t *byteOffset); |
| 310 |
| 311 // TODO: private with getter? |
| 312 icu::UnicodeString fString; |
| 313 }; |
| 314 |
| 315 class StringResource : public StringBaseResource { |
| 316 public: |
| 317 StringResource(SRBRoot *bundle, const char *tag, const UChar *value, int32_t
len, |
| 318 const UString* comment, UErrorCode &errorCode) |
| 319 : StringBaseResource(bundle, tag, URES_STRING, value, len, comment,
errorCode), |
| 320 fSame(NULL), fSuffixOffset(0), |
| 321 fNumCopies(0), fNumUnitsSaved(0), fNumCharsForLength(0) {} |
| 322 StringResource(SRBRoot *bundle, const icu::UnicodeString &value, UErrorCode
&errorCode) |
| 323 : StringBaseResource(bundle, URES_STRING, value, errorCode), |
| 324 fSame(NULL), fSuffixOffset(0), |
| 325 fNumCopies(0), fNumUnitsSaved(0), fNumCharsForLength(0) {} |
| 326 StringResource(int32_t poolStringIndex, int8_t numCharsForLength, |
| 327 const UChar *value, int32_t length, |
| 328 UErrorCode &errorCode) |
| 329 : StringBaseResource(URES_STRING, value, length, errorCode), |
| 330 fSame(NULL), fSuffixOffset(0), |
| 331 fNumCopies(0), fNumUnitsSaved(0), fNumCharsForLength(numCharsForLe
ngth) { |
| 332 // v3 pool string encoded as string-v2 with low offset |
| 333 fRes = URES_MAKE_RESOURCE(URES_STRING_V2, poolStringIndex); |
| 334 fWritten = TRUE; |
| 335 } |
| 336 virtual ~StringResource(); |
| 337 |
| 338 int32_t get16BitStringsLength() const { |
| 339 return fNumCharsForLength + length() + 1; // +1 for the NUL |
| 340 } |
| 341 |
| 342 virtual void handlePreflightStrings(SRBRoot *bundle, UHashtable *stringSet,
UErrorCode &errorCode); |
| 343 virtual void handleWrite16(SRBRoot *bundle); |
| 344 |
| 345 void writeUTF16v2(int32_t base, icu::UnicodeString &dest); |
| 346 |
| 347 StringResource *fSame; // used for duplicates |
| 348 int32_t fSuffixOffset; // this string is a suffix of fSame at this offset |
| 349 int32_t fNumCopies; // number of equal strings represented by one string
Set element |
| 350 int32_t fNumUnitsSaved; // from not writing duplicates and suffixes |
128 int8_t fNumCharsForLength; | 351 int8_t fNumCharsForLength; |
129 }; | 352 }; |
130 | 353 |
131 struct SResource *string_open(struct SRBRoot *bundle, const char *tag, const UCh
ar *value, int32_t len, const struct UString* comment, UErrorCode *status); | 354 class AliasResource : public StringBaseResource { |
132 | 355 public: |
133 struct SResource *alias_open(struct SRBRoot *bundle, const char *tag, UChar *val
ue, int32_t len, const struct UString* comment, UErrorCode *status); | 356 AliasResource(SRBRoot *bundle, const char *tag, const UChar *value, int32_t
len, |
134 | 357 const UString* comment, UErrorCode &errorCode) |
135 struct SResIntVector { | 358 : StringBaseResource(bundle, tag, URES_ALIAS, value, len, comment, e
rrorCode) {} |
| 359 virtual ~AliasResource(); |
| 360 }; |
| 361 |
| 362 class IntResource : public SResource { |
| 363 public: |
| 364 IntResource(SRBRoot *bundle, const char *tag, int32_t value, |
| 365 const UString* comment, UErrorCode &errorCode); |
| 366 virtual ~IntResource(); |
| 367 |
| 368 // TODO: private with getter? |
| 369 int32_t fValue; |
| 370 }; |
| 371 |
| 372 class IntVectorResource : public SResource { |
| 373 public: |
| 374 IntVectorResource(SRBRoot *bundle, const char *tag, |
| 375 const UString* comment, UErrorCode &errorCode); |
| 376 virtual ~IntVectorResource(); |
| 377 |
| 378 void add(int32_t value, UErrorCode &errorCode); |
| 379 |
| 380 virtual void handlePreWrite(uint32_t *byteOffset); |
| 381 virtual void handleWrite(UNewDataMemory *mem, uint32_t *byteOffset); |
| 382 |
| 383 // TODO: UVector32 |
136 uint32_t fCount; | 384 uint32_t fCount; |
137 uint32_t *fArray; | 385 uint32_t *fArray; |
138 }; | 386 }; |
139 | 387 |
140 struct SResource* intvector_open(struct SRBRoot *bundle, const char *tag, const
struct UString* comment, UErrorCode *status); | 388 class BinaryResource : public SResource { |
141 void intvector_add(struct SResource *intvector, int32_t value, UErrorCode *statu
s); | 389 public: |
142 | 390 BinaryResource(SRBRoot *bundle, const char *tag, |
143 struct SResInt { | 391 uint32_t length, uint8_t *data, const char* fileName, |
144 uint32_t fValue; | 392 const UString* comment, UErrorCode &errorCode); |
145 }; | 393 virtual ~BinaryResource(); |
146 | 394 |
147 struct SResource *int_open(struct SRBRoot *bundle, const char *tag, int32_t valu
e, const struct UString* comment, UErrorCode *status); | 395 virtual void handlePreWrite(uint32_t *byteOffset); |
148 | 396 virtual void handleWrite(UNewDataMemory *mem, uint32_t *byteOffset); |
149 struct SResBinary { | 397 |
| 398 // TODO: CharString? |
150 uint32_t fLength; | 399 uint32_t fLength; |
151 uint8_t *fData; | 400 uint8_t *fData; |
152 char* fFileName; /* file name for binary or import binary tags if any */ | 401 // TODO: CharString |
153 }; | 402 char* fFileName; // file name for binary or import binary tags if any |
154 | 403 }; |
155 struct SResource *bin_open(struct SRBRoot *bundle, const char *tag, uint32_t len
gth, uint8_t *data, const char* fileName, const struct UString* comment, UErrorC
ode *status); | 404 |
156 | 405 // TODO: use LocalPointer or delete |
157 /* Resource place holder */ | |
158 | |
159 struct SResource { | |
160 int8_t fType; /* nominal type: fRes (when != 0xffffffff) may use subty
pe */ | |
161 UBool fWritten; /* res_write() can exit early */ | |
162 uint32_t fRes; /* resource item word; 0xffffffff if not known yet */ | |
163 int32_t fKey; /* Index into bundle->fKeys; -1 if no key. */ | |
164 int line; /* used internally to report duplicate keys in tables */ | |
165 struct SResource *fNext; /*This is for internal chaining while building*/ | |
166 struct UString fComment; | |
167 union { | |
168 struct SResTable fTable; | |
169 struct SResArray fArray; | |
170 struct SResString fString; | |
171 struct SResIntVector fIntVector; | |
172 struct SResInt fIntValue; | |
173 struct SResBinary fBinaryValue; | |
174 } u; | |
175 }; | |
176 | |
177 const char * | |
178 res_getKeyString(const struct SRBRoot *bundle, const struct SResource *res, char
temp[8]); | |
179 | |
180 void res_close(struct SResource *res); | 406 void res_close(struct SResource *res); |
181 | 407 |
182 void setIncludeCopyright(UBool val); | 408 void setIncludeCopyright(UBool val); |
183 UBool getIncludeCopyright(void); | 409 UBool getIncludeCopyright(void); |
184 | 410 |
185 void setFormatVersion(int32_t formatVersion); | 411 void setFormatVersion(int32_t formatVersion); |
186 | 412 |
| 413 int32_t getFormatVersion(); |
| 414 |
187 void setUsePoolBundle(UBool use); | 415 void setUsePoolBundle(UBool use); |
188 | 416 |
189 /* in wrtxml.cpp */ | 417 /* in wrtxml.cpp */ |
190 uint32_t computeCRC(char *ptr, uint32_t len, uint32_t lastcrc); | 418 uint32_t computeCRC(const char *ptr, uint32_t len, uint32_t lastcrc); |
191 | 419 |
192 U_CDECL_END | 420 U_CDECL_END |
193 #endif /* #ifndef RESLIST_H */ | 421 #endif /* #ifndef RESLIST_H */ |
OLD | NEW |