2 *******************************************************************************
4 * Copyright (C) 2000-2011, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
11 * Modification History:
13 * Date Name Description
14 * 02/21/00 weiv Creation.
15 *******************************************************************************
21 #define KEY_SPACE_SIZE 65536
22 #define RESLIST_MAX_INT_VECTOR 2048
24 #include "unicode/utypes.h"
25 #include "unicode/ures.h"
26 #include "unicode/ustring.h"
36 typedef struct KeyMapEntry {
37 int32_t oldpos, newpos;
40 /* Resource bundle root table */
42 struct SResource *fRoot;
45 int32_t fMaxTableLength;
46 UBool noFallback; /* see URES_ATT_NO_FALLBACK */
47 int8_t fStringsForm; /* default STRINGS_UTF16_V1 */
52 int32_t fKeysBottom, fKeysTop;
53 int32_t fKeysCapacity;
55 int32_t fLocalKeyLimit; /* key offset < limit fits into URES_TABLE */
57 UHashtable *fStringSet;
58 uint16_t *f16BitUnits;
59 int32_t f16BitUnitsCapacity;
60 int32_t f16BitUnitsLength;
62 const char *fPoolBundleKeys;
63 int32_t fPoolBundleKeysLength;
64 int32_t fPoolBundleKeysCount;
65 int32_t fPoolChecksum;
68 struct SRBRoot *bundle_open(const struct UString* comment, UBool isPoolBundle, UErrorCode *status);
69 void bundle_write(struct SRBRoot *bundle, const char *outputDir, const char *outputPkg, char *writtenFilename, int writtenFilenameLen, UErrorCode *status);
71 /* write a java resource file */
72 void bundle_write_java(struct SRBRoot *bundle, const char *outputDir, const char* outputEnc, char *writtenFilename,
73 int writtenFilenameLen, const char* packageName, const char* bundleName, UErrorCode *status);
75 /* write a xml resource file */
76 /* commented by Jing*/
77 /* void bundle_write_xml(struct SRBRoot *bundle, const char *outputDir,const char* outputEnc,
78 char *writtenFilename, int writtenFilenameLen,UErrorCode *status); */
81 void bundle_write_xml(struct SRBRoot *bundle, const char *outputDir,const char* outputEnc, const char* rbname,
82 char *writtenFilename, int writtenFilenameLen, const char* language, const char* package, UErrorCode *status);
84 void bundle_close(struct SRBRoot *bundle, UErrorCode *status);
85 void bundle_setlocale(struct SRBRoot *bundle, UChar *locale, UErrorCode *status);
86 int32_t bundle_addtag(struct SRBRoot *bundle, const char *tag, UErrorCode *status);
89 bundle_getKeyBytes(struct SRBRoot *bundle, int32_t *pLength);
92 bundle_addKeyBytes(struct SRBRoot *bundle, const char *keyBytes, int32_t length, UErrorCode *status);
95 bundle_compactKeys(struct SRBRoot *bundle, UErrorCode *status);
97 /* Various resource types */
100 * Return a unique pointer to a dummy object,
101 * for use in non-error cases when no resource is to be added to the bundle.
102 * (NULL is used in error cases.)
104 struct SResource* res_none(void);
108 int8_t fType; /* determined by table_write16() for table_preWrite() & table_write() */
109 struct SResource *fFirst;
110 struct SRBRoot *fRoot;
113 struct SResource* table_open(struct SRBRoot *bundle, const char *tag, const struct UString* comment, UErrorCode *status);
114 void table_add(struct SResource *table, struct SResource *res, int linenumber, UErrorCode *status);
118 struct SResource *fFirst;
119 struct SResource *fLast;
122 struct SResource* array_open(struct SRBRoot *bundle, const char *tag, const struct UString* comment, UErrorCode *status);
123 void array_add(struct SResource *array, struct SResource *res, UErrorCode *status);
126 struct SResource *fSame; /* used for duplicates */
129 int32_t fSuffixOffset; /* this string is a suffix of fSame at this offset */
130 int8_t fNumCharsForLength;
133 struct SResource *string_open(struct SRBRoot *bundle, const char *tag, const UChar *value, int32_t len, const struct UString* comment, UErrorCode *status);
136 * Remove a string from a bundle and close (delete) it.
137 * The string must not have been added to a table or array yet.
138 * This function only undoes what string_open() did.
140 void bundle_closeString(struct SRBRoot *bundle, struct SResource *string);
142 struct SResource *alias_open(struct SRBRoot *bundle, const char *tag, UChar *value, int32_t len, const struct UString* comment, UErrorCode *status);
144 struct SResIntVector {
149 struct SResource* intvector_open(struct SRBRoot *bundle, const char *tag, const struct UString* comment, UErrorCode *status);
150 void intvector_add(struct SResource *intvector, int32_t value, UErrorCode *status);
156 struct SResource *int_open(struct SRBRoot *bundle, const char *tag, int32_t value, const struct UString* comment, UErrorCode *status);
161 char* fFileName; /* file name for binary or import binary tags if any */
164 struct SResource *bin_open(struct SRBRoot *bundle, const char *tag, uint32_t length, uint8_t *data, const char* fileName, const struct UString* comment, UErrorCode *status);
166 /* Resource place holder */
169 int8_t fType; /* nominal type: fRes (when != 0xffffffff) may use subtype */
170 UBool fWritten; /* res_write() can exit early */
171 uint32_t fRes; /* resource item word; 0xffffffff if not known yet */
172 int32_t fKey; /* Index into bundle->fKeys; -1 if no key. */
173 int line; /* used internally to report duplicate keys in tables */
174 struct SResource *fNext; /*This is for internal chaining while building*/
175 struct UString fComment;
177 struct SResTable fTable;
178 struct SResArray fArray;
179 struct SResString fString;
180 struct SResIntVector fIntVector;
181 struct SResInt fIntValue;
182 struct SResBinary fBinaryValue;
187 res_getKeyString(const struct SRBRoot *bundle, const struct SResource *res, char temp[8]);
189 void res_close(struct SResource *res);
191 void setIncludeCopyright(UBool val);
192 UBool getIncludeCopyright(void);
194 void setFormatVersion(int32_t formatVersion);
196 void setUsePoolBundle(UBool use);
199 uint32_t computeCRC(char *ptr, uint32_t len, uint32_t lastcrc);
202 #endif /* #ifndef RESLIST_H */