annotate modules/javafx.web/src/main/native/Source/ThirdParty/icu/source/common/uresimp.h @ 11348:6744f504e684

8231310: Add .jcheck/conf to jfx git repo Reviewed-by: prr, jvos
author kcr
date Tue, 01 Oct 2019 05:28:24 -0700
parents fee4ef5c87df
children
rev   line source
arajkumar@11038 1 // © 2016 and later: Unicode, Inc. and others.
arajkumar@11038 2 // License & terms of use: http://www.unicode.org/copyright.html
ghb@10550 3 /*
ghb@10550 4 **********************************************************************
arajkumar@11038 5 * Copyright (C) 2000-2016, International Business Machines
ghb@10550 6 * Corporation and others. All Rights Reserved.
ghb@10550 7 **********************************************************************
ghb@10550 8 */
ghb@10550 9
ghb@10550 10 #ifndef URESIMP_H
ghb@10550 11 #define URESIMP_H
ghb@10550 12
ghb@10550 13 #include "unicode/ures.h"
ghb@10550 14
ghb@10550 15 #include "uresdata.h"
ghb@10550 16
ghb@10550 17 #define kRootLocaleName "root"
ghb@10550 18 #define kPoolBundleName "pool"
ghb@10550 19
ghb@10550 20 /*
ghb@10550 21 The default minor version and the version separator must be exactly one
ghb@10550 22 character long.
ghb@10550 23 */
ghb@10550 24
ghb@10550 25 #define kDefaultMinorVersion "0"
ghb@10550 26 #define kVersionSeparator "."
ghb@10550 27 #define kVersionTag "Version"
ghb@10550 28
ghb@10550 29 #define MAGIC1 19700503
ghb@10550 30 #define MAGIC2 19641227
ghb@10550 31
ghb@10550 32 #define URES_MAX_ALIAS_LEVEL 256
ghb@10550 33 #define URES_MAX_BUFFER_SIZE 256
ghb@10550 34
ghb@10550 35 #define EMPTY_SET 0x2205
ghb@10550 36
ghb@10550 37 struct UResourceDataEntry;
ghb@10550 38 typedef struct UResourceDataEntry UResourceDataEntry;
ghb@10550 39
ghb@10550 40 /*
ghb@10550 41 * Note: If we wanted to make this structure smaller, then we could try
ghb@10550 42 * to use one UResourceDataEntry pointer for fAlias and fPool, with a separate
ghb@10550 43 * flag to distinguish whether this struct is for a real bundle with a pool,
ghb@10550 44 * or for an alias entry for which we won't use the pool after loading.
ghb@10550 45 */
ghb@10550 46 struct UResourceDataEntry {
ghb@10550 47 char *fName; /* name of the locale for bundle - still to decide whether it is original or fallback */
ghb@10550 48 char *fPath; /* path to bundle - used for distinguishing between resources with the same name */
ghb@10550 49 UResourceDataEntry *fParent; /*next resource in fallback chain*/
ghb@10550 50 UResourceDataEntry *fAlias;
ghb@10550 51 UResourceDataEntry *fPool;
ghb@10550 52 ResourceData fData; /* data for low level access */
ghb@10550 53 char fNameBuffer[3]; /* A small buffer of free space for fName. The free space is due to struct padding. */
ghb@10550 54 uint32_t fCountExisting; /* how much is this resource used */
ghb@10550 55 UErrorCode fBogus;
ghb@10550 56 /* int32_t fHashKey;*/ /* for faster access in the hashtable */
ghb@10550 57 };
ghb@10550 58
ghb@10550 59 #define RES_BUFSIZE 64
ghb@10550 60 #define RES_PATH_SEPARATOR '/'
ghb@10550 61 #define RES_PATH_SEPARATOR_S "/"
ghb@10550 62
ghb@10550 63 struct UResourceBundle {
ghb@10550 64 const char *fKey; /*tag*/
ghb@10550 65 UResourceDataEntry *fData; /*for low-level access*/
ghb@10550 66 char *fVersion;
ghb@10550 67 UResourceDataEntry *fTopLevelData; /* for getting the valid locale */
ghb@10550 68 char *fResPath; /* full path to the resource: "zh_TW/CollationElements/Sequence" */
ghb@10550 69 ResourceData fResData;
ghb@10550 70 char fResBuf[RES_BUFSIZE];
ghb@10550 71 int32_t fResPathLen;
ghb@10550 72 Resource fRes;
ghb@10550 73 UBool fHasFallback;
ghb@10550 74 UBool fIsTopLevel;
ghb@10550 75 uint32_t fMagic1; /* For determining if it's a stack object */
ghb@10550 76 uint32_t fMagic2; /* For determining if it's a stack object */
ghb@10550 77 int32_t fIndex;
ghb@10550 78 int32_t fSize;
ghb@10550 79
ghb@10550 80 /*const UResourceBundle *fParentRes;*/ /* needed to get the actual locale for a child resource */
ghb@10550 81 };
ghb@10550 82
ghb@10550 83 U_CAPI void U_EXPORT2 ures_initStackObject(UResourceBundle* resB);
ghb@10550 84
arajkumar@11038 85 /**
arajkumar@11038 86 * Opens a resource bundle for the locale;
arajkumar@11038 87 * if there is not even a base language bundle, then loads the root bundle;
arajkumar@11038 88 * never falls back to the default locale.
arajkumar@11038 89 *
arajkumar@11038 90 * This is used for algorithms that have good pan-Unicode default behavior,
arajkumar@11038 91 * such as case mappings, collation, and segmentation (BreakIterator).
arajkumar@11038 92 */
arajkumar@11038 93 U_CAPI UResourceBundle* U_EXPORT2
arajkumar@11038 94 ures_openNoDefault(const char* path, const char* localeID, UErrorCode* status);
arajkumar@11038 95
ghb@10550 96 /* Some getters used by the copy constructor */
ghb@10550 97 U_CFUNC const char* ures_getName(const UResourceBundle* resB);
ghb@10550 98 #ifdef URES_DEBUG
ghb@10550 99 U_CFUNC const char* ures_getPath(const UResourceBundle* resB);
ghb@10550 100 /**
ghb@10550 101 * If anything was in the RB cache, dump it to the screen.
ghb@10550 102 * @return TRUE if there was anything into the cache
ghb@10550 103 */
ghb@10550 104 U_CAPI UBool U_EXPORT2 ures_dumpCacheContents(void);
ghb@10550 105 #endif
ghb@10550 106 /*U_CFUNC void ures_appendResPath(UResourceBundle *resB, const char* toAdd, int32_t lenToAdd);*/
ghb@10550 107 /*U_CFUNC void ures_setResPath(UResourceBundle *resB, const char* toAdd);*/
ghb@10550 108 /*U_CFUNC void ures_freeResPath(UResourceBundle *resB);*/
ghb@10550 109
ghb@10550 110 /* Candidates for export */
ghb@10550 111 U_CFUNC UResourceBundle *ures_copyResb(UResourceBundle *r, const UResourceBundle *original, UErrorCode *status);
ghb@10550 112
ghb@10550 113 /**
ghb@10550 114 * Returns a resource that can be located using the pathToResource argument. One needs optional package, locale
ghb@10550 115 * and path inside the locale, for example: "/myData/en/zoneStrings/3". Keys and indexes are supported. Keys
ghb@10550 116 * need to reference data in named structures, while indexes can reference both named and anonymous resources.
ghb@10550 117 * Features a fill-in parameter.
ghb@10550 118 *
ghb@10550 119 * Note, this function does NOT have a syntax for specifying items within a tree. May want to consider a
ghb@10550 120 * syntax that delineates between package/tree and resource.
ghb@10550 121 *
ghb@10550 122 * @param pathToResource a path that will lead to the requested resource
ghb@10550 123 * @param fillIn if NULL a new UResourceBundle struct is allocated and must be deleted by the caller.
ghb@10550 124 * Alternatively, you can supply a struct to be filled by this function.
ghb@10550 125 * @param status fills in the outgoing error code.
ghb@10550 126 * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it
ghb@10550 127 */
ghb@10550 128 U_CAPI UResourceBundle* U_EXPORT2
ghb@10550 129 ures_findResource(const char* pathToResource,
ghb@10550 130 UResourceBundle *fillIn, UErrorCode *status);
ghb@10550 131
ghb@10550 132 /**
ghb@10550 133 * Returns a sub resource that can be located using the pathToResource argument. One needs a path inside
ghb@10550 134 * the supplied resource, for example, if you have "en_US" resource bundle opened, you might ask for
ghb@10550 135 * "zoneStrings/3". Keys and indexes are supported. Keys
ghb@10550 136 * need to reference data in named structures, while indexes can reference both
ghb@10550 137 * named and anonymous resources.
ghb@10550 138 * Features a fill-in parameter.
ghb@10550 139 *
ghb@10550 140 * @param resourceBundle a resource
ghb@10550 141 * @param pathToResource a path that will lead to the requested resource
ghb@10550 142 * @param fillIn if NULL a new UResourceBundle struct is allocated and must be deleted by the caller.
ghb@10550 143 * Alternatively, you can supply a struct to be filled by this function.
ghb@10550 144 * @param status fills in the outgoing error code.
ghb@10550 145 * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it
ghb@10550 146 */
ghb@10550 147 U_CAPI UResourceBundle* U_EXPORT2
ghb@10550 148 ures_findSubResource(const UResourceBundle *resB,
ghb@10550 149 char* pathToResource,
ghb@10550 150 UResourceBundle *fillIn, UErrorCode *status);
ghb@10550 151
ghb@10550 152 /**
ghb@10550 153 * Returns a functionally equivalent locale (considering keywords) for the specified keyword.
ghb@10550 154 * @param result fillin for the equivalent locale
ghb@10550 155 * @param resultCapacity capacity of the fillin buffer
ghb@10550 156 * @param path path to the tree, or NULL for ICU data
ghb@10550 157 * @param resName top level resource. Example: "collations"
ghb@10550 158 * @param keyword locale keyword. Example: "collation"
ghb@10550 159 * @param locid The requested locale
ghb@10550 160 * @param isAvailable If non-null, pointer to fillin parameter that indicates whether the
ghb@10550 161 * requested locale was available. The locale is defined as 'available' if it physically
ghb@10550 162 * exists within the specified tree.
ghb@10550 163 * @param omitDefault if TRUE, omit keyword and value if default. 'de_DE\@collation=standard' -> 'de_DE'
ghb@10550 164 * @param status error code
ghb@10550 165 * @return the actual buffer size needed for the full locale. If it's greater
ghb@10550 166 * than resultCapacity, the returned full name will be truncated and an error code will be returned.
ghb@10550 167 */
ghb@10550 168 U_CAPI int32_t U_EXPORT2
ghb@10550 169 ures_getFunctionalEquivalent(char *result, int32_t resultCapacity,
ghb@10550 170 const char *path, const char *resName, const char *keyword, const char *locid,
ghb@10550 171 UBool *isAvailable, UBool omitDefault, UErrorCode *status);
ghb@10550 172
ghb@10550 173 /**
ghb@10550 174 * Given a tree path and keyword, return a string enumeration of all possible values for that keyword.
ghb@10550 175 * @param path path to the tree, or NULL for ICU data
ghb@10550 176 * @param keyword a particular keyword to consider, must match a top level resource name
ghb@10550 177 * within the tree.
ghb@10550 178 * @param status error code
ghb@10550 179 */
ghb@10550 180 U_CAPI UEnumeration* U_EXPORT2
ghb@10550 181 ures_getKeywordValues(const char *path, const char *keyword, UErrorCode *status);
ghb@10550 182
ghb@10550 183
ghb@10550 184 /**
ghb@10550 185 * Get a resource with multi-level fallback. Normally only the top level resources will
ghb@10550 186 * fallback to its parent. This performs fallback on subresources. For example, when a table
ghb@10550 187 * is defined in a resource bundle and a parent resource bundle, normally no fallback occurs
ghb@10550 188 * on the sub-resources because the table is defined in the current resource bundle, but this
ghb@10550 189 * function can perform fallback on the sub-resources of the table.
ghb@10550 190 * @param resB a resource
ghb@10550 191 * @param inKey a key associated with the requested resource
ghb@10550 192 * @param fillIn if NULL a new UResourceBundle struct is allocated and must be deleted by the caller.
ghb@10550 193 * Alternatively, you can supply a struct to be filled by this function.
ghb@10550 194 * @param status: fills in the outgoing error code
ghb@10550 195 * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
ghb@10550 196 * could be a non-failing error
ghb@10550 197 * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
ghb@10550 198 * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it
ghb@10550 199 */
ghb@10550 200 U_CAPI UResourceBundle* U_EXPORT2
ghb@10550 201 ures_getByKeyWithFallback(const UResourceBundle *resB,
ghb@10550 202 const char* inKey,
ghb@10550 203 UResourceBundle *fillIn,
ghb@10550 204 UErrorCode *status);
ghb@10550 205
ghb@10550 206
ghb@10550 207 /**
ghb@10550 208 * Get a String with multi-level fallback. Normally only the top level resources will
ghb@10550 209 * fallback to its parent. This performs fallback on subresources. For example, when a table
ghb@10550 210 * is defined in a resource bundle and a parent resource bundle, normally no fallback occurs
ghb@10550 211 * on the sub-resources because the table is defined in the current resource bundle, but this
ghb@10550 212 * function can perform fallback on the sub-resources of the table.
ghb@10550 213 * @param resB a resource
ghb@10550 214 * @param inKey a key associated with the requested resource
ghb@10550 215 * @param status: fills in the outgoing error code
ghb@10550 216 * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
ghb@10550 217 * could be a non-failing error
ghb@10550 218 * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
ghb@10550 219 * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it
ghb@10550 220 */
ghb@10550 221 U_CAPI const UChar* U_EXPORT2
ghb@10550 222 ures_getStringByKeyWithFallback(const UResourceBundle *resB,
ghb@10550 223 const char* inKey,
ghb@10550 224 int32_t* len,
ghb@10550 225 UErrorCode *status);
ghb@10550 226
arajkumar@11038 227 #ifdef __cplusplus
arajkumar@11038 228
arajkumar@11038 229 U_CAPI void U_EXPORT2
arajkumar@11038 230 ures_getAllItemsWithFallback(const UResourceBundle *bundle, const char *path,
arajkumar@11038 231 icu::ResourceSink &sink, UErrorCode &errorCode);
arajkumar@11038 232
arajkumar@11038 233 #endif /* __cplusplus */
arajkumar@11038 234
ghb@10550 235 /**
ghb@10550 236 * Get a version number by key
ghb@10550 237 * @param resB bundle containing version number
ghb@10550 238 * @param key the key for the version number
ghb@10550 239 * @param ver fillin for the version number
ghb@10550 240 * @param status error code
ghb@10550 241 */
ghb@10550 242 U_CAPI void U_EXPORT2
ghb@10550 243 ures_getVersionByKey(const UResourceBundle *resB,
ghb@10550 244 const char *key,
ghb@10550 245 UVersionInfo ver,
ghb@10550 246 UErrorCode *status);
ghb@10550 247
ghb@10550 248
ghb@10550 249 /**
ghb@10550 250 * Internal function.
ghb@10550 251 * Return the version number associated with this ResourceBundle as a string.
ghb@10550 252 *
ghb@10550 253 * @param resourceBundle The resource bundle for which the version is checked.
ghb@10550 254 * @return A version number string as specified in the resource bundle or its parent.
ghb@10550 255 * The caller does not own this string.
ghb@10550 256 * @see ures_getVersion
ghb@10550 257 */
ghb@10550 258 U_CAPI const char* U_EXPORT2
ghb@10550 259 ures_getVersionNumberInternal(const UResourceBundle *resourceBundle);
ghb@10550 260
ghb@10550 261 /**
ghb@10550 262 * Return the name of the Locale associated with this ResourceBundle. This API allows
ghb@10550 263 * you to query for the real locale of the resource. For example, if you requested
ghb@10550 264 * "en_US_CALIFORNIA" and only "en_US" bundle exists, "en_US" will be returned.
ghb@10550 265 * For subresources, the locale where this resource comes from will be returned.
ghb@10550 266 * If fallback has occured, getLocale will reflect this.
ghb@10550 267 *
ghb@10550 268 * This internal version avoids deprecated-warnings in ICU code.
ghb@10550 269 *
ghb@10550 270 * @param resourceBundle resource bundle in question
ghb@10550 271 * @param status just for catching illegal arguments
ghb@10550 272 * @return A Locale name
ghb@10550 273 */
ghb@10550 274 U_CAPI const char* U_EXPORT2
ghb@10550 275 ures_getLocaleInternal(const UResourceBundle* resourceBundle,
ghb@10550 276 UErrorCode* status);
ghb@10550 277
ghb@10550 278 #endif /*URESIMP_H*/