intl/icu/source/common/unicode/ures.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/common/unicode/ures.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,886 @@
     1.4 +/*
     1.5 +**********************************************************************
     1.6 +*   Copyright (C) 1997-2012, International Business Machines
     1.7 +*   Corporation and others.  All Rights Reserved.
     1.8 +**********************************************************************
     1.9 +*
    1.10 +* File URES.H (formerly CRESBUND.H)
    1.11 +*
    1.12 +* Modification History:
    1.13 +*
    1.14 +*   Date        Name        Description
    1.15 +*   04/01/97    aliu        Creation.
    1.16 +*   02/22/99    damiba      overhaul.
    1.17 +*   04/04/99    helena      Fixed internal header inclusion.
    1.18 +*   04/15/99    Madhu       Updated Javadoc  
    1.19 +*   06/14/99    stephen     Removed functions taking a filename suffix.
    1.20 +*   07/20/99    stephen     Language-independent ypedef to void*
    1.21 +*   11/09/99    weiv        Added ures_getLocale()
    1.22 +*   06/24/02    weiv        Added support for resource sharing
    1.23 +******************************************************************************
    1.24 +*/
    1.25 +
    1.26 +#ifndef URES_H
    1.27 +#define URES_H
    1.28 +
    1.29 +#include "unicode/utypes.h"
    1.30 +#include "unicode/uloc.h"
    1.31 +#include "unicode/localpointer.h"
    1.32 +
    1.33 +/**
    1.34 + * \file
    1.35 + * \brief C API: Resource Bundle 
    1.36 + *
    1.37 + * <h2>C API: Resource Bundle</h2>
    1.38 + *
    1.39 + * C API representing a collection of resource information pertaining to a given
    1.40 + * locale. A resource bundle provides a way of accessing locale- specific information in
    1.41 + * a data file. You create a resource bundle that manages the resources for a given
    1.42 + * locale and then ask it for individual resources.
    1.43 + * <P>
    1.44 + * Resource bundles in ICU4C are currently defined using text files which conform to the following
    1.45 + * <a href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt">BNF definition</a>.
    1.46 + * More on resource bundle concepts and syntax can be found in the 
    1.47 + * <a href="http://icu-project.org/userguide/ResourceManagement.html">Users Guide</a>.
    1.48 + * <P>
    1.49 + */
    1.50 +
    1.51 +/**
    1.52 + * UResourceBundle is an opaque type for handles for resource bundles in C APIs.
    1.53 + * @stable ICU 2.0
    1.54 + */
    1.55 +struct UResourceBundle;
    1.56 +
    1.57 +/**
    1.58 + * @stable ICU 2.0
    1.59 + */
    1.60 +typedef struct UResourceBundle UResourceBundle;
    1.61 +
    1.62 +/**
    1.63 + * Numeric constants for types of resource items.
    1.64 + * @see ures_getType
    1.65 + * @stable ICU 2.0
    1.66 + */
    1.67 +typedef enum {
    1.68 +    /** Resource type constant for "no resource". @stable ICU 2.6 */
    1.69 +    URES_NONE=-1,
    1.70 +
    1.71 +    /** Resource type constant for 16-bit Unicode strings. @stable ICU 2.6 */
    1.72 +    URES_STRING=0,
    1.73 +
    1.74 +    /** Resource type constant for binary data. @stable ICU 2.6 */
    1.75 +    URES_BINARY=1,
    1.76 +
    1.77 +    /** Resource type constant for tables of key-value pairs. @stable ICU 2.6 */
    1.78 +    URES_TABLE=2,
    1.79 +
    1.80 +    /**
    1.81 +     * Resource type constant for aliases;
    1.82 +     * internally stores a string which identifies the actual resource
    1.83 +     * storing the data (can be in a different resource bundle).
    1.84 +     * Resolved internally before delivering the actual resource through the API.
    1.85 +     * @stable ICU 2.6
    1.86 +     */
    1.87 +    URES_ALIAS=3,
    1.88 +
    1.89 +    /**
    1.90 +     * Resource type constant for a single 28-bit integer, interpreted as
    1.91 +     * signed or unsigned by the ures_getInt() or ures_getUInt() function.
    1.92 +     * @see ures_getInt
    1.93 +     * @see ures_getUInt
    1.94 +     * @stable ICU 2.6
    1.95 +     */
    1.96 +    URES_INT=7,
    1.97 +
    1.98 +    /** Resource type constant for arrays of resources. @stable ICU 2.6 */
    1.99 +    URES_ARRAY=8,
   1.100 +
   1.101 +    /**
   1.102 +     * Resource type constant for vectors of 32-bit integers.
   1.103 +     * @see ures_getIntVector
   1.104 +     * @stable ICU 2.6
   1.105 +     */
   1.106 +    URES_INT_VECTOR = 14,
   1.107 +#ifndef U_HIDE_DEPRECATED_API
   1.108 +    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
   1.109 +    RES_NONE=URES_NONE,
   1.110 +    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
   1.111 +    RES_STRING=URES_STRING,
   1.112 +    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
   1.113 +    RES_BINARY=URES_BINARY,
   1.114 +    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
   1.115 +    RES_TABLE=URES_TABLE,
   1.116 +    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
   1.117 +    RES_ALIAS=URES_ALIAS,
   1.118 +    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
   1.119 +    RES_INT=URES_INT,
   1.120 +    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
   1.121 +    RES_ARRAY=URES_ARRAY,
   1.122 +    /** @deprecated ICU 2.6 Use the URES_ constant instead. */
   1.123 +    RES_INT_VECTOR=URES_INT_VECTOR,
   1.124 +    /** @deprecated ICU 2.6 Not used. */
   1.125 +    RES_RESERVED=15, 
   1.126 +#endif /* U_HIDE_DEPRECATED_API */
   1.127 +
   1.128 +    URES_LIMIT = 16
   1.129 +} UResType;
   1.130 +
   1.131 +/*
   1.132 + * Functions to create and destroy resource bundles.
   1.133 + */
   1.134 +
   1.135 +/**
   1.136 + * Opens a UResourceBundle, from which users can extract strings by using
   1.137 + * their corresponding keys.
   1.138 + * Note that the caller is responsible of calling <TT>ures_close</TT> on each succesfully
   1.139 + * opened resource bundle.
   1.140 + * @param packageName   The packageName and locale together point to an ICU udata object, 
   1.141 + *                      as defined by <code> udata_open( packageName, "res", locale, err) </code> 
   1.142 + *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to
   1.143 + *                      a package registered with udata_setAppData(). Using a full file or directory
   1.144 + *                      pathname for packageName is deprecated. If NULL, ICU data will be used.
   1.145 + * @param locale  specifies the locale for which we want to open the resource
   1.146 + *                if NULL, the default locale will be used. If strlen(locale) == 0
   1.147 + *                root locale will be used.
   1.148 + *                
   1.149 + * @param status  fills in the outgoing error code.
   1.150 + * The UErrorCode err parameter is used to return status information to the user. To
   1.151 + * check whether the construction succeeded or not, you should check the value of
   1.152 + * U_SUCCESS(err). If you wish more detailed information, you can check for
   1.153 + * informational status results which still indicate success. U_USING_FALLBACK_WARNING
   1.154 + * indicates that a fall back locale was used. For example, 'de_CH' was requested,
   1.155 + * but nothing was found there, so 'de' was used. U_USING_DEFAULT_WARNING indicates that
   1.156 + * the default locale data or root locale data was used; neither the requested locale 
   1.157 + * nor any of its fall back locales could be found. Please see the users guide for more 
   1.158 + * information on this topic.
   1.159 + * @return      a newly allocated resource bundle.
   1.160 + * @see ures_close
   1.161 + * @stable ICU 2.0
   1.162 + */
   1.163 +U_STABLE UResourceBundle*  U_EXPORT2 
   1.164 +ures_open(const char*    packageName,
   1.165 +          const char*  locale, 
   1.166 +          UErrorCode*     status);
   1.167 +
   1.168 +
   1.169 +/** This function does not care what kind of localeID is passed in. It simply opens a bundle with 
   1.170 + *  that name. Fallback mechanism is disabled for the new bundle. If the requested bundle contains
   1.171 + *  an %%ALIAS directive, the results are undefined.
   1.172 + * @param packageName   The packageName and locale together point to an ICU udata object, 
   1.173 + *                      as defined by <code> udata_open( packageName, "res", locale, err) </code> 
   1.174 + *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to
   1.175 + *                      a package registered with udata_setAppData(). Using a full file or directory
   1.176 + *                      pathname for packageName is deprecated. If NULL, ICU data will be used.
   1.177 + * @param locale  specifies the locale for which we want to open the resource
   1.178 + *                if NULL, the default locale will be used. If strlen(locale) == 0
   1.179 + *                root locale will be used.
   1.180 + *                
   1.181 + * @param status fills in the outgoing error code. Either U_ZERO_ERROR or U_MISSING_RESOURCE_ERROR
   1.182 + * @return      a newly allocated resource bundle or NULL if it doesn't exist.
   1.183 + * @see ures_close
   1.184 + * @stable ICU 2.0
   1.185 + */
   1.186 +U_STABLE UResourceBundle* U_EXPORT2 
   1.187 +ures_openDirect(const char* packageName, 
   1.188 +                const char* locale, 
   1.189 +                UErrorCode* status);
   1.190 +
   1.191 +/**
   1.192 + * Same as ures_open() but takes a const UChar *path.
   1.193 + * This path will be converted to char * using the default converter,
   1.194 + * then ures_open() is called.
   1.195 + *
   1.196 + * @param packageName   The packageName and locale together point to an ICU udata object, 
   1.197 + *                      as defined by <code> udata_open( packageName, "res", locale, err) </code> 
   1.198 + *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to
   1.199 + *                      a package registered with udata_setAppData(). Using a full file or directory
   1.200 + *                      pathname for packageName is deprecated. If NULL, ICU data will be used.
   1.201 + * @param locale  specifies the locale for which we want to open the resource
   1.202 + *                if NULL, the default locale will be used. If strlen(locale) == 0
   1.203 + *                root locale will be used.
   1.204 + * @param status  fills in the outgoing error code.
   1.205 + * @return      a newly allocated resource bundle.
   1.206 + * @see ures_open
   1.207 + * @stable ICU 2.0
   1.208 + */
   1.209 +U_STABLE UResourceBundle* U_EXPORT2 
   1.210 +ures_openU(const UChar* packageName, 
   1.211 +           const char* locale, 
   1.212 +           UErrorCode* status);
   1.213 +
   1.214 +#ifndef U_HIDE_DEPRECATED_API
   1.215 +/**
   1.216 + * Returns the number of strings/arrays in resource bundles.
   1.217 + * Better to use ures_getSize, as this function will be deprecated. 
   1.218 + *
   1.219 + *@param resourceBundle resource bundle containing the desired strings
   1.220 + *@param resourceKey key tagging the resource
   1.221 + *@param err fills in the outgoing error code
   1.222 + *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
   1.223 + *                could be a non-failing error 
   1.224 + *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_FALLBACK_WARNING </TT>
   1.225 + *@return: for    <STRONG>Arrays</STRONG>: returns the number of resources in the array
   1.226 + *                <STRONG>Tables</STRONG>: returns the number of resources in the table
   1.227 + *                <STRONG>single string</STRONG>: returns 1
   1.228 + *@see ures_getSize
   1.229 + * @deprecated ICU 2.8 User ures_getSize instead
   1.230 + */
   1.231 +U_DEPRECATED int32_t U_EXPORT2 
   1.232 +ures_countArrayItems(const UResourceBundle* resourceBundle,
   1.233 +                     const char* resourceKey,
   1.234 +                     UErrorCode* err);
   1.235 +#endif  /* U_HIDE_DEPRECATED_API */
   1.236 +/**
   1.237 + * Close a resource bundle, all pointers returned from the various ures_getXXX calls
   1.238 + * on this particular bundle should be considered invalid henceforth.
   1.239 + *
   1.240 + * @param resourceBundle a pointer to a resourceBundle struct. Can be NULL.
   1.241 + * @see ures_open
   1.242 + * @stable ICU 2.0
   1.243 + */
   1.244 +U_STABLE void U_EXPORT2 
   1.245 +ures_close(UResourceBundle* resourceBundle);
   1.246 +
   1.247 +#if U_SHOW_CPLUSPLUS_API
   1.248 +
   1.249 +U_NAMESPACE_BEGIN
   1.250 +
   1.251 +/**
   1.252 + * \class LocalUResourceBundlePointer
   1.253 + * "Smart pointer" class, closes a UResourceBundle via ures_close().
   1.254 + * For most methods see the LocalPointerBase base class.
   1.255 + *
   1.256 + * @see LocalPointerBase
   1.257 + * @see LocalPointer
   1.258 + * @stable ICU 4.4
   1.259 + */
   1.260 +U_DEFINE_LOCAL_OPEN_POINTER(LocalUResourceBundlePointer, UResourceBundle, ures_close);
   1.261 +
   1.262 +U_NAMESPACE_END
   1.263 +
   1.264 +#endif
   1.265 +
   1.266 +#ifndef U_HIDE_DEPRECATED_API
   1.267 +/**
   1.268 + * Return the version number associated with this ResourceBundle as a string. Please
   1.269 + * use ures_getVersion as this function is going to be deprecated.
   1.270 + *
   1.271 + * @param resourceBundle The resource bundle for which the version is checked.
   1.272 + * @return  A version number string as specified in the resource bundle or its parent.
   1.273 + *          The caller does not own this string.
   1.274 + * @see ures_getVersion
   1.275 + * @deprecated ICU 2.8 Use ures_getVersion instead.
   1.276 + */
   1.277 +U_DEPRECATED const char* U_EXPORT2 
   1.278 +ures_getVersionNumber(const UResourceBundle*   resourceBundle);
   1.279 +#endif  /* U_HIDE_DEPRECATED_API */
   1.280 +
   1.281 +/**
   1.282 + * Return the version number associated with this ResourceBundle as an 
   1.283 + * UVersionInfo array.
   1.284 + *
   1.285 + * @param resB The resource bundle for which the version is checked.
   1.286 + * @param versionInfo A UVersionInfo array that is filled with the version number
   1.287 + *                    as specified in the resource bundle or its parent.
   1.288 + * @stable ICU 2.0
   1.289 + */
   1.290 +U_STABLE void U_EXPORT2 
   1.291 +ures_getVersion(const UResourceBundle* resB, 
   1.292 +                UVersionInfo versionInfo);
   1.293 +
   1.294 +#ifndef U_HIDE_DEPRECATED_API
   1.295 +/**
   1.296 + * Return the name of the Locale associated with this ResourceBundle. This API allows
   1.297 + * you to query for the real locale of the resource. For example, if you requested 
   1.298 + * "en_US_CALIFORNIA" and only "en_US" bundle exists, "en_US" will be returned. 
   1.299 + * For subresources, the locale where this resource comes from will be returned.
   1.300 + * If fallback has occured, getLocale will reflect this.
   1.301 + *
   1.302 + * @param resourceBundle resource bundle in question
   1.303 + * @param status just for catching illegal arguments
   1.304 + * @return  A Locale name
   1.305 + * @deprecated ICU 2.8 Use ures_getLocaleByType instead.
   1.306 + */
   1.307 +U_DEPRECATED const char* U_EXPORT2 
   1.308 +ures_getLocale(const UResourceBundle* resourceBundle, 
   1.309 +               UErrorCode* status);
   1.310 +#endif  /* U_HIDE_DEPRECATED_API */
   1.311 +
   1.312 +/**
   1.313 + * Return the name of the Locale associated with this ResourceBundle. 
   1.314 + * You can choose between requested, valid and real locale.
   1.315 + *
   1.316 + * @param resourceBundle resource bundle in question
   1.317 + * @param type You can choose between requested, valid and actual
   1.318 + *             locale. For description see the definition of
   1.319 + *             ULocDataLocaleType in uloc.h
   1.320 + * @param status just for catching illegal arguments
   1.321 + * @return  A Locale name
   1.322 + * @stable ICU 2.8
   1.323 + */
   1.324 +U_STABLE const char* U_EXPORT2 
   1.325 +ures_getLocaleByType(const UResourceBundle* resourceBundle, 
   1.326 +                     ULocDataLocaleType type, 
   1.327 +                     UErrorCode* status);
   1.328 +
   1.329 +
   1.330 +#ifndef U_HIDE_INTERNAL_API
   1.331 +/**
   1.332 + * Same as ures_open() but uses the fill-in parameter instead of allocating
   1.333 + * a bundle, if r!=NULL.
   1.334 + * TODO need to revisit usefulness of this function
   1.335 + *      and usage model for fillIn parameters without knowing sizeof(UResourceBundle)
   1.336 + * @param r The resourcebundle to open
   1.337 + * @param packageName   The packageName and locale together point to an ICU udata object, 
   1.338 + *                      as defined by <code> udata_open( packageName, "res", locale, err) </code> 
   1.339 + *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to
   1.340 + *                      a package registered with udata_setAppData(). Using a full file or directory
   1.341 + *                      pathname for packageName is deprecated. If NULL, ICU data will be used.
   1.342 + * @param localeID specifies the locale for which we want to open the resource
   1.343 + * @param status The error code
   1.344 + * @return a newly allocated resource bundle or NULL if it doesn't exist.
   1.345 + * @internal
   1.346 + */
   1.347 +U_INTERNAL void U_EXPORT2 
   1.348 +ures_openFillIn(UResourceBundle *r, 
   1.349 +                const char* packageName,
   1.350 +                const char* localeID, 
   1.351 +                UErrorCode* status);
   1.352 +#endif  /* U_HIDE_INTERNAL_API */
   1.353 +
   1.354 +/**
   1.355 + * Returns a string from a string resource type
   1.356 + *
   1.357 + * @param resourceBundle a string resource
   1.358 + * @param len    fills in the length of resulting string
   1.359 + * @param status fills in the outgoing error code
   1.360 + *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
   1.361 + *                Always check the value of status. Don't count on returning NULL.
   1.362 + *                could be a non-failing error 
   1.363 + *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
   1.364 + * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
   1.365 + * @see ures_getBinary
   1.366 + * @see ures_getIntVector
   1.367 + * @see ures_getInt
   1.368 + * @see ures_getUInt
   1.369 + * @stable ICU 2.0
   1.370 + */
   1.371 +U_STABLE const UChar* U_EXPORT2 
   1.372 +ures_getString(const UResourceBundle* resourceBundle, 
   1.373 +               int32_t* len, 
   1.374 +               UErrorCode* status);
   1.375 +
   1.376 +/**
   1.377 + * Returns a UTF-8 string from a string resource.
   1.378 + * The UTF-8 string may be returnable directly as a pointer, or
   1.379 + * it may need to be copied, or transformed from UTF-16 using u_strToUTF8()
   1.380 + * or equivalent.
   1.381 + *
   1.382 + * If forceCopy==TRUE, then the string is always written to the dest buffer
   1.383 + * and dest is returned.
   1.384 + *
   1.385 + * If forceCopy==FALSE, then the string is returned as a pointer if possible,
   1.386 + * without needing a dest buffer (it can be NULL). If the string needs to be
   1.387 + * copied or transformed, then it may be placed into dest at an arbitrary offset.
   1.388 + *
   1.389 + * If the string is to be written to dest, then U_BUFFER_OVERFLOW_ERROR and
   1.390 + * U_STRING_NOT_TERMINATED_WARNING are set if appropriate, as usual.
   1.391 + *
   1.392 + * If the string is transformed from UTF-16, then a conversion error may occur
   1.393 + * if an unpaired surrogate is encountered. If the function is successful, then
   1.394 + * the output UTF-8 string is always well-formed.
   1.395 + *
   1.396 + * @param resB Resource bundle.
   1.397 + * @param dest Destination buffer. Can be NULL only if capacity=*length==0.
   1.398 + * @param length Input: Capacity of destination buffer.
   1.399 + *               Output: Actual length of the UTF-8 string, not counting the
   1.400 + *               terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.
   1.401 + *               Can be NULL, meaning capacity=0 and the string length is not
   1.402 + *               returned to the caller.
   1.403 + * @param forceCopy If TRUE, then the output string will always be written to
   1.404 + *                  dest, with U_BUFFER_OVERFLOW_ERROR and
   1.405 + *                  U_STRING_NOT_TERMINATED_WARNING set if appropriate.
   1.406 + *                  If FALSE, then the dest buffer may or may not contain a
   1.407 + *                  copy of the string. dest may or may not be modified.
   1.408 + *                  If a copy needs to be written, then the UErrorCode parameter
   1.409 + *                  indicates overflow etc. as usual.
   1.410 + * @param status Pointer to a standard ICU error code. Its input value must
   1.411 + *               pass the U_SUCCESS() test, or else the function returns
   1.412 + *               immediately. Check for U_FAILURE() on output or use with
   1.413 + *               function chaining. (See User Guide for details.)
   1.414 + * @return The pointer to the UTF-8 string. It may be dest, or at some offset
   1.415 + *         from dest (only if !forceCopy), or in unrelated memory.
   1.416 + *         Always NUL-terminated unless the string was written to dest and
   1.417 + *         length==capacity (in which case U_STRING_NOT_TERMINATED_WARNING is set).
   1.418 + *
   1.419 + * @see ures_getString
   1.420 + * @see u_strToUTF8
   1.421 + * @stable ICU 3.6
   1.422 + */
   1.423 +U_STABLE const char * U_EXPORT2
   1.424 +ures_getUTF8String(const UResourceBundle *resB,
   1.425 +                   char *dest, int32_t *length,
   1.426 +                   UBool forceCopy,
   1.427 +                   UErrorCode *status);
   1.428 +
   1.429 +/**
   1.430 + * Returns a binary data from a binary resource. 
   1.431 + *
   1.432 + * @param resourceBundle a string resource
   1.433 + * @param len    fills in the length of resulting byte chunk
   1.434 + * @param status fills in the outgoing error code
   1.435 + *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
   1.436 + *                Always check the value of status. Don't count on returning NULL.
   1.437 + *                could be a non-failing error 
   1.438 + *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
   1.439 + * @return a pointer to a chunk of unsigned bytes which live in a memory mapped/DLL file.
   1.440 + * @see ures_getString
   1.441 + * @see ures_getIntVector
   1.442 + * @see ures_getInt
   1.443 + * @see ures_getUInt
   1.444 + * @stable ICU 2.0
   1.445 + */
   1.446 +U_STABLE const uint8_t* U_EXPORT2 
   1.447 +ures_getBinary(const UResourceBundle* resourceBundle, 
   1.448 +               int32_t* len, 
   1.449 +               UErrorCode* status);
   1.450 +
   1.451 +/**
   1.452 + * Returns a 32 bit integer array from a resource. 
   1.453 + *
   1.454 + * @param resourceBundle an int vector resource
   1.455 + * @param len    fills in the length of resulting byte chunk
   1.456 + * @param status fills in the outgoing error code
   1.457 + *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
   1.458 + *                Always check the value of status. Don't count on returning NULL.
   1.459 + *                could be a non-failing error 
   1.460 + *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
   1.461 + * @return a pointer to a chunk of integers which live in a memory mapped/DLL file.
   1.462 + * @see ures_getBinary
   1.463 + * @see ures_getString
   1.464 + * @see ures_getInt
   1.465 + * @see ures_getUInt
   1.466 + * @stable ICU 2.0
   1.467 + */
   1.468 +U_STABLE const int32_t* U_EXPORT2 
   1.469 +ures_getIntVector(const UResourceBundle* resourceBundle, 
   1.470 +                  int32_t* len, 
   1.471 +                  UErrorCode* status);
   1.472 +
   1.473 +/**
   1.474 + * Returns an unsigned integer from a resource. 
   1.475 + * This integer is originally 28 bits.
   1.476 + *
   1.477 + * @param resourceBundle a string resource
   1.478 + * @param status fills in the outgoing error code
   1.479 + *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
   1.480 + *                could be a non-failing error 
   1.481 + *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
   1.482 + * @return an integer value
   1.483 + * @see ures_getInt
   1.484 + * @see ures_getIntVector
   1.485 + * @see ures_getBinary
   1.486 + * @see ures_getString
   1.487 + * @stable ICU 2.0
   1.488 + */
   1.489 +U_STABLE uint32_t U_EXPORT2 
   1.490 +ures_getUInt(const UResourceBundle* resourceBundle, 
   1.491 +             UErrorCode *status);
   1.492 +
   1.493 +/**
   1.494 + * Returns a signed integer from a resource. 
   1.495 + * This integer is originally 28 bit and the sign gets propagated.
   1.496 + *
   1.497 + * @param resourceBundle a string resource
   1.498 + * @param status  fills in the outgoing error code
   1.499 + *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
   1.500 + *                could be a non-failing error 
   1.501 + *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
   1.502 + * @return an integer value
   1.503 + * @see ures_getUInt
   1.504 + * @see ures_getIntVector
   1.505 + * @see ures_getBinary
   1.506 + * @see ures_getString
   1.507 + * @stable ICU 2.0
   1.508 + */
   1.509 +U_STABLE int32_t U_EXPORT2 
   1.510 +ures_getInt(const UResourceBundle* resourceBundle, 
   1.511 +            UErrorCode *status);
   1.512 +
   1.513 +/**
   1.514 + * Returns the size of a resource. Size for scalar types is always 1, 
   1.515 + * and for vector/table types is the number of child resources.
   1.516 + * @warning Integer array is treated as a scalar type. There are no 
   1.517 + *          APIs to access individual members of an integer array. It
   1.518 + *          is always returned as a whole.
   1.519 + * @param resourceBundle a resource
   1.520 + * @return number of resources in a given resource.
   1.521 + * @stable ICU 2.0
   1.522 + */
   1.523 +U_STABLE int32_t U_EXPORT2 
   1.524 +ures_getSize(const UResourceBundle *resourceBundle);
   1.525 +
   1.526 +/**
   1.527 + * Returns the type of a resource. Available types are defined in enum UResType
   1.528 + *
   1.529 + * @param resourceBundle a resource
   1.530 + * @return type of the given resource.
   1.531 + * @see UResType
   1.532 + * @stable ICU 2.0
   1.533 + */
   1.534 +U_STABLE UResType U_EXPORT2 
   1.535 +ures_getType(const UResourceBundle *resourceBundle);
   1.536 +
   1.537 +/**
   1.538 + * Returns the key associated with a given resource. Not all the resources have a key - only 
   1.539 + * those that are members of a table.
   1.540 + *
   1.541 + * @param resourceBundle a resource
   1.542 + * @return a key associated to this resource, or NULL if it doesn't have a key
   1.543 + * @stable ICU 2.0
   1.544 + */
   1.545 +U_STABLE const char * U_EXPORT2 
   1.546 +ures_getKey(const UResourceBundle *resourceBundle);
   1.547 +
   1.548 +/* ITERATION API 
   1.549 +    This API provides means for iterating through a resource
   1.550 +*/
   1.551 +
   1.552 +/**
   1.553 + * Resets the internal context of a resource so that iteration starts from the first element.
   1.554 + *
   1.555 + * @param resourceBundle a resource
   1.556 + * @stable ICU 2.0
   1.557 + */
   1.558 +U_STABLE void U_EXPORT2 
   1.559 +ures_resetIterator(UResourceBundle *resourceBundle);
   1.560 +
   1.561 +/**
   1.562 + * Checks whether the given resource has another element to iterate over.
   1.563 + *
   1.564 + * @param resourceBundle a resource
   1.565 + * @return TRUE if there are more elements, FALSE if there is no more elements
   1.566 + * @stable ICU 2.0
   1.567 + */
   1.568 +U_STABLE UBool U_EXPORT2 
   1.569 +ures_hasNext(const UResourceBundle *resourceBundle);
   1.570 +
   1.571 +/**
   1.572 + * Returns the next resource in a given resource or NULL if there are no more resources 
   1.573 + * to iterate over. Features a fill-in parameter. 
   1.574 + *
   1.575 + * @param resourceBundle    a resource
   1.576 + * @param fillIn            if NULL a new UResourceBundle struct is allocated and must be closed by the caller.
   1.577 + *                          Alternatively, you can supply a struct to be filled by this function.
   1.578 + * @param status            fills in the outgoing error code. You may still get a non NULL result even if an
   1.579 + *                          error occured. Check status instead.
   1.580 + * @return                  a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it
   1.581 + * @stable ICU 2.0
   1.582 + */
   1.583 +U_STABLE UResourceBundle* U_EXPORT2 
   1.584 +ures_getNextResource(UResourceBundle *resourceBundle, 
   1.585 +                     UResourceBundle *fillIn, 
   1.586 +                     UErrorCode *status);
   1.587 +
   1.588 +/**
   1.589 + * Returns the next string in a given resource or NULL if there are no more resources 
   1.590 + * to iterate over. 
   1.591 + *
   1.592 + * @param resourceBundle    a resource
   1.593 + * @param len               fill in length of the string
   1.594 + * @param key               fill in for key associated with this string. NULL if no key
   1.595 + * @param status            fills in the outgoing error code. If an error occured, we may return NULL, but don't
   1.596 + *                          count on it. Check status instead!
   1.597 + * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
   1.598 + * @stable ICU 2.0
   1.599 + */
   1.600 +U_STABLE const UChar* U_EXPORT2 
   1.601 +ures_getNextString(UResourceBundle *resourceBundle, 
   1.602 +                   int32_t* len, 
   1.603 +                   const char ** key, 
   1.604 +                   UErrorCode *status);
   1.605 +
   1.606 +/**
   1.607 + * Returns the resource in a given resource at the specified index. Features a fill-in parameter. 
   1.608 + *
   1.609 + * @param resourceBundle    the resource bundle from which to get a sub-resource
   1.610 + * @param indexR            an index to the wanted resource.
   1.611 + * @param fillIn            if NULL a new UResourceBundle struct is allocated and must be closed by the caller.
   1.612 + *                          Alternatively, you can supply a struct to be filled by this function.
   1.613 + * @param status            fills in the outgoing error code. Don't count on NULL being returned if an error has
   1.614 + *                          occured. Check status instead.
   1.615 + * @return                  a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it
   1.616 + * @stable ICU 2.0
   1.617 + */
   1.618 +U_STABLE UResourceBundle* U_EXPORT2 
   1.619 +ures_getByIndex(const UResourceBundle *resourceBundle, 
   1.620 +                int32_t indexR, 
   1.621 +                UResourceBundle *fillIn, 
   1.622 +                UErrorCode *status);
   1.623 +
   1.624 +/**
   1.625 + * Returns the string in a given resource at the specified index.
   1.626 + *
   1.627 + * @param resourceBundle    a resource
   1.628 + * @param indexS            an index to the wanted string.
   1.629 + * @param len               fill in length of the string
   1.630 + * @param status            fills in the outgoing error code. If an error occured, we may return NULL, but don't
   1.631 + *                          count on it. Check status instead!
   1.632 + * @return                  a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
   1.633 + * @stable ICU 2.0
   1.634 + */
   1.635 +U_STABLE const UChar* U_EXPORT2 
   1.636 +ures_getStringByIndex(const UResourceBundle *resourceBundle, 
   1.637 +                      int32_t indexS, 
   1.638 +                      int32_t* len, 
   1.639 +                      UErrorCode *status);
   1.640 +
   1.641 +/**
   1.642 + * Returns a UTF-8 string from a resource at the specified index.
   1.643 + * The UTF-8 string may be returnable directly as a pointer, or
   1.644 + * it may need to be copied, or transformed from UTF-16 using u_strToUTF8()
   1.645 + * or equivalent.
   1.646 + *
   1.647 + * If forceCopy==TRUE, then the string is always written to the dest buffer
   1.648 + * and dest is returned.
   1.649 + *
   1.650 + * If forceCopy==FALSE, then the string is returned as a pointer if possible,
   1.651 + * without needing a dest buffer (it can be NULL). If the string needs to be
   1.652 + * copied or transformed, then it may be placed into dest at an arbitrary offset.
   1.653 + *
   1.654 + * If the string is to be written to dest, then U_BUFFER_OVERFLOW_ERROR and
   1.655 + * U_STRING_NOT_TERMINATED_WARNING are set if appropriate, as usual.
   1.656 + *
   1.657 + * If the string is transformed from UTF-16, then a conversion error may occur
   1.658 + * if an unpaired surrogate is encountered. If the function is successful, then
   1.659 + * the output UTF-8 string is always well-formed.
   1.660 + *
   1.661 + * @param resB Resource bundle.
   1.662 + * @param stringIndex An index to the wanted string.
   1.663 + * @param dest Destination buffer. Can be NULL only if capacity=*length==0.
   1.664 + * @param pLength Input: Capacity of destination buffer.
   1.665 + *               Output: Actual length of the UTF-8 string, not counting the
   1.666 + *               terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.
   1.667 + *               Can be NULL, meaning capacity=0 and the string length is not
   1.668 + *               returned to the caller.
   1.669 + * @param forceCopy If TRUE, then the output string will always be written to
   1.670 + *                  dest, with U_BUFFER_OVERFLOW_ERROR and
   1.671 + *                  U_STRING_NOT_TERMINATED_WARNING set if appropriate.
   1.672 + *                  If FALSE, then the dest buffer may or may not contain a
   1.673 + *                  copy of the string. dest may or may not be modified.
   1.674 + *                  If a copy needs to be written, then the UErrorCode parameter
   1.675 + *                  indicates overflow etc. as usual.
   1.676 + * @param status Pointer to a standard ICU error code. Its input value must
   1.677 + *               pass the U_SUCCESS() test, or else the function returns
   1.678 + *               immediately. Check for U_FAILURE() on output or use with
   1.679 + *               function chaining. (See User Guide for details.)
   1.680 + * @return The pointer to the UTF-8 string. It may be dest, or at some offset
   1.681 + *         from dest (only if !forceCopy), or in unrelated memory.
   1.682 + *         Always NUL-terminated unless the string was written to dest and
   1.683 + *         length==capacity (in which case U_STRING_NOT_TERMINATED_WARNING is set).
   1.684 + *
   1.685 + * @see ures_getStringByIndex
   1.686 + * @see u_strToUTF8
   1.687 + * @stable ICU 3.6
   1.688 + */
   1.689 +U_STABLE const char * U_EXPORT2
   1.690 +ures_getUTF8StringByIndex(const UResourceBundle *resB,
   1.691 +                          int32_t stringIndex,
   1.692 +                          char *dest, int32_t *pLength,
   1.693 +                          UBool forceCopy,
   1.694 +                          UErrorCode *status);
   1.695 +
   1.696 +/**
   1.697 + * Returns a resource in a given resource that has a given key. This procedure works only with table
   1.698 + * resources. Features a fill-in parameter. 
   1.699 + *
   1.700 + * @param resourceBundle    a resource
   1.701 + * @param key               a key associated with the wanted resource
   1.702 + * @param fillIn            if NULL a new UResourceBundle struct is allocated and must be closed by the caller.
   1.703 + *                          Alternatively, you can supply a struct to be filled by this function.
   1.704 + * @param status            fills in the outgoing error code.
   1.705 + * @return                  a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it
   1.706 + * @stable ICU 2.0
   1.707 + */
   1.708 +U_STABLE UResourceBundle* U_EXPORT2 
   1.709 +ures_getByKey(const UResourceBundle *resourceBundle, 
   1.710 +              const char* key, 
   1.711 +              UResourceBundle *fillIn, 
   1.712 +              UErrorCode *status);
   1.713 +
   1.714 +/**
   1.715 + * Returns a string in a given resource that has a given key. This procedure works only with table
   1.716 + * resources. 
   1.717 + *
   1.718 + * @param resB              a resource
   1.719 + * @param key               a key associated with the wanted string
   1.720 + * @param len               fill in length of the string
   1.721 + * @param status            fills in the outgoing error code. If an error occured, we may return NULL, but don't
   1.722 + *                          count on it. Check status instead!
   1.723 + * @return                  a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
   1.724 + * @stable ICU 2.0
   1.725 + */
   1.726 +U_STABLE const UChar* U_EXPORT2 
   1.727 +ures_getStringByKey(const UResourceBundle *resB, 
   1.728 +                    const char* key, 
   1.729 +                    int32_t* len, 
   1.730 +                    UErrorCode *status);
   1.731 +
   1.732 +/**
   1.733 + * Returns a UTF-8 string from a resource and a key.
   1.734 + * This function works only with table resources.
   1.735 + *
   1.736 + * The UTF-8 string may be returnable directly as a pointer, or
   1.737 + * it may need to be copied, or transformed from UTF-16 using u_strToUTF8()
   1.738 + * or equivalent.
   1.739 + *
   1.740 + * If forceCopy==TRUE, then the string is always written to the dest buffer
   1.741 + * and dest is returned.
   1.742 + *
   1.743 + * If forceCopy==FALSE, then the string is returned as a pointer if possible,
   1.744 + * without needing a dest buffer (it can be NULL). If the string needs to be
   1.745 + * copied or transformed, then it may be placed into dest at an arbitrary offset.
   1.746 + *
   1.747 + * If the string is to be written to dest, then U_BUFFER_OVERFLOW_ERROR and
   1.748 + * U_STRING_NOT_TERMINATED_WARNING are set if appropriate, as usual.
   1.749 + *
   1.750 + * If the string is transformed from UTF-16, then a conversion error may occur
   1.751 + * if an unpaired surrogate is encountered. If the function is successful, then
   1.752 + * the output UTF-8 string is always well-formed.
   1.753 + *
   1.754 + * @param resB Resource bundle.
   1.755 + * @param key  A key associated with the wanted resource
   1.756 + * @param dest Destination buffer. Can be NULL only if capacity=*length==0.
   1.757 + * @param pLength Input: Capacity of destination buffer.
   1.758 + *               Output: Actual length of the UTF-8 string, not counting the
   1.759 + *               terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.
   1.760 + *               Can be NULL, meaning capacity=0 and the string length is not
   1.761 + *               returned to the caller.
   1.762 + * @param forceCopy If TRUE, then the output string will always be written to
   1.763 + *                  dest, with U_BUFFER_OVERFLOW_ERROR and
   1.764 + *                  U_STRING_NOT_TERMINATED_WARNING set if appropriate.
   1.765 + *                  If FALSE, then the dest buffer may or may not contain a
   1.766 + *                  copy of the string. dest may or may not be modified.
   1.767 + *                  If a copy needs to be written, then the UErrorCode parameter
   1.768 + *                  indicates overflow etc. as usual.
   1.769 + * @param status Pointer to a standard ICU error code. Its input value must
   1.770 + *               pass the U_SUCCESS() test, or else the function returns
   1.771 + *               immediately. Check for U_FAILURE() on output or use with
   1.772 + *               function chaining. (See User Guide for details.)
   1.773 + * @return The pointer to the UTF-8 string. It may be dest, or at some offset
   1.774 + *         from dest (only if !forceCopy), or in unrelated memory.
   1.775 + *         Always NUL-terminated unless the string was written to dest and
   1.776 + *         length==capacity (in which case U_STRING_NOT_TERMINATED_WARNING is set).
   1.777 + *
   1.778 + * @see ures_getStringByKey
   1.779 + * @see u_strToUTF8
   1.780 + * @stable ICU 3.6
   1.781 + */
   1.782 +U_STABLE const char * U_EXPORT2
   1.783 +ures_getUTF8StringByKey(const UResourceBundle *resB,
   1.784 +                        const char *key,
   1.785 +                        char *dest, int32_t *pLength,
   1.786 +                        UBool forceCopy,
   1.787 +                        UErrorCode *status);
   1.788 +
   1.789 +#if U_SHOW_CPLUSPLUS_API
   1.790 +#include "unicode/unistr.h"
   1.791 +
   1.792 +U_NAMESPACE_BEGIN
   1.793 +/**
   1.794 + * returns a string from a string resource type
   1.795 + *
   1.796 + * @param resB    a resource
   1.797 + * @param status: fills in the outgoing error code
   1.798 + *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found
   1.799 + *                could be a non-failing error 
   1.800 + *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>
   1.801 + * @return        a UnicodeString object. If there is an error, string is bogus
   1.802 + * @stable ICU 2.0
   1.803 + */
   1.804 +inline UnicodeString 
   1.805 +ures_getUnicodeString(const UResourceBundle *resB, 
   1.806 +                      UErrorCode* status) 
   1.807 +{
   1.808 +    int32_t len = 0;
   1.809 +    const UChar *r = ures_getString(resB, &len, status);
   1.810 +    return UnicodeString(TRUE, r, len);
   1.811 +}
   1.812 +
   1.813 +/**
   1.814 + * Returns the next string in a resource or NULL if there are no more resources 
   1.815 + * to iterate over. 
   1.816 + *
   1.817 + * @param resB              a resource
   1.818 + * @param key               fill in for key associated with this string
   1.819 + * @param status            fills in the outgoing error code
   1.820 + * @return an UnicodeString object.
   1.821 + * @stable ICU 2.0
   1.822 + */
   1.823 +inline UnicodeString 
   1.824 +ures_getNextUnicodeString(UResourceBundle *resB, 
   1.825 +                          const char ** key, 
   1.826 +                          UErrorCode* status) 
   1.827 +{
   1.828 +    int32_t len = 0;
   1.829 +    const UChar* r = ures_getNextString(resB, &len, key, status);
   1.830 +    return UnicodeString(TRUE, r, len);
   1.831 +}
   1.832 +
   1.833 +/**
   1.834 + * Returns the string in a given resource at the specified index.
   1.835 + *
   1.836 + * @param resB              a resource
   1.837 + * @param indexS            an index to the wanted string.
   1.838 + * @param status            fills in the outgoing error code
   1.839 + * @return                  an UnicodeString object. If there is an error, string is bogus
   1.840 + * @stable ICU 2.0
   1.841 + */
   1.842 +inline UnicodeString 
   1.843 +ures_getUnicodeStringByIndex(const UResourceBundle *resB, 
   1.844 +                             int32_t indexS, 
   1.845 +                             UErrorCode* status) 
   1.846 +{
   1.847 +    int32_t len = 0;
   1.848 +    const UChar* r = ures_getStringByIndex(resB, indexS, &len, status);
   1.849 +    return UnicodeString(TRUE, r, len);
   1.850 +}
   1.851 +
   1.852 +/**
   1.853 + * Returns a string in a resource that has a given key. This procedure works only with table
   1.854 + * resources. 
   1.855 + *
   1.856 + * @param resB              a resource
   1.857 + * @param key               a key associated with the wanted string
   1.858 + * @param status            fills in the outgoing error code
   1.859 + * @return                  an UnicodeString object. If there is an error, string is bogus
   1.860 + * @stable ICU 2.0
   1.861 + */
   1.862 +inline UnicodeString 
   1.863 +ures_getUnicodeStringByKey(const UResourceBundle *resB, 
   1.864 +                           const char* key, 
   1.865 +                           UErrorCode* status) 
   1.866 +{
   1.867 +    int32_t len = 0;
   1.868 +    const UChar* r = ures_getStringByKey(resB, key, &len, status);
   1.869 +    return UnicodeString(TRUE, r, len);
   1.870 +}
   1.871 +
   1.872 +U_NAMESPACE_END
   1.873 +
   1.874 +#endif
   1.875 +
   1.876 +/**
   1.877 + * Create a string enumerator, owned by the caller, of all locales located within 
   1.878 + * the specified resource tree.
   1.879 + * @param packageName name of the tree, such as (NULL) or U_ICUDATA_ALIAS or  or "ICUDATA-coll"
   1.880 + * This call is similar to uloc_getAvailable().
   1.881 + * @param status error code
   1.882 + * @stable ICU 3.2
   1.883 + */
   1.884 +U_STABLE UEnumeration* U_EXPORT2
   1.885 +ures_openAvailableLocales(const char *packageName, UErrorCode *status);
   1.886 +
   1.887 +
   1.888 +#endif /*_URES*/
   1.889 +/*eof*/

mercurial