intl/icu/source/tools/genrb/reslist.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /*
     2 *******************************************************************************
     3 *
     4 *   Copyright (C) 2000-2011, International Business Machines
     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 */
    18 #ifndef RESLIST_H
    19 #define RESLIST_H
    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"
    27 #include "uresdata.h"
    28 #include "cmemory.h"
    29 #include "cstring.h"
    30 #include "unewdata.h"
    31 #include "ustr.h"
    32 #include "uhash.h"
    34 U_CDECL_BEGIN
    36 typedef struct KeyMapEntry {
    37     int32_t oldpos, newpos;
    38 } KeyMapEntry;
    40 /* Resource bundle root table */
    41 struct SRBRoot {
    42   struct SResource *fRoot;
    43   char *fLocale;
    44   int32_t fIndexLength;
    45   int32_t fMaxTableLength;
    46   UBool noFallback; /* see URES_ATT_NO_FALLBACK */
    47   int8_t fStringsForm; /* default STRINGS_UTF16_V1 */
    48   UBool fIsPoolBundle;
    50   char *fKeys;
    51   KeyMapEntry *fKeyMap;
    52   int32_t fKeysBottom, fKeysTop;
    53   int32_t fKeysCapacity;
    54   int32_t fKeysCount;
    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;
    66 };
    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); */
    80 /* added by Jing*/
    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);
    88 const char *
    89 bundle_getKeyBytes(struct SRBRoot *bundle, int32_t *pLength);
    91 int32_t
    92 bundle_addKeyBytes(struct SRBRoot *bundle, const char *keyBytes, int32_t length, UErrorCode *status);
    94 void
    95 bundle_compactKeys(struct SRBRoot *bundle, UErrorCode *status);
    97 /* Various resource types */
    99 /*
   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.)
   103  */
   104 struct SResource* res_none(void);
   106 struct SResTable {
   107     uint32_t fCount;
   108     int8_t fType;  /* determined by table_write16() for table_preWrite() & table_write() */
   109     struct SResource *fFirst;
   110     struct SRBRoot *fRoot;
   111 };
   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);
   116 struct SResArray {
   117     uint32_t fCount;
   118     struct SResource *fFirst;
   119     struct SResource *fLast;
   120 };
   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);
   125 struct SResString {
   126     struct SResource *fSame;  /* used for duplicates */
   127     UChar *fChars;
   128     int32_t fLength;
   129     int32_t fSuffixOffset;  /* this string is a suffix of fSame at this offset */
   130     int8_t fNumCharsForLength;
   131 };
   133 struct SResource *string_open(struct SRBRoot *bundle, const char *tag, const UChar *value, int32_t len, const struct UString* comment, UErrorCode *status);
   135 /**
   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.
   139  */
   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 {
   145     uint32_t fCount;
   146     uint32_t *fArray;
   147 };
   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);
   152 struct SResInt {
   153     uint32_t fValue;
   154 };
   156 struct SResource *int_open(struct SRBRoot *bundle, const char *tag, int32_t value, const struct UString* comment, UErrorCode *status);
   158 struct SResBinary {
   159     uint32_t fLength;
   160     uint8_t *fData;
   161     char* fFileName; /* file name for binary or import binary tags if any */
   162 };
   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 */
   168 struct SResource {
   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;
   176     union {
   177         struct SResTable fTable;
   178         struct SResArray fArray;
   179         struct SResString fString;
   180         struct SResIntVector fIntVector;
   181         struct SResInt fIntValue;
   182         struct SResBinary fBinaryValue;
   183     } u;
   184 };
   186 const char *
   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);
   198 /* in wrtxml.cpp */
   199 uint32_t computeCRC(char *ptr, uint32_t len, uint32_t lastcrc);
   201 U_CDECL_END
   202 #endif /* #ifndef RESLIST_H */

mercurial