Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | ********************************************************************** |
michael@0 | 3 | * Copyright (C) 1997-2012, International Business Machines |
michael@0 | 4 | * Corporation and others. All Rights Reserved. |
michael@0 | 5 | ********************************************************************** |
michael@0 | 6 | * |
michael@0 | 7 | * File URES.H (formerly CRESBUND.H) |
michael@0 | 8 | * |
michael@0 | 9 | * Modification History: |
michael@0 | 10 | * |
michael@0 | 11 | * Date Name Description |
michael@0 | 12 | * 04/01/97 aliu Creation. |
michael@0 | 13 | * 02/22/99 damiba overhaul. |
michael@0 | 14 | * 04/04/99 helena Fixed internal header inclusion. |
michael@0 | 15 | * 04/15/99 Madhu Updated Javadoc |
michael@0 | 16 | * 06/14/99 stephen Removed functions taking a filename suffix. |
michael@0 | 17 | * 07/20/99 stephen Language-independent ypedef to void* |
michael@0 | 18 | * 11/09/99 weiv Added ures_getLocale() |
michael@0 | 19 | * 06/24/02 weiv Added support for resource sharing |
michael@0 | 20 | ****************************************************************************** |
michael@0 | 21 | */ |
michael@0 | 22 | |
michael@0 | 23 | #ifndef URES_H |
michael@0 | 24 | #define URES_H |
michael@0 | 25 | |
michael@0 | 26 | #include "unicode/utypes.h" |
michael@0 | 27 | #include "unicode/uloc.h" |
michael@0 | 28 | #include "unicode/localpointer.h" |
michael@0 | 29 | |
michael@0 | 30 | /** |
michael@0 | 31 | * \file |
michael@0 | 32 | * \brief C API: Resource Bundle |
michael@0 | 33 | * |
michael@0 | 34 | * <h2>C API: Resource Bundle</h2> |
michael@0 | 35 | * |
michael@0 | 36 | * C API representing a collection of resource information pertaining to a given |
michael@0 | 37 | * locale. A resource bundle provides a way of accessing locale- specific information in |
michael@0 | 38 | * a data file. You create a resource bundle that manages the resources for a given |
michael@0 | 39 | * locale and then ask it for individual resources. |
michael@0 | 40 | * <P> |
michael@0 | 41 | * Resource bundles in ICU4C are currently defined using text files which conform to the following |
michael@0 | 42 | * <a href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt">BNF definition</a>. |
michael@0 | 43 | * More on resource bundle concepts and syntax can be found in the |
michael@0 | 44 | * <a href="http://icu-project.org/userguide/ResourceManagement.html">Users Guide</a>. |
michael@0 | 45 | * <P> |
michael@0 | 46 | */ |
michael@0 | 47 | |
michael@0 | 48 | /** |
michael@0 | 49 | * UResourceBundle is an opaque type for handles for resource bundles in C APIs. |
michael@0 | 50 | * @stable ICU 2.0 |
michael@0 | 51 | */ |
michael@0 | 52 | struct UResourceBundle; |
michael@0 | 53 | |
michael@0 | 54 | /** |
michael@0 | 55 | * @stable ICU 2.0 |
michael@0 | 56 | */ |
michael@0 | 57 | typedef struct UResourceBundle UResourceBundle; |
michael@0 | 58 | |
michael@0 | 59 | /** |
michael@0 | 60 | * Numeric constants for types of resource items. |
michael@0 | 61 | * @see ures_getType |
michael@0 | 62 | * @stable ICU 2.0 |
michael@0 | 63 | */ |
michael@0 | 64 | typedef enum { |
michael@0 | 65 | /** Resource type constant for "no resource". @stable ICU 2.6 */ |
michael@0 | 66 | URES_NONE=-1, |
michael@0 | 67 | |
michael@0 | 68 | /** Resource type constant for 16-bit Unicode strings. @stable ICU 2.6 */ |
michael@0 | 69 | URES_STRING=0, |
michael@0 | 70 | |
michael@0 | 71 | /** Resource type constant for binary data. @stable ICU 2.6 */ |
michael@0 | 72 | URES_BINARY=1, |
michael@0 | 73 | |
michael@0 | 74 | /** Resource type constant for tables of key-value pairs. @stable ICU 2.6 */ |
michael@0 | 75 | URES_TABLE=2, |
michael@0 | 76 | |
michael@0 | 77 | /** |
michael@0 | 78 | * Resource type constant for aliases; |
michael@0 | 79 | * internally stores a string which identifies the actual resource |
michael@0 | 80 | * storing the data (can be in a different resource bundle). |
michael@0 | 81 | * Resolved internally before delivering the actual resource through the API. |
michael@0 | 82 | * @stable ICU 2.6 |
michael@0 | 83 | */ |
michael@0 | 84 | URES_ALIAS=3, |
michael@0 | 85 | |
michael@0 | 86 | /** |
michael@0 | 87 | * Resource type constant for a single 28-bit integer, interpreted as |
michael@0 | 88 | * signed or unsigned by the ures_getInt() or ures_getUInt() function. |
michael@0 | 89 | * @see ures_getInt |
michael@0 | 90 | * @see ures_getUInt |
michael@0 | 91 | * @stable ICU 2.6 |
michael@0 | 92 | */ |
michael@0 | 93 | URES_INT=7, |
michael@0 | 94 | |
michael@0 | 95 | /** Resource type constant for arrays of resources. @stable ICU 2.6 */ |
michael@0 | 96 | URES_ARRAY=8, |
michael@0 | 97 | |
michael@0 | 98 | /** |
michael@0 | 99 | * Resource type constant for vectors of 32-bit integers. |
michael@0 | 100 | * @see ures_getIntVector |
michael@0 | 101 | * @stable ICU 2.6 |
michael@0 | 102 | */ |
michael@0 | 103 | URES_INT_VECTOR = 14, |
michael@0 | 104 | #ifndef U_HIDE_DEPRECATED_API |
michael@0 | 105 | /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
michael@0 | 106 | RES_NONE=URES_NONE, |
michael@0 | 107 | /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
michael@0 | 108 | RES_STRING=URES_STRING, |
michael@0 | 109 | /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
michael@0 | 110 | RES_BINARY=URES_BINARY, |
michael@0 | 111 | /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
michael@0 | 112 | RES_TABLE=URES_TABLE, |
michael@0 | 113 | /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
michael@0 | 114 | RES_ALIAS=URES_ALIAS, |
michael@0 | 115 | /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
michael@0 | 116 | RES_INT=URES_INT, |
michael@0 | 117 | /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
michael@0 | 118 | RES_ARRAY=URES_ARRAY, |
michael@0 | 119 | /** @deprecated ICU 2.6 Use the URES_ constant instead. */ |
michael@0 | 120 | RES_INT_VECTOR=URES_INT_VECTOR, |
michael@0 | 121 | /** @deprecated ICU 2.6 Not used. */ |
michael@0 | 122 | RES_RESERVED=15, |
michael@0 | 123 | #endif /* U_HIDE_DEPRECATED_API */ |
michael@0 | 124 | |
michael@0 | 125 | URES_LIMIT = 16 |
michael@0 | 126 | } UResType; |
michael@0 | 127 | |
michael@0 | 128 | /* |
michael@0 | 129 | * Functions to create and destroy resource bundles. |
michael@0 | 130 | */ |
michael@0 | 131 | |
michael@0 | 132 | /** |
michael@0 | 133 | * Opens a UResourceBundle, from which users can extract strings by using |
michael@0 | 134 | * their corresponding keys. |
michael@0 | 135 | * Note that the caller is responsible of calling <TT>ures_close</TT> on each succesfully |
michael@0 | 136 | * opened resource bundle. |
michael@0 | 137 | * @param packageName The packageName and locale together point to an ICU udata object, |
michael@0 | 138 | * as defined by <code> udata_open( packageName, "res", locale, err) </code> |
michael@0 | 139 | * or equivalent. Typically, packageName will refer to a (.dat) file, or to |
michael@0 | 140 | * a package registered with udata_setAppData(). Using a full file or directory |
michael@0 | 141 | * pathname for packageName is deprecated. If NULL, ICU data will be used. |
michael@0 | 142 | * @param locale specifies the locale for which we want to open the resource |
michael@0 | 143 | * if NULL, the default locale will be used. If strlen(locale) == 0 |
michael@0 | 144 | * root locale will be used. |
michael@0 | 145 | * |
michael@0 | 146 | * @param status fills in the outgoing error code. |
michael@0 | 147 | * The UErrorCode err parameter is used to return status information to the user. To |
michael@0 | 148 | * check whether the construction succeeded or not, you should check the value of |
michael@0 | 149 | * U_SUCCESS(err). If you wish more detailed information, you can check for |
michael@0 | 150 | * informational status results which still indicate success. U_USING_FALLBACK_WARNING |
michael@0 | 151 | * indicates that a fall back locale was used. For example, 'de_CH' was requested, |
michael@0 | 152 | * but nothing was found there, so 'de' was used. U_USING_DEFAULT_WARNING indicates that |
michael@0 | 153 | * the default locale data or root locale data was used; neither the requested locale |
michael@0 | 154 | * nor any of its fall back locales could be found. Please see the users guide for more |
michael@0 | 155 | * information on this topic. |
michael@0 | 156 | * @return a newly allocated resource bundle. |
michael@0 | 157 | * @see ures_close |
michael@0 | 158 | * @stable ICU 2.0 |
michael@0 | 159 | */ |
michael@0 | 160 | U_STABLE UResourceBundle* U_EXPORT2 |
michael@0 | 161 | ures_open(const char* packageName, |
michael@0 | 162 | const char* locale, |
michael@0 | 163 | UErrorCode* status); |
michael@0 | 164 | |
michael@0 | 165 | |
michael@0 | 166 | /** This function does not care what kind of localeID is passed in. It simply opens a bundle with |
michael@0 | 167 | * that name. Fallback mechanism is disabled for the new bundle. If the requested bundle contains |
michael@0 | 168 | * an %%ALIAS directive, the results are undefined. |
michael@0 | 169 | * @param packageName The packageName and locale together point to an ICU udata object, |
michael@0 | 170 | * as defined by <code> udata_open( packageName, "res", locale, err) </code> |
michael@0 | 171 | * or equivalent. Typically, packageName will refer to a (.dat) file, or to |
michael@0 | 172 | * a package registered with udata_setAppData(). Using a full file or directory |
michael@0 | 173 | * pathname for packageName is deprecated. If NULL, ICU data will be used. |
michael@0 | 174 | * @param locale specifies the locale for which we want to open the resource |
michael@0 | 175 | * if NULL, the default locale will be used. If strlen(locale) == 0 |
michael@0 | 176 | * root locale will be used. |
michael@0 | 177 | * |
michael@0 | 178 | * @param status fills in the outgoing error code. Either U_ZERO_ERROR or U_MISSING_RESOURCE_ERROR |
michael@0 | 179 | * @return a newly allocated resource bundle or NULL if it doesn't exist. |
michael@0 | 180 | * @see ures_close |
michael@0 | 181 | * @stable ICU 2.0 |
michael@0 | 182 | */ |
michael@0 | 183 | U_STABLE UResourceBundle* U_EXPORT2 |
michael@0 | 184 | ures_openDirect(const char* packageName, |
michael@0 | 185 | const char* locale, |
michael@0 | 186 | UErrorCode* status); |
michael@0 | 187 | |
michael@0 | 188 | /** |
michael@0 | 189 | * Same as ures_open() but takes a const UChar *path. |
michael@0 | 190 | * This path will be converted to char * using the default converter, |
michael@0 | 191 | * then ures_open() is called. |
michael@0 | 192 | * |
michael@0 | 193 | * @param packageName The packageName and locale together point to an ICU udata object, |
michael@0 | 194 | * as defined by <code> udata_open( packageName, "res", locale, err) </code> |
michael@0 | 195 | * or equivalent. Typically, packageName will refer to a (.dat) file, or to |
michael@0 | 196 | * a package registered with udata_setAppData(). Using a full file or directory |
michael@0 | 197 | * pathname for packageName is deprecated. If NULL, ICU data will be used. |
michael@0 | 198 | * @param locale specifies the locale for which we want to open the resource |
michael@0 | 199 | * if NULL, the default locale will be used. If strlen(locale) == 0 |
michael@0 | 200 | * root locale will be used. |
michael@0 | 201 | * @param status fills in the outgoing error code. |
michael@0 | 202 | * @return a newly allocated resource bundle. |
michael@0 | 203 | * @see ures_open |
michael@0 | 204 | * @stable ICU 2.0 |
michael@0 | 205 | */ |
michael@0 | 206 | U_STABLE UResourceBundle* U_EXPORT2 |
michael@0 | 207 | ures_openU(const UChar* packageName, |
michael@0 | 208 | const char* locale, |
michael@0 | 209 | UErrorCode* status); |
michael@0 | 210 | |
michael@0 | 211 | #ifndef U_HIDE_DEPRECATED_API |
michael@0 | 212 | /** |
michael@0 | 213 | * Returns the number of strings/arrays in resource bundles. |
michael@0 | 214 | * Better to use ures_getSize, as this function will be deprecated. |
michael@0 | 215 | * |
michael@0 | 216 | *@param resourceBundle resource bundle containing the desired strings |
michael@0 | 217 | *@param resourceKey key tagging the resource |
michael@0 | 218 | *@param err fills in the outgoing error code |
michael@0 | 219 | * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found |
michael@0 | 220 | * could be a non-failing error |
michael@0 | 221 | * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_FALLBACK_WARNING </TT> |
michael@0 | 222 | *@return: for <STRONG>Arrays</STRONG>: returns the number of resources in the array |
michael@0 | 223 | * <STRONG>Tables</STRONG>: returns the number of resources in the table |
michael@0 | 224 | * <STRONG>single string</STRONG>: returns 1 |
michael@0 | 225 | *@see ures_getSize |
michael@0 | 226 | * @deprecated ICU 2.8 User ures_getSize instead |
michael@0 | 227 | */ |
michael@0 | 228 | U_DEPRECATED int32_t U_EXPORT2 |
michael@0 | 229 | ures_countArrayItems(const UResourceBundle* resourceBundle, |
michael@0 | 230 | const char* resourceKey, |
michael@0 | 231 | UErrorCode* err); |
michael@0 | 232 | #endif /* U_HIDE_DEPRECATED_API */ |
michael@0 | 233 | /** |
michael@0 | 234 | * Close a resource bundle, all pointers returned from the various ures_getXXX calls |
michael@0 | 235 | * on this particular bundle should be considered invalid henceforth. |
michael@0 | 236 | * |
michael@0 | 237 | * @param resourceBundle a pointer to a resourceBundle struct. Can be NULL. |
michael@0 | 238 | * @see ures_open |
michael@0 | 239 | * @stable ICU 2.0 |
michael@0 | 240 | */ |
michael@0 | 241 | U_STABLE void U_EXPORT2 |
michael@0 | 242 | ures_close(UResourceBundle* resourceBundle); |
michael@0 | 243 | |
michael@0 | 244 | #if U_SHOW_CPLUSPLUS_API |
michael@0 | 245 | |
michael@0 | 246 | U_NAMESPACE_BEGIN |
michael@0 | 247 | |
michael@0 | 248 | /** |
michael@0 | 249 | * \class LocalUResourceBundlePointer |
michael@0 | 250 | * "Smart pointer" class, closes a UResourceBundle via ures_close(). |
michael@0 | 251 | * For most methods see the LocalPointerBase base class. |
michael@0 | 252 | * |
michael@0 | 253 | * @see LocalPointerBase |
michael@0 | 254 | * @see LocalPointer |
michael@0 | 255 | * @stable ICU 4.4 |
michael@0 | 256 | */ |
michael@0 | 257 | U_DEFINE_LOCAL_OPEN_POINTER(LocalUResourceBundlePointer, UResourceBundle, ures_close); |
michael@0 | 258 | |
michael@0 | 259 | U_NAMESPACE_END |
michael@0 | 260 | |
michael@0 | 261 | #endif |
michael@0 | 262 | |
michael@0 | 263 | #ifndef U_HIDE_DEPRECATED_API |
michael@0 | 264 | /** |
michael@0 | 265 | * Return the version number associated with this ResourceBundle as a string. Please |
michael@0 | 266 | * use ures_getVersion as this function is going to be deprecated. |
michael@0 | 267 | * |
michael@0 | 268 | * @param resourceBundle The resource bundle for which the version is checked. |
michael@0 | 269 | * @return A version number string as specified in the resource bundle or its parent. |
michael@0 | 270 | * The caller does not own this string. |
michael@0 | 271 | * @see ures_getVersion |
michael@0 | 272 | * @deprecated ICU 2.8 Use ures_getVersion instead. |
michael@0 | 273 | */ |
michael@0 | 274 | U_DEPRECATED const char* U_EXPORT2 |
michael@0 | 275 | ures_getVersionNumber(const UResourceBundle* resourceBundle); |
michael@0 | 276 | #endif /* U_HIDE_DEPRECATED_API */ |
michael@0 | 277 | |
michael@0 | 278 | /** |
michael@0 | 279 | * Return the version number associated with this ResourceBundle as an |
michael@0 | 280 | * UVersionInfo array. |
michael@0 | 281 | * |
michael@0 | 282 | * @param resB The resource bundle for which the version is checked. |
michael@0 | 283 | * @param versionInfo A UVersionInfo array that is filled with the version number |
michael@0 | 284 | * as specified in the resource bundle or its parent. |
michael@0 | 285 | * @stable ICU 2.0 |
michael@0 | 286 | */ |
michael@0 | 287 | U_STABLE void U_EXPORT2 |
michael@0 | 288 | ures_getVersion(const UResourceBundle* resB, |
michael@0 | 289 | UVersionInfo versionInfo); |
michael@0 | 290 | |
michael@0 | 291 | #ifndef U_HIDE_DEPRECATED_API |
michael@0 | 292 | /** |
michael@0 | 293 | * Return the name of the Locale associated with this ResourceBundle. This API allows |
michael@0 | 294 | * you to query for the real locale of the resource. For example, if you requested |
michael@0 | 295 | * "en_US_CALIFORNIA" and only "en_US" bundle exists, "en_US" will be returned. |
michael@0 | 296 | * For subresources, the locale where this resource comes from will be returned. |
michael@0 | 297 | * If fallback has occured, getLocale will reflect this. |
michael@0 | 298 | * |
michael@0 | 299 | * @param resourceBundle resource bundle in question |
michael@0 | 300 | * @param status just for catching illegal arguments |
michael@0 | 301 | * @return A Locale name |
michael@0 | 302 | * @deprecated ICU 2.8 Use ures_getLocaleByType instead. |
michael@0 | 303 | */ |
michael@0 | 304 | U_DEPRECATED const char* U_EXPORT2 |
michael@0 | 305 | ures_getLocale(const UResourceBundle* resourceBundle, |
michael@0 | 306 | UErrorCode* status); |
michael@0 | 307 | #endif /* U_HIDE_DEPRECATED_API */ |
michael@0 | 308 | |
michael@0 | 309 | /** |
michael@0 | 310 | * Return the name of the Locale associated with this ResourceBundle. |
michael@0 | 311 | * You can choose between requested, valid and real locale. |
michael@0 | 312 | * |
michael@0 | 313 | * @param resourceBundle resource bundle in question |
michael@0 | 314 | * @param type You can choose between requested, valid and actual |
michael@0 | 315 | * locale. For description see the definition of |
michael@0 | 316 | * ULocDataLocaleType in uloc.h |
michael@0 | 317 | * @param status just for catching illegal arguments |
michael@0 | 318 | * @return A Locale name |
michael@0 | 319 | * @stable ICU 2.8 |
michael@0 | 320 | */ |
michael@0 | 321 | U_STABLE const char* U_EXPORT2 |
michael@0 | 322 | ures_getLocaleByType(const UResourceBundle* resourceBundle, |
michael@0 | 323 | ULocDataLocaleType type, |
michael@0 | 324 | UErrorCode* status); |
michael@0 | 325 | |
michael@0 | 326 | |
michael@0 | 327 | #ifndef U_HIDE_INTERNAL_API |
michael@0 | 328 | /** |
michael@0 | 329 | * Same as ures_open() but uses the fill-in parameter instead of allocating |
michael@0 | 330 | * a bundle, if r!=NULL. |
michael@0 | 331 | * TODO need to revisit usefulness of this function |
michael@0 | 332 | * and usage model for fillIn parameters without knowing sizeof(UResourceBundle) |
michael@0 | 333 | * @param r The resourcebundle to open |
michael@0 | 334 | * @param packageName The packageName and locale together point to an ICU udata object, |
michael@0 | 335 | * as defined by <code> udata_open( packageName, "res", locale, err) </code> |
michael@0 | 336 | * or equivalent. Typically, packageName will refer to a (.dat) file, or to |
michael@0 | 337 | * a package registered with udata_setAppData(). Using a full file or directory |
michael@0 | 338 | * pathname for packageName is deprecated. If NULL, ICU data will be used. |
michael@0 | 339 | * @param localeID specifies the locale for which we want to open the resource |
michael@0 | 340 | * @param status The error code |
michael@0 | 341 | * @return a newly allocated resource bundle or NULL if it doesn't exist. |
michael@0 | 342 | * @internal |
michael@0 | 343 | */ |
michael@0 | 344 | U_INTERNAL void U_EXPORT2 |
michael@0 | 345 | ures_openFillIn(UResourceBundle *r, |
michael@0 | 346 | const char* packageName, |
michael@0 | 347 | const char* localeID, |
michael@0 | 348 | UErrorCode* status); |
michael@0 | 349 | #endif /* U_HIDE_INTERNAL_API */ |
michael@0 | 350 | |
michael@0 | 351 | /** |
michael@0 | 352 | * Returns a string from a string resource type |
michael@0 | 353 | * |
michael@0 | 354 | * @param resourceBundle a string resource |
michael@0 | 355 | * @param len fills in the length of resulting string |
michael@0 | 356 | * @param status fills in the outgoing error code |
michael@0 | 357 | * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found |
michael@0 | 358 | * Always check the value of status. Don't count on returning NULL. |
michael@0 | 359 | * could be a non-failing error |
michael@0 | 360 | * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT> |
michael@0 | 361 | * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file. |
michael@0 | 362 | * @see ures_getBinary |
michael@0 | 363 | * @see ures_getIntVector |
michael@0 | 364 | * @see ures_getInt |
michael@0 | 365 | * @see ures_getUInt |
michael@0 | 366 | * @stable ICU 2.0 |
michael@0 | 367 | */ |
michael@0 | 368 | U_STABLE const UChar* U_EXPORT2 |
michael@0 | 369 | ures_getString(const UResourceBundle* resourceBundle, |
michael@0 | 370 | int32_t* len, |
michael@0 | 371 | UErrorCode* status); |
michael@0 | 372 | |
michael@0 | 373 | /** |
michael@0 | 374 | * Returns a UTF-8 string from a string resource. |
michael@0 | 375 | * The UTF-8 string may be returnable directly as a pointer, or |
michael@0 | 376 | * it may need to be copied, or transformed from UTF-16 using u_strToUTF8() |
michael@0 | 377 | * or equivalent. |
michael@0 | 378 | * |
michael@0 | 379 | * If forceCopy==TRUE, then the string is always written to the dest buffer |
michael@0 | 380 | * and dest is returned. |
michael@0 | 381 | * |
michael@0 | 382 | * If forceCopy==FALSE, then the string is returned as a pointer if possible, |
michael@0 | 383 | * without needing a dest buffer (it can be NULL). If the string needs to be |
michael@0 | 384 | * copied or transformed, then it may be placed into dest at an arbitrary offset. |
michael@0 | 385 | * |
michael@0 | 386 | * If the string is to be written to dest, then U_BUFFER_OVERFLOW_ERROR and |
michael@0 | 387 | * U_STRING_NOT_TERMINATED_WARNING are set if appropriate, as usual. |
michael@0 | 388 | * |
michael@0 | 389 | * If the string is transformed from UTF-16, then a conversion error may occur |
michael@0 | 390 | * if an unpaired surrogate is encountered. If the function is successful, then |
michael@0 | 391 | * the output UTF-8 string is always well-formed. |
michael@0 | 392 | * |
michael@0 | 393 | * @param resB Resource bundle. |
michael@0 | 394 | * @param dest Destination buffer. Can be NULL only if capacity=*length==0. |
michael@0 | 395 | * @param length Input: Capacity of destination buffer. |
michael@0 | 396 | * Output: Actual length of the UTF-8 string, not counting the |
michael@0 | 397 | * terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR. |
michael@0 | 398 | * Can be NULL, meaning capacity=0 and the string length is not |
michael@0 | 399 | * returned to the caller. |
michael@0 | 400 | * @param forceCopy If TRUE, then the output string will always be written to |
michael@0 | 401 | * dest, with U_BUFFER_OVERFLOW_ERROR and |
michael@0 | 402 | * U_STRING_NOT_TERMINATED_WARNING set if appropriate. |
michael@0 | 403 | * If FALSE, then the dest buffer may or may not contain a |
michael@0 | 404 | * copy of the string. dest may or may not be modified. |
michael@0 | 405 | * If a copy needs to be written, then the UErrorCode parameter |
michael@0 | 406 | * indicates overflow etc. as usual. |
michael@0 | 407 | * @param status Pointer to a standard ICU error code. Its input value must |
michael@0 | 408 | * pass the U_SUCCESS() test, or else the function returns |
michael@0 | 409 | * immediately. Check for U_FAILURE() on output or use with |
michael@0 | 410 | * function chaining. (See User Guide for details.) |
michael@0 | 411 | * @return The pointer to the UTF-8 string. It may be dest, or at some offset |
michael@0 | 412 | * from dest (only if !forceCopy), or in unrelated memory. |
michael@0 | 413 | * Always NUL-terminated unless the string was written to dest and |
michael@0 | 414 | * length==capacity (in which case U_STRING_NOT_TERMINATED_WARNING is set). |
michael@0 | 415 | * |
michael@0 | 416 | * @see ures_getString |
michael@0 | 417 | * @see u_strToUTF8 |
michael@0 | 418 | * @stable ICU 3.6 |
michael@0 | 419 | */ |
michael@0 | 420 | U_STABLE const char * U_EXPORT2 |
michael@0 | 421 | ures_getUTF8String(const UResourceBundle *resB, |
michael@0 | 422 | char *dest, int32_t *length, |
michael@0 | 423 | UBool forceCopy, |
michael@0 | 424 | UErrorCode *status); |
michael@0 | 425 | |
michael@0 | 426 | /** |
michael@0 | 427 | * Returns a binary data from a binary resource. |
michael@0 | 428 | * |
michael@0 | 429 | * @param resourceBundle a string resource |
michael@0 | 430 | * @param len fills in the length of resulting byte chunk |
michael@0 | 431 | * @param status fills in the outgoing error code |
michael@0 | 432 | * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found |
michael@0 | 433 | * Always check the value of status. Don't count on returning NULL. |
michael@0 | 434 | * could be a non-failing error |
michael@0 | 435 | * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT> |
michael@0 | 436 | * @return a pointer to a chunk of unsigned bytes which live in a memory mapped/DLL file. |
michael@0 | 437 | * @see ures_getString |
michael@0 | 438 | * @see ures_getIntVector |
michael@0 | 439 | * @see ures_getInt |
michael@0 | 440 | * @see ures_getUInt |
michael@0 | 441 | * @stable ICU 2.0 |
michael@0 | 442 | */ |
michael@0 | 443 | U_STABLE const uint8_t* U_EXPORT2 |
michael@0 | 444 | ures_getBinary(const UResourceBundle* resourceBundle, |
michael@0 | 445 | int32_t* len, |
michael@0 | 446 | UErrorCode* status); |
michael@0 | 447 | |
michael@0 | 448 | /** |
michael@0 | 449 | * Returns a 32 bit integer array from a resource. |
michael@0 | 450 | * |
michael@0 | 451 | * @param resourceBundle an int vector resource |
michael@0 | 452 | * @param len fills in the length of resulting byte chunk |
michael@0 | 453 | * @param status fills in the outgoing error code |
michael@0 | 454 | * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found |
michael@0 | 455 | * Always check the value of status. Don't count on returning NULL. |
michael@0 | 456 | * could be a non-failing error |
michael@0 | 457 | * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT> |
michael@0 | 458 | * @return a pointer to a chunk of integers which live in a memory mapped/DLL file. |
michael@0 | 459 | * @see ures_getBinary |
michael@0 | 460 | * @see ures_getString |
michael@0 | 461 | * @see ures_getInt |
michael@0 | 462 | * @see ures_getUInt |
michael@0 | 463 | * @stable ICU 2.0 |
michael@0 | 464 | */ |
michael@0 | 465 | U_STABLE const int32_t* U_EXPORT2 |
michael@0 | 466 | ures_getIntVector(const UResourceBundle* resourceBundle, |
michael@0 | 467 | int32_t* len, |
michael@0 | 468 | UErrorCode* status); |
michael@0 | 469 | |
michael@0 | 470 | /** |
michael@0 | 471 | * Returns an unsigned integer from a resource. |
michael@0 | 472 | * This integer is originally 28 bits. |
michael@0 | 473 | * |
michael@0 | 474 | * @param resourceBundle a string resource |
michael@0 | 475 | * @param status fills in the outgoing error code |
michael@0 | 476 | * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found |
michael@0 | 477 | * could be a non-failing error |
michael@0 | 478 | * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT> |
michael@0 | 479 | * @return an integer value |
michael@0 | 480 | * @see ures_getInt |
michael@0 | 481 | * @see ures_getIntVector |
michael@0 | 482 | * @see ures_getBinary |
michael@0 | 483 | * @see ures_getString |
michael@0 | 484 | * @stable ICU 2.0 |
michael@0 | 485 | */ |
michael@0 | 486 | U_STABLE uint32_t U_EXPORT2 |
michael@0 | 487 | ures_getUInt(const UResourceBundle* resourceBundle, |
michael@0 | 488 | UErrorCode *status); |
michael@0 | 489 | |
michael@0 | 490 | /** |
michael@0 | 491 | * Returns a signed integer from a resource. |
michael@0 | 492 | * This integer is originally 28 bit and the sign gets propagated. |
michael@0 | 493 | * |
michael@0 | 494 | * @param resourceBundle a string resource |
michael@0 | 495 | * @param status fills in the outgoing error code |
michael@0 | 496 | * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found |
michael@0 | 497 | * could be a non-failing error |
michael@0 | 498 | * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT> |
michael@0 | 499 | * @return an integer value |
michael@0 | 500 | * @see ures_getUInt |
michael@0 | 501 | * @see ures_getIntVector |
michael@0 | 502 | * @see ures_getBinary |
michael@0 | 503 | * @see ures_getString |
michael@0 | 504 | * @stable ICU 2.0 |
michael@0 | 505 | */ |
michael@0 | 506 | U_STABLE int32_t U_EXPORT2 |
michael@0 | 507 | ures_getInt(const UResourceBundle* resourceBundle, |
michael@0 | 508 | UErrorCode *status); |
michael@0 | 509 | |
michael@0 | 510 | /** |
michael@0 | 511 | * Returns the size of a resource. Size for scalar types is always 1, |
michael@0 | 512 | * and for vector/table types is the number of child resources. |
michael@0 | 513 | * @warning Integer array is treated as a scalar type. There are no |
michael@0 | 514 | * APIs to access individual members of an integer array. It |
michael@0 | 515 | * is always returned as a whole. |
michael@0 | 516 | * @param resourceBundle a resource |
michael@0 | 517 | * @return number of resources in a given resource. |
michael@0 | 518 | * @stable ICU 2.0 |
michael@0 | 519 | */ |
michael@0 | 520 | U_STABLE int32_t U_EXPORT2 |
michael@0 | 521 | ures_getSize(const UResourceBundle *resourceBundle); |
michael@0 | 522 | |
michael@0 | 523 | /** |
michael@0 | 524 | * Returns the type of a resource. Available types are defined in enum UResType |
michael@0 | 525 | * |
michael@0 | 526 | * @param resourceBundle a resource |
michael@0 | 527 | * @return type of the given resource. |
michael@0 | 528 | * @see UResType |
michael@0 | 529 | * @stable ICU 2.0 |
michael@0 | 530 | */ |
michael@0 | 531 | U_STABLE UResType U_EXPORT2 |
michael@0 | 532 | ures_getType(const UResourceBundle *resourceBundle); |
michael@0 | 533 | |
michael@0 | 534 | /** |
michael@0 | 535 | * Returns the key associated with a given resource. Not all the resources have a key - only |
michael@0 | 536 | * those that are members of a table. |
michael@0 | 537 | * |
michael@0 | 538 | * @param resourceBundle a resource |
michael@0 | 539 | * @return a key associated to this resource, or NULL if it doesn't have a key |
michael@0 | 540 | * @stable ICU 2.0 |
michael@0 | 541 | */ |
michael@0 | 542 | U_STABLE const char * U_EXPORT2 |
michael@0 | 543 | ures_getKey(const UResourceBundle *resourceBundle); |
michael@0 | 544 | |
michael@0 | 545 | /* ITERATION API |
michael@0 | 546 | This API provides means for iterating through a resource |
michael@0 | 547 | */ |
michael@0 | 548 | |
michael@0 | 549 | /** |
michael@0 | 550 | * Resets the internal context of a resource so that iteration starts from the first element. |
michael@0 | 551 | * |
michael@0 | 552 | * @param resourceBundle a resource |
michael@0 | 553 | * @stable ICU 2.0 |
michael@0 | 554 | */ |
michael@0 | 555 | U_STABLE void U_EXPORT2 |
michael@0 | 556 | ures_resetIterator(UResourceBundle *resourceBundle); |
michael@0 | 557 | |
michael@0 | 558 | /** |
michael@0 | 559 | * Checks whether the given resource has another element to iterate over. |
michael@0 | 560 | * |
michael@0 | 561 | * @param resourceBundle a resource |
michael@0 | 562 | * @return TRUE if there are more elements, FALSE if there is no more elements |
michael@0 | 563 | * @stable ICU 2.0 |
michael@0 | 564 | */ |
michael@0 | 565 | U_STABLE UBool U_EXPORT2 |
michael@0 | 566 | ures_hasNext(const UResourceBundle *resourceBundle); |
michael@0 | 567 | |
michael@0 | 568 | /** |
michael@0 | 569 | * Returns the next resource in a given resource or NULL if there are no more resources |
michael@0 | 570 | * to iterate over. Features a fill-in parameter. |
michael@0 | 571 | * |
michael@0 | 572 | * @param resourceBundle a resource |
michael@0 | 573 | * @param fillIn if NULL a new UResourceBundle struct is allocated and must be closed by the caller. |
michael@0 | 574 | * Alternatively, you can supply a struct to be filled by this function. |
michael@0 | 575 | * @param status fills in the outgoing error code. You may still get a non NULL result even if an |
michael@0 | 576 | * error occured. Check status instead. |
michael@0 | 577 | * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it |
michael@0 | 578 | * @stable ICU 2.0 |
michael@0 | 579 | */ |
michael@0 | 580 | U_STABLE UResourceBundle* U_EXPORT2 |
michael@0 | 581 | ures_getNextResource(UResourceBundle *resourceBundle, |
michael@0 | 582 | UResourceBundle *fillIn, |
michael@0 | 583 | UErrorCode *status); |
michael@0 | 584 | |
michael@0 | 585 | /** |
michael@0 | 586 | * Returns the next string in a given resource or NULL if there are no more resources |
michael@0 | 587 | * to iterate over. |
michael@0 | 588 | * |
michael@0 | 589 | * @param resourceBundle a resource |
michael@0 | 590 | * @param len fill in length of the string |
michael@0 | 591 | * @param key fill in for key associated with this string. NULL if no key |
michael@0 | 592 | * @param status fills in the outgoing error code. If an error occured, we may return NULL, but don't |
michael@0 | 593 | * count on it. Check status instead! |
michael@0 | 594 | * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file. |
michael@0 | 595 | * @stable ICU 2.0 |
michael@0 | 596 | */ |
michael@0 | 597 | U_STABLE const UChar* U_EXPORT2 |
michael@0 | 598 | ures_getNextString(UResourceBundle *resourceBundle, |
michael@0 | 599 | int32_t* len, |
michael@0 | 600 | const char ** key, |
michael@0 | 601 | UErrorCode *status); |
michael@0 | 602 | |
michael@0 | 603 | /** |
michael@0 | 604 | * Returns the resource in a given resource at the specified index. Features a fill-in parameter. |
michael@0 | 605 | * |
michael@0 | 606 | * @param resourceBundle the resource bundle from which to get a sub-resource |
michael@0 | 607 | * @param indexR an index to the wanted resource. |
michael@0 | 608 | * @param fillIn if NULL a new UResourceBundle struct is allocated and must be closed by the caller. |
michael@0 | 609 | * Alternatively, you can supply a struct to be filled by this function. |
michael@0 | 610 | * @param status fills in the outgoing error code. Don't count on NULL being returned if an error has |
michael@0 | 611 | * occured. Check status instead. |
michael@0 | 612 | * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it |
michael@0 | 613 | * @stable ICU 2.0 |
michael@0 | 614 | */ |
michael@0 | 615 | U_STABLE UResourceBundle* U_EXPORT2 |
michael@0 | 616 | ures_getByIndex(const UResourceBundle *resourceBundle, |
michael@0 | 617 | int32_t indexR, |
michael@0 | 618 | UResourceBundle *fillIn, |
michael@0 | 619 | UErrorCode *status); |
michael@0 | 620 | |
michael@0 | 621 | /** |
michael@0 | 622 | * Returns the string in a given resource at the specified index. |
michael@0 | 623 | * |
michael@0 | 624 | * @param resourceBundle a resource |
michael@0 | 625 | * @param indexS an index to the wanted string. |
michael@0 | 626 | * @param len fill in length of the string |
michael@0 | 627 | * @param status fills in the outgoing error code. If an error occured, we may return NULL, but don't |
michael@0 | 628 | * count on it. Check status instead! |
michael@0 | 629 | * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file. |
michael@0 | 630 | * @stable ICU 2.0 |
michael@0 | 631 | */ |
michael@0 | 632 | U_STABLE const UChar* U_EXPORT2 |
michael@0 | 633 | ures_getStringByIndex(const UResourceBundle *resourceBundle, |
michael@0 | 634 | int32_t indexS, |
michael@0 | 635 | int32_t* len, |
michael@0 | 636 | UErrorCode *status); |
michael@0 | 637 | |
michael@0 | 638 | /** |
michael@0 | 639 | * Returns a UTF-8 string from a resource at the specified index. |
michael@0 | 640 | * The UTF-8 string may be returnable directly as a pointer, or |
michael@0 | 641 | * it may need to be copied, or transformed from UTF-16 using u_strToUTF8() |
michael@0 | 642 | * or equivalent. |
michael@0 | 643 | * |
michael@0 | 644 | * If forceCopy==TRUE, then the string is always written to the dest buffer |
michael@0 | 645 | * and dest is returned. |
michael@0 | 646 | * |
michael@0 | 647 | * If forceCopy==FALSE, then the string is returned as a pointer if possible, |
michael@0 | 648 | * without needing a dest buffer (it can be NULL). If the string needs to be |
michael@0 | 649 | * copied or transformed, then it may be placed into dest at an arbitrary offset. |
michael@0 | 650 | * |
michael@0 | 651 | * If the string is to be written to dest, then U_BUFFER_OVERFLOW_ERROR and |
michael@0 | 652 | * U_STRING_NOT_TERMINATED_WARNING are set if appropriate, as usual. |
michael@0 | 653 | * |
michael@0 | 654 | * If the string is transformed from UTF-16, then a conversion error may occur |
michael@0 | 655 | * if an unpaired surrogate is encountered. If the function is successful, then |
michael@0 | 656 | * the output UTF-8 string is always well-formed. |
michael@0 | 657 | * |
michael@0 | 658 | * @param resB Resource bundle. |
michael@0 | 659 | * @param stringIndex An index to the wanted string. |
michael@0 | 660 | * @param dest Destination buffer. Can be NULL only if capacity=*length==0. |
michael@0 | 661 | * @param pLength Input: Capacity of destination buffer. |
michael@0 | 662 | * Output: Actual length of the UTF-8 string, not counting the |
michael@0 | 663 | * terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR. |
michael@0 | 664 | * Can be NULL, meaning capacity=0 and the string length is not |
michael@0 | 665 | * returned to the caller. |
michael@0 | 666 | * @param forceCopy If TRUE, then the output string will always be written to |
michael@0 | 667 | * dest, with U_BUFFER_OVERFLOW_ERROR and |
michael@0 | 668 | * U_STRING_NOT_TERMINATED_WARNING set if appropriate. |
michael@0 | 669 | * If FALSE, then the dest buffer may or may not contain a |
michael@0 | 670 | * copy of the string. dest may or may not be modified. |
michael@0 | 671 | * If a copy needs to be written, then the UErrorCode parameter |
michael@0 | 672 | * indicates overflow etc. as usual. |
michael@0 | 673 | * @param status Pointer to a standard ICU error code. Its input value must |
michael@0 | 674 | * pass the U_SUCCESS() test, or else the function returns |
michael@0 | 675 | * immediately. Check for U_FAILURE() on output or use with |
michael@0 | 676 | * function chaining. (See User Guide for details.) |
michael@0 | 677 | * @return The pointer to the UTF-8 string. It may be dest, or at some offset |
michael@0 | 678 | * from dest (only if !forceCopy), or in unrelated memory. |
michael@0 | 679 | * Always NUL-terminated unless the string was written to dest and |
michael@0 | 680 | * length==capacity (in which case U_STRING_NOT_TERMINATED_WARNING is set). |
michael@0 | 681 | * |
michael@0 | 682 | * @see ures_getStringByIndex |
michael@0 | 683 | * @see u_strToUTF8 |
michael@0 | 684 | * @stable ICU 3.6 |
michael@0 | 685 | */ |
michael@0 | 686 | U_STABLE const char * U_EXPORT2 |
michael@0 | 687 | ures_getUTF8StringByIndex(const UResourceBundle *resB, |
michael@0 | 688 | int32_t stringIndex, |
michael@0 | 689 | char *dest, int32_t *pLength, |
michael@0 | 690 | UBool forceCopy, |
michael@0 | 691 | UErrorCode *status); |
michael@0 | 692 | |
michael@0 | 693 | /** |
michael@0 | 694 | * Returns a resource in a given resource that has a given key. This procedure works only with table |
michael@0 | 695 | * resources. Features a fill-in parameter. |
michael@0 | 696 | * |
michael@0 | 697 | * @param resourceBundle a resource |
michael@0 | 698 | * @param key a key associated with the wanted resource |
michael@0 | 699 | * @param fillIn if NULL a new UResourceBundle struct is allocated and must be closed by the caller. |
michael@0 | 700 | * Alternatively, you can supply a struct to be filled by this function. |
michael@0 | 701 | * @param status fills in the outgoing error code. |
michael@0 | 702 | * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it |
michael@0 | 703 | * @stable ICU 2.0 |
michael@0 | 704 | */ |
michael@0 | 705 | U_STABLE UResourceBundle* U_EXPORT2 |
michael@0 | 706 | ures_getByKey(const UResourceBundle *resourceBundle, |
michael@0 | 707 | const char* key, |
michael@0 | 708 | UResourceBundle *fillIn, |
michael@0 | 709 | UErrorCode *status); |
michael@0 | 710 | |
michael@0 | 711 | /** |
michael@0 | 712 | * Returns a string in a given resource that has a given key. This procedure works only with table |
michael@0 | 713 | * resources. |
michael@0 | 714 | * |
michael@0 | 715 | * @param resB a resource |
michael@0 | 716 | * @param key a key associated with the wanted string |
michael@0 | 717 | * @param len fill in length of the string |
michael@0 | 718 | * @param status fills in the outgoing error code. If an error occured, we may return NULL, but don't |
michael@0 | 719 | * count on it. Check status instead! |
michael@0 | 720 | * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file. |
michael@0 | 721 | * @stable ICU 2.0 |
michael@0 | 722 | */ |
michael@0 | 723 | U_STABLE const UChar* U_EXPORT2 |
michael@0 | 724 | ures_getStringByKey(const UResourceBundle *resB, |
michael@0 | 725 | const char* key, |
michael@0 | 726 | int32_t* len, |
michael@0 | 727 | UErrorCode *status); |
michael@0 | 728 | |
michael@0 | 729 | /** |
michael@0 | 730 | * Returns a UTF-8 string from a resource and a key. |
michael@0 | 731 | * This function works only with table resources. |
michael@0 | 732 | * |
michael@0 | 733 | * The UTF-8 string may be returnable directly as a pointer, or |
michael@0 | 734 | * it may need to be copied, or transformed from UTF-16 using u_strToUTF8() |
michael@0 | 735 | * or equivalent. |
michael@0 | 736 | * |
michael@0 | 737 | * If forceCopy==TRUE, then the string is always written to the dest buffer |
michael@0 | 738 | * and dest is returned. |
michael@0 | 739 | * |
michael@0 | 740 | * If forceCopy==FALSE, then the string is returned as a pointer if possible, |
michael@0 | 741 | * without needing a dest buffer (it can be NULL). If the string needs to be |
michael@0 | 742 | * copied or transformed, then it may be placed into dest at an arbitrary offset. |
michael@0 | 743 | * |
michael@0 | 744 | * If the string is to be written to dest, then U_BUFFER_OVERFLOW_ERROR and |
michael@0 | 745 | * U_STRING_NOT_TERMINATED_WARNING are set if appropriate, as usual. |
michael@0 | 746 | * |
michael@0 | 747 | * If the string is transformed from UTF-16, then a conversion error may occur |
michael@0 | 748 | * if an unpaired surrogate is encountered. If the function is successful, then |
michael@0 | 749 | * the output UTF-8 string is always well-formed. |
michael@0 | 750 | * |
michael@0 | 751 | * @param resB Resource bundle. |
michael@0 | 752 | * @param key A key associated with the wanted resource |
michael@0 | 753 | * @param dest Destination buffer. Can be NULL only if capacity=*length==0. |
michael@0 | 754 | * @param pLength Input: Capacity of destination buffer. |
michael@0 | 755 | * Output: Actual length of the UTF-8 string, not counting the |
michael@0 | 756 | * terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR. |
michael@0 | 757 | * Can be NULL, meaning capacity=0 and the string length is not |
michael@0 | 758 | * returned to the caller. |
michael@0 | 759 | * @param forceCopy If TRUE, then the output string will always be written to |
michael@0 | 760 | * dest, with U_BUFFER_OVERFLOW_ERROR and |
michael@0 | 761 | * U_STRING_NOT_TERMINATED_WARNING set if appropriate. |
michael@0 | 762 | * If FALSE, then the dest buffer may or may not contain a |
michael@0 | 763 | * copy of the string. dest may or may not be modified. |
michael@0 | 764 | * If a copy needs to be written, then the UErrorCode parameter |
michael@0 | 765 | * indicates overflow etc. as usual. |
michael@0 | 766 | * @param status Pointer to a standard ICU error code. Its input value must |
michael@0 | 767 | * pass the U_SUCCESS() test, or else the function returns |
michael@0 | 768 | * immediately. Check for U_FAILURE() on output or use with |
michael@0 | 769 | * function chaining. (See User Guide for details.) |
michael@0 | 770 | * @return The pointer to the UTF-8 string. It may be dest, or at some offset |
michael@0 | 771 | * from dest (only if !forceCopy), or in unrelated memory. |
michael@0 | 772 | * Always NUL-terminated unless the string was written to dest and |
michael@0 | 773 | * length==capacity (in which case U_STRING_NOT_TERMINATED_WARNING is set). |
michael@0 | 774 | * |
michael@0 | 775 | * @see ures_getStringByKey |
michael@0 | 776 | * @see u_strToUTF8 |
michael@0 | 777 | * @stable ICU 3.6 |
michael@0 | 778 | */ |
michael@0 | 779 | U_STABLE const char * U_EXPORT2 |
michael@0 | 780 | ures_getUTF8StringByKey(const UResourceBundle *resB, |
michael@0 | 781 | const char *key, |
michael@0 | 782 | char *dest, int32_t *pLength, |
michael@0 | 783 | UBool forceCopy, |
michael@0 | 784 | UErrorCode *status); |
michael@0 | 785 | |
michael@0 | 786 | #if U_SHOW_CPLUSPLUS_API |
michael@0 | 787 | #include "unicode/unistr.h" |
michael@0 | 788 | |
michael@0 | 789 | U_NAMESPACE_BEGIN |
michael@0 | 790 | /** |
michael@0 | 791 | * returns a string from a string resource type |
michael@0 | 792 | * |
michael@0 | 793 | * @param resB a resource |
michael@0 | 794 | * @param status: fills in the outgoing error code |
michael@0 | 795 | * could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found |
michael@0 | 796 | * could be a non-failing error |
michael@0 | 797 | * e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT> |
michael@0 | 798 | * @return a UnicodeString object. If there is an error, string is bogus |
michael@0 | 799 | * @stable ICU 2.0 |
michael@0 | 800 | */ |
michael@0 | 801 | inline UnicodeString |
michael@0 | 802 | ures_getUnicodeString(const UResourceBundle *resB, |
michael@0 | 803 | UErrorCode* status) |
michael@0 | 804 | { |
michael@0 | 805 | int32_t len = 0; |
michael@0 | 806 | const UChar *r = ures_getString(resB, &len, status); |
michael@0 | 807 | return UnicodeString(TRUE, r, len); |
michael@0 | 808 | } |
michael@0 | 809 | |
michael@0 | 810 | /** |
michael@0 | 811 | * Returns the next string in a resource or NULL if there are no more resources |
michael@0 | 812 | * to iterate over. |
michael@0 | 813 | * |
michael@0 | 814 | * @param resB a resource |
michael@0 | 815 | * @param key fill in for key associated with this string |
michael@0 | 816 | * @param status fills in the outgoing error code |
michael@0 | 817 | * @return an UnicodeString object. |
michael@0 | 818 | * @stable ICU 2.0 |
michael@0 | 819 | */ |
michael@0 | 820 | inline UnicodeString |
michael@0 | 821 | ures_getNextUnicodeString(UResourceBundle *resB, |
michael@0 | 822 | const char ** key, |
michael@0 | 823 | UErrorCode* status) |
michael@0 | 824 | { |
michael@0 | 825 | int32_t len = 0; |
michael@0 | 826 | const UChar* r = ures_getNextString(resB, &len, key, status); |
michael@0 | 827 | return UnicodeString(TRUE, r, len); |
michael@0 | 828 | } |
michael@0 | 829 | |
michael@0 | 830 | /** |
michael@0 | 831 | * Returns the string in a given resource at the specified index. |
michael@0 | 832 | * |
michael@0 | 833 | * @param resB a resource |
michael@0 | 834 | * @param indexS an index to the wanted string. |
michael@0 | 835 | * @param status fills in the outgoing error code |
michael@0 | 836 | * @return an UnicodeString object. If there is an error, string is bogus |
michael@0 | 837 | * @stable ICU 2.0 |
michael@0 | 838 | */ |
michael@0 | 839 | inline UnicodeString |
michael@0 | 840 | ures_getUnicodeStringByIndex(const UResourceBundle *resB, |
michael@0 | 841 | int32_t indexS, |
michael@0 | 842 | UErrorCode* status) |
michael@0 | 843 | { |
michael@0 | 844 | int32_t len = 0; |
michael@0 | 845 | const UChar* r = ures_getStringByIndex(resB, indexS, &len, status); |
michael@0 | 846 | return UnicodeString(TRUE, r, len); |
michael@0 | 847 | } |
michael@0 | 848 | |
michael@0 | 849 | /** |
michael@0 | 850 | * Returns a string in a resource that has a given key. This procedure works only with table |
michael@0 | 851 | * resources. |
michael@0 | 852 | * |
michael@0 | 853 | * @param resB a resource |
michael@0 | 854 | * @param key a key associated with the wanted string |
michael@0 | 855 | * @param status fills in the outgoing error code |
michael@0 | 856 | * @return an UnicodeString object. If there is an error, string is bogus |
michael@0 | 857 | * @stable ICU 2.0 |
michael@0 | 858 | */ |
michael@0 | 859 | inline UnicodeString |
michael@0 | 860 | ures_getUnicodeStringByKey(const UResourceBundle *resB, |
michael@0 | 861 | const char* key, |
michael@0 | 862 | UErrorCode* status) |
michael@0 | 863 | { |
michael@0 | 864 | int32_t len = 0; |
michael@0 | 865 | const UChar* r = ures_getStringByKey(resB, key, &len, status); |
michael@0 | 866 | return UnicodeString(TRUE, r, len); |
michael@0 | 867 | } |
michael@0 | 868 | |
michael@0 | 869 | U_NAMESPACE_END |
michael@0 | 870 | |
michael@0 | 871 | #endif |
michael@0 | 872 | |
michael@0 | 873 | /** |
michael@0 | 874 | * Create a string enumerator, owned by the caller, of all locales located within |
michael@0 | 875 | * the specified resource tree. |
michael@0 | 876 | * @param packageName name of the tree, such as (NULL) or U_ICUDATA_ALIAS or or "ICUDATA-coll" |
michael@0 | 877 | * This call is similar to uloc_getAvailable(). |
michael@0 | 878 | * @param status error code |
michael@0 | 879 | * @stable ICU 3.2 |
michael@0 | 880 | */ |
michael@0 | 881 | U_STABLE UEnumeration* U_EXPORT2 |
michael@0 | 882 | ures_openAvailableLocales(const char *packageName, UErrorCode *status); |
michael@0 | 883 | |
michael@0 | 884 | |
michael@0 | 885 | #endif /*_URES*/ |
michael@0 | 886 | /*eof*/ |