]> git.saurik.com Git - apple/icu.git/blame - icuSources/tools/genrb/reslist.h
ICU-531.30.tar.gz
[apple/icu.git] / icuSources / tools / genrb / reslist.h
CommitLineData
b75a7d8f
A
1/*
2*******************************************************************************
3*
57a6839d 4* Copyright (C) 2000-2014, International Business Machines
b75a7d8f
A
5* Corporation and others. All Rights Reserved.
6*
7*******************************************************************************
8*
9* File reslist.h
10*
11* Modification History:
12*
13* Date Name Description
14* 02/21/00 weiv Creation.
15*******************************************************************************
16*/
17
18#ifndef RESLIST_H
19#define RESLIST_H
20
374ca955 21#define KEY_SPACE_SIZE 65536
b75a7d8f
A
22#define RESLIST_MAX_INT_VECTOR 2048
23
24#include "unicode/utypes.h"
25#include "unicode/ures.h"
26#include "unicode/ustring.h"
27#include "uresdata.h"
28#include "cmemory.h"
29#include "cstring.h"
30#include "unewdata.h"
374ca955 31#include "ustr.h"
b75a7d8f
A
32
33U_CDECL_BEGIN
34
729e4ab9
A
35typedef struct KeyMapEntry {
36 int32_t oldpos, newpos;
37} KeyMapEntry;
38
b75a7d8f
A
39/* Resource bundle root table */
40struct SRBRoot {
374ca955 41 struct SResource *fRoot;
729e4ab9
A
42 char *fLocale;
43 int32_t fIndexLength;
374ca955 44 int32_t fMaxTableLength;
73c04bcf 45 UBool noFallback; /* see URES_ATT_NO_FALLBACK */
729e4ab9
A
46 int8_t fStringsForm; /* default STRINGS_UTF16_V1 */
47 UBool fIsPoolBundle;
48
49 char *fKeys;
50 KeyMapEntry *fKeyMap;
51 int32_t fKeysBottom, fKeysTop;
52 int32_t fKeysCapacity;
53 int32_t fKeysCount;
54 int32_t fLocalKeyLimit; /* key offset < limit fits into URES_TABLE */
55
729e4ab9
A
56 uint16_t *f16BitUnits;
57 int32_t f16BitUnitsCapacity;
58 int32_t f16BitUnitsLength;
59
60 const char *fPoolBundleKeys;
61 int32_t fPoolBundleKeysLength;
62 int32_t fPoolBundleKeysCount;
63 int32_t fPoolChecksum;
b75a7d8f
A
64};
65
729e4ab9 66struct SRBRoot *bundle_open(const struct UString* comment, UBool isPoolBundle, UErrorCode *status);
b75a7d8f
A
67void bundle_write(struct SRBRoot *bundle, const char *outputDir, const char *outputPkg, char *writtenFilename, int writtenFilenameLen, UErrorCode *status);
68
69/* write a java resource file */
70void bundle_write_java(struct SRBRoot *bundle, const char *outputDir, const char* outputEnc, char *writtenFilename,
71 int writtenFilenameLen, const char* packageName, const char* bundleName, UErrorCode *status);
72
73/* write a xml resource file */
74/* commented by Jing*/
75/* void bundle_write_xml(struct SRBRoot *bundle, const char *outputDir,const char* outputEnc,
76 char *writtenFilename, int writtenFilenameLen,UErrorCode *status); */
77
78/* added by Jing*/
79void bundle_write_xml(struct SRBRoot *bundle, const char *outputDir,const char* outputEnc, const char* rbname,
80 char *writtenFilename, int writtenFilenameLen, const char* language, const char* package, UErrorCode *status);
81
82void bundle_close(struct SRBRoot *bundle, UErrorCode *status);
83void bundle_setlocale(struct SRBRoot *bundle, UChar *locale, UErrorCode *status);
374ca955 84int32_t bundle_addtag(struct SRBRoot *bundle, const char *tag, UErrorCode *status);
b75a7d8f 85
729e4ab9
A
86const char *
87bundle_getKeyBytes(struct SRBRoot *bundle, int32_t *pLength);
88
89int32_t
90bundle_addKeyBytes(struct SRBRoot *bundle, const char *keyBytes, int32_t length, UErrorCode *status);
91
92void
93bundle_compactKeys(struct SRBRoot *bundle, UErrorCode *status);
94
b75a7d8f
A
95/* Various resource types */
96
46f4442e
A
97/*
98 * 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.
100 * (NULL is used in error cases.)
101 */
102struct SResource* res_none(void);
103
b75a7d8f 104struct SResTable {
374ca955 105 uint32_t fCount;
729e4ab9 106 int8_t fType; /* determined by table_write16() for table_preWrite() & table_write() */
b75a7d8f
A
107 struct SResource *fFirst;
108 struct SRBRoot *fRoot;
109};
110
729e4ab9 111struct SResource* table_open(struct SRBRoot *bundle, const char *tag, const struct UString* comment, UErrorCode *status);
b75a7d8f
A
112void table_add(struct SResource *table, struct SResource *res, int linenumber, UErrorCode *status);
113
114struct SResArray {
115 uint32_t fCount;
b75a7d8f
A
116 struct SResource *fFirst;
117 struct SResource *fLast;
118};
119
73c04bcf 120struct SResource* array_open(struct SRBRoot *bundle, const char *tag, const struct UString* comment, UErrorCode *status);
b75a7d8f
A
121void array_add(struct SResource *array, struct SResource *res, UErrorCode *status);
122
123struct SResString {
729e4ab9 124 struct SResource *fSame; /* used for duplicates */
b75a7d8f 125 UChar *fChars;
729e4ab9
A
126 int32_t fLength;
127 int32_t fSuffixOffset; /* this string is a suffix of fSame at this offset */
128 int8_t fNumCharsForLength;
b75a7d8f
A
129};
130
4388f060 131struct SResource *string_open(struct SRBRoot *bundle, const char *tag, const UChar *value, int32_t len, const struct UString* comment, UErrorCode *status);
b75a7d8f 132
4388f060 133struct SResource *alias_open(struct SRBRoot *bundle, const char *tag, UChar *value, int32_t len, const struct UString* comment, UErrorCode *status);
b75a7d8f
A
134
135struct SResIntVector {
136 uint32_t fCount;
137 uint32_t *fArray;
138};
139
4388f060 140struct SResource* intvector_open(struct SRBRoot *bundle, const char *tag, const struct UString* comment, UErrorCode *status);
b75a7d8f
A
141void intvector_add(struct SResource *intvector, int32_t value, UErrorCode *status);
142
143struct SResInt {
144 uint32_t fValue;
145};
146
4388f060 147struct SResource *int_open(struct SRBRoot *bundle, const char *tag, int32_t value, const struct UString* comment, UErrorCode *status);
b75a7d8f
A
148
149struct SResBinary {
150 uint32_t fLength;
151 uint8_t *fData;
152 char* fFileName; /* file name for binary or import binary tags if any */
153};
154
374ca955 155struct SResource *bin_open(struct SRBRoot *bundle, const char *tag, uint32_t length, uint8_t *data, const char* fileName, const struct UString* comment, UErrorCode *status);
b75a7d8f
A
156
157/* Resource place holder */
158
159struct SResource {
729e4ab9
A
160 int8_t fType; /* nominal type: fRes (when != 0xffffffff) may use subtype */
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 */
b75a7d8f 165 struct SResource *fNext; /*This is for internal chaining while building*/
46f4442e 166 struct UString fComment;
b75a7d8f
A
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
729e4ab9
A
177const char *
178res_getKeyString(const struct SRBRoot *bundle, const struct SResource *res, char temp[8]);
179
46f4442e 180void res_close(struct SResource *res);
729e4ab9 181
b75a7d8f
A
182void setIncludeCopyright(UBool val);
183UBool getIncludeCopyright(void);
184
729e4ab9
A
185void setFormatVersion(int32_t formatVersion);
186
187void setUsePoolBundle(UBool use);
188
189/* in wrtxml.cpp */
190uint32_t computeCRC(char *ptr, uint32_t len, uint32_t lastcrc);
191
b75a7d8f
A
192U_CDECL_END
193#endif /* #ifndef RESLIST_H */