1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/tools/genrb/reslist.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,202 @@ 1.4 +/* 1.5 +******************************************************************************* 1.6 +* 1.7 +* Copyright (C) 2000-2011, International Business Machines 1.8 +* Corporation and others. All Rights Reserved. 1.9 +* 1.10 +******************************************************************************* 1.11 +* 1.12 +* File reslist.h 1.13 +* 1.14 +* Modification History: 1.15 +* 1.16 +* Date Name Description 1.17 +* 02/21/00 weiv Creation. 1.18 +******************************************************************************* 1.19 +*/ 1.20 + 1.21 +#ifndef RESLIST_H 1.22 +#define RESLIST_H 1.23 + 1.24 +#define KEY_SPACE_SIZE 65536 1.25 +#define RESLIST_MAX_INT_VECTOR 2048 1.26 + 1.27 +#include "unicode/utypes.h" 1.28 +#include "unicode/ures.h" 1.29 +#include "unicode/ustring.h" 1.30 +#include "uresdata.h" 1.31 +#include "cmemory.h" 1.32 +#include "cstring.h" 1.33 +#include "unewdata.h" 1.34 +#include "ustr.h" 1.35 +#include "uhash.h" 1.36 + 1.37 +U_CDECL_BEGIN 1.38 + 1.39 +typedef struct KeyMapEntry { 1.40 + int32_t oldpos, newpos; 1.41 +} KeyMapEntry; 1.42 + 1.43 +/* Resource bundle root table */ 1.44 +struct SRBRoot { 1.45 + struct SResource *fRoot; 1.46 + char *fLocale; 1.47 + int32_t fIndexLength; 1.48 + int32_t fMaxTableLength; 1.49 + UBool noFallback; /* see URES_ATT_NO_FALLBACK */ 1.50 + int8_t fStringsForm; /* default STRINGS_UTF16_V1 */ 1.51 + UBool fIsPoolBundle; 1.52 + 1.53 + char *fKeys; 1.54 + KeyMapEntry *fKeyMap; 1.55 + int32_t fKeysBottom, fKeysTop; 1.56 + int32_t fKeysCapacity; 1.57 + int32_t fKeysCount; 1.58 + int32_t fLocalKeyLimit; /* key offset < limit fits into URES_TABLE */ 1.59 + 1.60 + UHashtable *fStringSet; 1.61 + uint16_t *f16BitUnits; 1.62 + int32_t f16BitUnitsCapacity; 1.63 + int32_t f16BitUnitsLength; 1.64 + 1.65 + const char *fPoolBundleKeys; 1.66 + int32_t fPoolBundleKeysLength; 1.67 + int32_t fPoolBundleKeysCount; 1.68 + int32_t fPoolChecksum; 1.69 +}; 1.70 + 1.71 +struct SRBRoot *bundle_open(const struct UString* comment, UBool isPoolBundle, UErrorCode *status); 1.72 +void bundle_write(struct SRBRoot *bundle, const char *outputDir, const char *outputPkg, char *writtenFilename, int writtenFilenameLen, UErrorCode *status); 1.73 + 1.74 +/* write a java resource file */ 1.75 +void bundle_write_java(struct SRBRoot *bundle, const char *outputDir, const char* outputEnc, char *writtenFilename, 1.76 + int writtenFilenameLen, const char* packageName, const char* bundleName, UErrorCode *status); 1.77 + 1.78 +/* write a xml resource file */ 1.79 +/* commented by Jing*/ 1.80 +/* void bundle_write_xml(struct SRBRoot *bundle, const char *outputDir,const char* outputEnc, 1.81 + char *writtenFilename, int writtenFilenameLen,UErrorCode *status); */ 1.82 + 1.83 +/* added by Jing*/ 1.84 +void bundle_write_xml(struct SRBRoot *bundle, const char *outputDir,const char* outputEnc, const char* rbname, 1.85 + char *writtenFilename, int writtenFilenameLen, const char* language, const char* package, UErrorCode *status); 1.86 + 1.87 +void bundle_close(struct SRBRoot *bundle, UErrorCode *status); 1.88 +void bundle_setlocale(struct SRBRoot *bundle, UChar *locale, UErrorCode *status); 1.89 +int32_t bundle_addtag(struct SRBRoot *bundle, const char *tag, UErrorCode *status); 1.90 + 1.91 +const char * 1.92 +bundle_getKeyBytes(struct SRBRoot *bundle, int32_t *pLength); 1.93 + 1.94 +int32_t 1.95 +bundle_addKeyBytes(struct SRBRoot *bundle, const char *keyBytes, int32_t length, UErrorCode *status); 1.96 + 1.97 +void 1.98 +bundle_compactKeys(struct SRBRoot *bundle, UErrorCode *status); 1.99 + 1.100 +/* Various resource types */ 1.101 + 1.102 +/* 1.103 + * Return a unique pointer to a dummy object, 1.104 + * for use in non-error cases when no resource is to be added to the bundle. 1.105 + * (NULL is used in error cases.) 1.106 + */ 1.107 +struct SResource* res_none(void); 1.108 + 1.109 +struct SResTable { 1.110 + uint32_t fCount; 1.111 + int8_t fType; /* determined by table_write16() for table_preWrite() & table_write() */ 1.112 + struct SResource *fFirst; 1.113 + struct SRBRoot *fRoot; 1.114 +}; 1.115 + 1.116 +struct SResource* table_open(struct SRBRoot *bundle, const char *tag, const struct UString* comment, UErrorCode *status); 1.117 +void table_add(struct SResource *table, struct SResource *res, int linenumber, UErrorCode *status); 1.118 + 1.119 +struct SResArray { 1.120 + uint32_t fCount; 1.121 + struct SResource *fFirst; 1.122 + struct SResource *fLast; 1.123 +}; 1.124 + 1.125 +struct SResource* array_open(struct SRBRoot *bundle, const char *tag, const struct UString* comment, UErrorCode *status); 1.126 +void array_add(struct SResource *array, struct SResource *res, UErrorCode *status); 1.127 + 1.128 +struct SResString { 1.129 + struct SResource *fSame; /* used for duplicates */ 1.130 + UChar *fChars; 1.131 + int32_t fLength; 1.132 + int32_t fSuffixOffset; /* this string is a suffix of fSame at this offset */ 1.133 + int8_t fNumCharsForLength; 1.134 +}; 1.135 + 1.136 +struct SResource *string_open(struct SRBRoot *bundle, const char *tag, const UChar *value, int32_t len, const struct UString* comment, UErrorCode *status); 1.137 + 1.138 +/** 1.139 + * Remove a string from a bundle and close (delete) it. 1.140 + * The string must not have been added to a table or array yet. 1.141 + * This function only undoes what string_open() did. 1.142 + */ 1.143 +void bundle_closeString(struct SRBRoot *bundle, struct SResource *string); 1.144 + 1.145 +struct SResource *alias_open(struct SRBRoot *bundle, const char *tag, UChar *value, int32_t len, const struct UString* comment, UErrorCode *status); 1.146 + 1.147 +struct SResIntVector { 1.148 + uint32_t fCount; 1.149 + uint32_t *fArray; 1.150 +}; 1.151 + 1.152 +struct SResource* intvector_open(struct SRBRoot *bundle, const char *tag, const struct UString* comment, UErrorCode *status); 1.153 +void intvector_add(struct SResource *intvector, int32_t value, UErrorCode *status); 1.154 + 1.155 +struct SResInt { 1.156 + uint32_t fValue; 1.157 +}; 1.158 + 1.159 +struct SResource *int_open(struct SRBRoot *bundle, const char *tag, int32_t value, const struct UString* comment, UErrorCode *status); 1.160 + 1.161 +struct SResBinary { 1.162 + uint32_t fLength; 1.163 + uint8_t *fData; 1.164 + char* fFileName; /* file name for binary or import binary tags if any */ 1.165 +}; 1.166 + 1.167 +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); 1.168 + 1.169 +/* Resource place holder */ 1.170 + 1.171 +struct SResource { 1.172 + int8_t fType; /* nominal type: fRes (when != 0xffffffff) may use subtype */ 1.173 + UBool fWritten; /* res_write() can exit early */ 1.174 + uint32_t fRes; /* resource item word; 0xffffffff if not known yet */ 1.175 + int32_t fKey; /* Index into bundle->fKeys; -1 if no key. */ 1.176 + int line; /* used internally to report duplicate keys in tables */ 1.177 + struct SResource *fNext; /*This is for internal chaining while building*/ 1.178 + struct UString fComment; 1.179 + union { 1.180 + struct SResTable fTable; 1.181 + struct SResArray fArray; 1.182 + struct SResString fString; 1.183 + struct SResIntVector fIntVector; 1.184 + struct SResInt fIntValue; 1.185 + struct SResBinary fBinaryValue; 1.186 + } u; 1.187 +}; 1.188 + 1.189 +const char * 1.190 +res_getKeyString(const struct SRBRoot *bundle, const struct SResource *res, char temp[8]); 1.191 + 1.192 +void res_close(struct SResource *res); 1.193 + 1.194 +void setIncludeCopyright(UBool val); 1.195 +UBool getIncludeCopyright(void); 1.196 + 1.197 +void setFormatVersion(int32_t formatVersion); 1.198 + 1.199 +void setUsePoolBundle(UBool use); 1.200 + 1.201 +/* in wrtxml.cpp */ 1.202 +uint32_t computeCRC(char *ptr, uint32_t len, uint32_t lastcrc); 1.203 + 1.204 +U_CDECL_END 1.205 +#endif /* #ifndef RESLIST_H */