sl@0: /* sl@0: ********************************************************************** sl@0: * Copyright (C) 1997-2005, International Business Machines sl@0: * Corporation and others. All Rights Reserved. sl@0: ********************************************************************** sl@0: * sl@0: * File URES.H (formerly CRESBUND.H) sl@0: * sl@0: * Modification History: sl@0: * sl@0: * Date Name Description sl@0: * 04/01/97 aliu Creation. sl@0: * 02/22/99 damiba overhaul. sl@0: * 04/04/99 helena Fixed internal header inclusion. sl@0: * 04/15/99 Madhu Updated Javadoc sl@0: * 06/14/99 stephen Removed functions taking a filename suffix. sl@0: * 07/20/99 stephen Language-independent ypedef to void* sl@0: * 11/09/99 weiv Added ures_getLocale() sl@0: * 06/24/02 weiv Added support for resource sharing sl@0: ****************************************************************************** sl@0: */ sl@0: sl@0: #ifndef URES_H sl@0: #define URES_H sl@0: sl@0: #include "unicode/utypes.h" sl@0: #include "unicode/uloc.h" sl@0: sl@0: /** sl@0: * \file sl@0: * \brief C API: Resource Bundle sl@0: * sl@0: *
sl@0: * Resource bundles in ICU4C are currently defined using text files which conform to the following sl@0: * BNF definition. sl@0: * More on resource bundle concepts and syntax can be found in the sl@0: * Users Guide. sl@0: *
sl@0: */
sl@0:
sl@0: /**
sl@0: * UResourceBundle is an opaque type for handles for resource bundles in C APIs.
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: struct UResourceBundle;
sl@0:
sl@0: /**
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: typedef struct UResourceBundle UResourceBundle;
sl@0:
sl@0: /**
sl@0: * Numeric constants for types of resource items.
sl@0: * @see ures_getType
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: typedef enum {
sl@0: /** Resource type constant for "no resource". @stable ICU 2.6 */
sl@0: URES_NONE=-1,
sl@0:
sl@0: /** Resource type constant for 16-bit Unicode strings. @stable ICU 2.6 */
sl@0: URES_STRING=0,
sl@0:
sl@0: /** Resource type constant for binary data. @stable ICU 2.6 */
sl@0: URES_BINARY=1,
sl@0:
sl@0: /** Resource type constant for tables of key-value pairs. @stable ICU 2.6 */
sl@0: URES_TABLE=2,
sl@0:
sl@0: /**
sl@0: * Resource type constant for aliases;
sl@0: * internally stores a string which identifies the actual resource
sl@0: * storing the data (can be in a different resource bundle).
sl@0: * Resolved internally before delivering the actual resource through the API.
sl@0: * @stable ICU 2.6
sl@0: */
sl@0: URES_ALIAS=3,
sl@0:
sl@0: /**
sl@0: * Internal use only.
sl@0: * Alternative resource type constant for tables of key-value pairs.
sl@0: * Never returned by ures_getType().
sl@0: * @internal
sl@0: */
sl@0: URES_TABLE32=4,
sl@0:
sl@0: /**
sl@0: * Resource type constant for a single 28-bit integer, interpreted as
sl@0: * signed or unsigned by the ures_getInt() or ures_getUInt() function.
sl@0: * @see ures_getInt
sl@0: * @see ures_getUInt
sl@0: * @stable ICU 2.6
sl@0: */
sl@0: URES_INT=7,
sl@0:
sl@0: /** Resource type constant for arrays of resources. @stable ICU 2.6 */
sl@0: URES_ARRAY=8,
sl@0:
sl@0: /**
sl@0: * Resource type constant for vectors of 32-bit integers.
sl@0: * @see ures_getIntVector
sl@0: * @stable ICU 2.6
sl@0: */
sl@0: URES_INT_VECTOR=14,
sl@0:
sl@0: #ifndef U_HIDE_DEPRECATED_API
sl@0: /** @deprecated ICU 2.6 Use the URES_ constant instead. */
sl@0: RES_NONE=URES_NONE,
sl@0: /** @deprecated ICU 2.6 Use the URES_ constant instead. */
sl@0: RES_STRING=URES_STRING,
sl@0: /** @deprecated ICU 2.6 Use the URES_ constant instead. */
sl@0: RES_BINARY=URES_BINARY,
sl@0: /** @deprecated ICU 2.6 Use the URES_ constant instead. */
sl@0: RES_TABLE=URES_TABLE,
sl@0: /** @deprecated ICU 2.6 Use the URES_ constant instead. */
sl@0: RES_ALIAS=URES_ALIAS,
sl@0: /** @deprecated ICU 2.6 Use the URES_ constant instead. */
sl@0: RES_INT=URES_INT,
sl@0: /** @deprecated ICU 2.6 Use the URES_ constant instead. */
sl@0: RES_ARRAY=URES_ARRAY,
sl@0: /** @deprecated ICU 2.6 Use the URES_ constant instead. */
sl@0: RES_INT_VECTOR=URES_INT_VECTOR,
sl@0: #endif /* U_HIDE_DEPRECATED_API */
sl@0:
sl@0: /** @deprecated ICU 2.6 Not used. */
sl@0: RES_RESERVED=15
sl@0: } UResType;
sl@0:
sl@0: /*
sl@0: * Functions to create and destroy resource bundles.
sl@0: */
sl@0:
sl@0: /**
sl@0: * Opens a UResourceBundle, from which users can extract strings by using
sl@0: * their corresponding keys.
sl@0: * Note that the caller is responsible of calling ures_close on each succesfully
sl@0: * opened resource bundle.
sl@0: * @param packageName The packageName and locale together point to an ICU udata object,
sl@0: * as defined by udata_open( packageName, "res", locale, err)
sl@0: * or equivalent. Typically, packageName will refer to a (.dat) file, or to
sl@0: * a package registered with udata_setAppData(). Using a full file or directory
sl@0: * pathname for packageName is deprecated. If NULL, ICU data will be used.
sl@0: * @param locale specifies the locale for which we want to open the resource
sl@0: * if NULL, the default locale will be used. If strlen(locale) == 0
sl@0: * root locale will be used.
sl@0: *
sl@0: * @param status fills in the outgoing error code.
sl@0: * The UErrorCode err parameter is used to return status information to the user. To
sl@0: * check whether the construction succeeded or not, you should check the value of
sl@0: * U_SUCCESS(err). If you wish more detailed information, you can check for
sl@0: * informational status results which still indicate success. U_USING_FALLBACK_WARNING
sl@0: * indicates that a fall back locale was used. For example, 'de_CH' was requested,
sl@0: * but nothing was found there, so 'de' was used. U_USING_DEFAULT_WARNING indicates that
sl@0: * the default locale data or root locale data was used; neither the requested locale
sl@0: * nor any of its fall back locales could be found. Please see the users guide for more
sl@0: * information on this topic.
sl@0: * @return a newly allocated resource bundle.
sl@0: * @see ures_close
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE UResourceBundle* U_EXPORT2
sl@0: ures_open(const char* packageName,
sl@0: const char* locale,
sl@0: UErrorCode* status);
sl@0:
sl@0:
sl@0: /** This function does not care what kind of localeID is passed in. It simply opens a bundle with
sl@0: * that name. Fallback mechanism is disabled for the new bundle. If the requested bundle contains
sl@0: * an %%ALIAS directive, the results are undefined.
sl@0: * @param packageName The packageName and locale together point to an ICU udata object,
sl@0: * as defined by udata_open( packageName, "res", locale, err)
sl@0: * or equivalent. Typically, packageName will refer to a (.dat) file, or to
sl@0: * a package registered with udata_setAppData(). Using a full file or directory
sl@0: * pathname for packageName is deprecated. If NULL, ICU data will be used.
sl@0: * @param locale specifies the locale for which we want to open the resource
sl@0: * if NULL, the default locale will be used. If strlen(locale) == 0
sl@0: * root locale will be used.
sl@0: *
sl@0: * @param status fills in the outgoing error code. Either U_ZERO_ERROR or U_MISSING_RESOURCE_ERROR
sl@0: * @return a newly allocated resource bundle or NULL if it doesn't exist.
sl@0: * @see ures_close
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE UResourceBundle* U_EXPORT2
sl@0: ures_openDirect(const char* packageName,
sl@0: const char* locale,
sl@0: UErrorCode* status);
sl@0:
sl@0: /**
sl@0: * Same as ures_open() but takes a const UChar *path.
sl@0: * This path will be converted to char * using the default converter,
sl@0: * then ures_open() is called.
sl@0: *
sl@0: * @param packageName The packageName and locale together point to an ICU udata object,
sl@0: * as defined by udata_open( packageName, "res", locale, err)
sl@0: * or equivalent. Typically, packageName will refer to a (.dat) file, or to
sl@0: * a package registered with udata_setAppData(). Using a full file or directory
sl@0: * pathname for packageName is deprecated. If NULL, ICU data will be used.
sl@0: * @param locale specifies the locale for which we want to open the resource
sl@0: * if NULL, the default locale will be used. If strlen(locale) == 0
sl@0: * root locale will be used.
sl@0: * @param status fills in the outgoing error code.
sl@0: * @return a newly allocated resource bundle.
sl@0: * @see ures_open
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE UResourceBundle* U_EXPORT2
sl@0: ures_openU(const UChar* packageName,
sl@0: const char* locale,
sl@0: UErrorCode* status);
sl@0:
sl@0: /**
sl@0: * Returns the number of strings/arrays in resource bundles.
sl@0: * Better to use ures_getSize, as this function will be deprecated.
sl@0: *
sl@0: *@param resourceBundle resource bundle containing the desired strings
sl@0: *@param resourceKey key tagging the resource
sl@0: *@param err fills in the outgoing error code
sl@0: * could be U_MISSING_RESOURCE_ERROR if the key is not found
sl@0: * could be a non-failing error
sl@0: * e.g.: U_USING_FALLBACK_WARNING,U_USING_FALLBACK_WARNING
sl@0: *@return: for Arrays: returns the number of resources in the array
sl@0: * Tables: returns the number of resources in the table
sl@0: * single string: returns 1
sl@0: *@see ures_getSize
sl@0: * @deprecated ICU 2.8 User ures_getSize instead
sl@0: */
sl@0: U_DEPRECATED int32_t U_EXPORT2
sl@0: ures_countArrayItems(const UResourceBundle* resourceBundle,
sl@0: const char* resourceKey,
sl@0: UErrorCode* err);
sl@0: /**
sl@0: * Close a resource bundle, all pointers returned from the various ures_getXXX calls
sl@0: * on this particular bundle should be considered invalid henceforth.
sl@0: *
sl@0: * @param resourceBundle a pointer to a resourceBundle struct. Can be NULL.
sl@0: * @see ures_open
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE void U_EXPORT2
sl@0: ures_close(UResourceBundle* resourceBundle);
sl@0:
sl@0: /**
sl@0: * Return the version number associated with this ResourceBundle as a string. Please
sl@0: * use ures_getVersion as this function is going to be deprecated.
sl@0: *
sl@0: * @param resourceBundle The resource bundle for which the version is checked.
sl@0: * @return A version number string as specified in the resource bundle or its parent.
sl@0: * The caller does not own this string.
sl@0: * @see ures_getVersion
sl@0: * @deprecated ICU 2.8 Use ures_getVersion instead.
sl@0: */
sl@0: U_DEPRECATED const char* U_EXPORT2
sl@0: ures_getVersionNumber(const UResourceBundle* resourceBundle);
sl@0:
sl@0: /**
sl@0: * Return the version number associated with this ResourceBundle as an
sl@0: * UVersionInfo array.
sl@0: *
sl@0: * @param resB The resource bundle for which the version is checked.
sl@0: * @param versionInfo A UVersionInfo array that is filled with the version number
sl@0: * as specified in the resource bundle or its parent.
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE void U_EXPORT2
sl@0: ures_getVersion(const UResourceBundle* resB,
sl@0: UVersionInfo versionInfo);
sl@0:
sl@0: /**
sl@0: * Return the name of the Locale associated with this ResourceBundle. This API allows
sl@0: * you to query for the real locale of the resource. For example, if you requested
sl@0: * "en_US_CALIFORNIA" and only "en_US" bundle exists, "en_US" will be returned.
sl@0: * For subresources, the locale where this resource comes from will be returned.
sl@0: * If fallback has occured, getLocale will reflect this.
sl@0: *
sl@0: * @param resourceBundle resource bundle in question
sl@0: * @param status just for catching illegal arguments
sl@0: * @return A Locale name
sl@0: * @deprecated ICU 2.8 Use ures_getLocaleByType instead.
sl@0: */
sl@0: U_DEPRECATED const char* U_EXPORT2
sl@0: ures_getLocale(const UResourceBundle* resourceBundle,
sl@0: UErrorCode* status);
sl@0:
sl@0:
sl@0: /**
sl@0: * Return the name of the Locale associated with this ResourceBundle.
sl@0: * You can choose between requested, valid and real locale.
sl@0: *
sl@0: * @param resourceBundle resource bundle in question
sl@0: * @param type You can choose between requested, valid and actual
sl@0: * locale. For description see the definition of
sl@0: * ULocDataLocaleType in uloc.h
sl@0: * @param status just for catching illegal arguments
sl@0: * @return A Locale name
sl@0: * @draft ICU 2.8 likely to change in the future
sl@0: */
sl@0: U_DRAFT const char* U_EXPORT2
sl@0: ures_getLocaleByType(const UResourceBundle* resourceBundle,
sl@0: ULocDataLocaleType type,
sl@0: UErrorCode* status);
sl@0:
sl@0:
sl@0: /**
sl@0: * Same as ures_open() but uses the fill-in parameter instead of allocating
sl@0: * a bundle, if r!=NULL.
sl@0: * TODO need to revisit usefulness of this function
sl@0: * and usage model for fillIn parameters without knowing sizeof(UResourceBundle)
sl@0: * @param r The resourcebundle to open
sl@0: * @param packageName The packageName and locale together point to an ICU udata object,
sl@0: * as defined by udata_open( packageName, "res", locale, err)
sl@0: * or equivalent. Typically, packageName will refer to a (.dat) file, or to
sl@0: * a package registered with udata_setAppData(). Using a full file or directory
sl@0: * pathname for packageName is deprecated. If NULL, ICU data will be used.
sl@0: * @param localeID specifies the locale for which we want to open the resource
sl@0: * @param status The error code
sl@0: * @return a newly allocated resource bundle or NULL if it doesn't exist.
sl@0: * @internal
sl@0: */
sl@0: U_INTERNAL void U_EXPORT2
sl@0: ures_openFillIn(UResourceBundle *r,
sl@0: const char* packageName,
sl@0: const char* localeID,
sl@0: UErrorCode* status);
sl@0:
sl@0: /**
sl@0: * Returns a string from a string resource type
sl@0: *
sl@0: * @param resourceBundle a string resource
sl@0: * @param len fills in the length of resulting string
sl@0: * @param status fills in the outgoing error code
sl@0: * could be U_MISSING_RESOURCE_ERROR if the key is not found
sl@0: * Always check the value of status. Don't count on returning NULL.
sl@0: * could be a non-failing error
sl@0: * e.g.: U_USING_FALLBACK_WARNING,U_USING_DEFAULT_WARNING
sl@0: * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
sl@0: * @see ures_getBinary
sl@0: * @see ures_getIntVector
sl@0: * @see ures_getInt
sl@0: * @see ures_getUInt
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE const UChar* U_EXPORT2
sl@0: ures_getString(const UResourceBundle* resourceBundle,
sl@0: int32_t* len,
sl@0: UErrorCode* status);
sl@0:
sl@0: /**
sl@0: * Returns a binary data from a binary resource.
sl@0: *
sl@0: * @param resourceBundle a string resource
sl@0: * @param len fills in the length of resulting byte chunk
sl@0: * @param status fills in the outgoing error code
sl@0: * could be U_MISSING_RESOURCE_ERROR if the key is not found
sl@0: * Always check the value of status. Don't count on returning NULL.
sl@0: * could be a non-failing error
sl@0: * e.g.: U_USING_FALLBACK_WARNING,U_USING_DEFAULT_WARNING
sl@0: * @return a pointer to a chuck of unsigned bytes which live in a memory mapped/DLL file.
sl@0: * @see ures_getString
sl@0: * @see ures_getIntVector
sl@0: * @see ures_getInt
sl@0: * @see ures_getUInt
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE const uint8_t* U_EXPORT2
sl@0: ures_getBinary(const UResourceBundle* resourceBundle,
sl@0: int32_t* len,
sl@0: UErrorCode* status);
sl@0:
sl@0: /**
sl@0: * Returns a 32 bit integer array from a resource.
sl@0: *
sl@0: * @param resourceBundle an int vector resource
sl@0: * @param len fills in the length of resulting byte chunk
sl@0: * @param status fills in the outgoing error code
sl@0: * could be U_MISSING_RESOURCE_ERROR if the key is not found
sl@0: * Always check the value of status. Don't count on returning NULL.
sl@0: * could be a non-failing error
sl@0: * e.g.: U_USING_FALLBACK_WARNING,U_USING_DEFAULT_WARNING
sl@0: * @return a pointer to a chunk of unsigned bytes which live in a memory mapped/DLL file.
sl@0: * @see ures_getBinary
sl@0: * @see ures_getString
sl@0: * @see ures_getInt
sl@0: * @see ures_getUInt
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE const int32_t* U_EXPORT2
sl@0: ures_getIntVector(const UResourceBundle* resourceBundle,
sl@0: int32_t* len,
sl@0: UErrorCode* status);
sl@0:
sl@0: /**
sl@0: * Returns an unsigned integer from a resource.
sl@0: * This integer is originally 28 bits.
sl@0: *
sl@0: * @param resourceBundle a string resource
sl@0: * @param status fills in the outgoing error code
sl@0: * could be U_MISSING_RESOURCE_ERROR if the key is not found
sl@0: * could be a non-failing error
sl@0: * e.g.: U_USING_FALLBACK_WARNING,U_USING_DEFAULT_WARNING
sl@0: * @return an integer value
sl@0: * @see ures_getInt
sl@0: * @see ures_getIntVector
sl@0: * @see ures_getBinary
sl@0: * @see ures_getString
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE uint32_t U_EXPORT2
sl@0: ures_getUInt(const UResourceBundle* resourceBundle,
sl@0: UErrorCode *status);
sl@0:
sl@0: /**
sl@0: * Returns a signed integer from a resource.
sl@0: * This integer is originally 28 bit and the sign gets propagated.
sl@0: *
sl@0: * @param resourceBundle a string resource
sl@0: * @param status fills in the outgoing error code
sl@0: * could be U_MISSING_RESOURCE_ERROR if the key is not found
sl@0: * could be a non-failing error
sl@0: * e.g.: U_USING_FALLBACK_WARNING,U_USING_DEFAULT_WARNING
sl@0: * @return an integer value
sl@0: * @see ures_getUInt
sl@0: * @see ures_getIntVector
sl@0: * @see ures_getBinary
sl@0: * @see ures_getString
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE int32_t U_EXPORT2
sl@0: ures_getInt(const UResourceBundle* resourceBundle,
sl@0: UErrorCode *status);
sl@0:
sl@0: /**
sl@0: * Returns the size of a resource. Size for scalar types is always 1,
sl@0: * and for vector/table types is the number of child resources.
sl@0: * @warning Integer array is treated as a scalar type. There are no
sl@0: * APIs to access individual members of an integer array. It
sl@0: * is always returned as a whole.
sl@0: * @param resourceBundle a resource
sl@0: * @return number of resources in a given resource.
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE int32_t U_EXPORT2
sl@0: ures_getSize(const UResourceBundle *resourceBundle);
sl@0:
sl@0: /**
sl@0: * Returns the type of a resource. Available types are defined in enum UResType
sl@0: *
sl@0: * @param resourceBundle a resource
sl@0: * @return type of the given resource.
sl@0: * @see UResType
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE UResType U_EXPORT2
sl@0: ures_getType(const UResourceBundle *resourceBundle);
sl@0:
sl@0: /**
sl@0: * Returns the key associated with a given resource. Not all the resources have a key - only
sl@0: * those that are members of a table.
sl@0: *
sl@0: * @param resourceBundle a resource
sl@0: * @return a key associated to this resource, or NULL if it doesn't have a key
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE const char * U_EXPORT2
sl@0: ures_getKey(const UResourceBundle *resourceBundle);
sl@0:
sl@0: /* ITERATION API
sl@0: This API provides means for iterating through a resource
sl@0: */
sl@0:
sl@0: /**
sl@0: * Resets the internal context of a resource so that iteration starts from the first element.
sl@0: *
sl@0: * @param resourceBundle a resource
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE void U_EXPORT2
sl@0: ures_resetIterator(UResourceBundle *resourceBundle);
sl@0:
sl@0: /**
sl@0: * Checks whether the given resource has another element to iterate over.
sl@0: *
sl@0: * @param resourceBundle a resource
sl@0: * @return TRUE if there are more elements, FALSE if there is no more elements
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE UBool U_EXPORT2
sl@0: ures_hasNext(const UResourceBundle *resourceBundle);
sl@0:
sl@0: /**
sl@0: * Returns the next resource in a given resource or NULL if there are no more resources
sl@0: * to iterate over. Features a fill-in parameter.
sl@0: *
sl@0: * @param resourceBundle a resource
sl@0: * @param fillIn if NULL a new UResourceBundle struct is allocated and must be deleted by the caller.
sl@0: * Alternatively, you can supply a struct to be filled by this function.
sl@0: * @param status fills in the outgoing error code. You may still get a non NULL result even if an
sl@0: * error occured. Check status instead.
sl@0: * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE UResourceBundle* U_EXPORT2
sl@0: ures_getNextResource(UResourceBundle *resourceBundle,
sl@0: UResourceBundle *fillIn,
sl@0: UErrorCode *status);
sl@0:
sl@0: /**
sl@0: * Returns the next string in a given resource or NULL if there are no more resources
sl@0: * to iterate over.
sl@0: *
sl@0: * @param resourceBundle a resource
sl@0: * @param len fill in length of the string
sl@0: * @param key fill in for key associated with this string. NULL if no key
sl@0: * @param status fills in the outgoing error code. If an error occured, we may return NULL, but don't
sl@0: * count on it. Check status instead!
sl@0: * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE const UChar* U_EXPORT2
sl@0: ures_getNextString(UResourceBundle *resourceBundle,
sl@0: int32_t* len,
sl@0: const char ** key,
sl@0: UErrorCode *status);
sl@0:
sl@0: /**
sl@0: * Returns the resource in a given resource at the specified index. Features a fill-in parameter.
sl@0: *
sl@0: * @param resourceBundle the resource bundle from which to get a sub-resource
sl@0: * @param indexR an index to the wanted resource.
sl@0: * @param fillIn if NULL a new UResourceBundle struct is allocated and must be deleted by the caller.
sl@0: * Alternatively, you can supply a struct to be filled by this function.
sl@0: * @param status fills in the outgoing error code. Don't count on NULL being returned if an error has
sl@0: * occured. Check status instead.
sl@0: * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE UResourceBundle* U_EXPORT2
sl@0: ures_getByIndex(const UResourceBundle *resourceBundle,
sl@0: int32_t indexR,
sl@0: UResourceBundle *fillIn,
sl@0: UErrorCode *status);
sl@0:
sl@0: /**
sl@0: * Returns the string in a given resource at the specified index.
sl@0: *
sl@0: * @param resourceBundle a resource
sl@0: * @param indexS an index to the wanted string.
sl@0: * @param len fill in length of the string
sl@0: * @param status fills in the outgoing error code. If an error occured, we may return NULL, but don't
sl@0: * count on it. Check status instead!
sl@0: * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE const UChar* U_EXPORT2
sl@0: ures_getStringByIndex(const UResourceBundle *resourceBundle,
sl@0: int32_t indexS,
sl@0: int32_t* len,
sl@0: UErrorCode *status);
sl@0:
sl@0: /**
sl@0: * Returns a resource in a given resource that has a given key. This procedure works only with table
sl@0: * resources. Features a fill-in parameter.
sl@0: *
sl@0: * @param resourceBundle a resource
sl@0: * @param key a key associated with the wanted resource
sl@0: * @param fillIn if NULL a new UResourceBundle struct is allocated and must be deleted by the caller.
sl@0: * Alternatively, you can supply a struct to be filled by this function.
sl@0: * @param status fills in the outgoing error code.
sl@0: * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE UResourceBundle* U_EXPORT2
sl@0: ures_getByKey(const UResourceBundle *resourceBundle,
sl@0: const char* key,
sl@0: UResourceBundle *fillIn,
sl@0: UErrorCode *status);
sl@0:
sl@0: /**
sl@0: * Returns a string in a given resource that has a given key. This procedure works only with table
sl@0: * resources.
sl@0: *
sl@0: * @param resB a resource
sl@0: * @param key a key associated with the wanted string
sl@0: * @param len fill in length of the string
sl@0: * @param status fills in the outgoing error code. If an error occured, we may return NULL, but don't
sl@0: * count on it. Check status instead!
sl@0: * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: U_STABLE const UChar* U_EXPORT2
sl@0: ures_getStringByKey(const UResourceBundle *resB,
sl@0: const char* key,
sl@0: int32_t* len,
sl@0: UErrorCode *status);
sl@0:
sl@0: #ifdef XP_CPLUSPLUS
sl@0: #include "unicode/unistr.h"
sl@0:
sl@0: U_NAMESPACE_BEGIN
sl@0: /**
sl@0: * returns a string from a string resource type
sl@0: *
sl@0: * @param resB a resource
sl@0: * @param status: fills in the outgoing error code
sl@0: * could be U_MISSING_RESOURCE_ERROR if the key is not found
sl@0: * could be a non-failing error
sl@0: * e.g.: U_USING_FALLBACK_WARNING,U_USING_DEFAULT_WARNING
sl@0: * @return an UnicodeString object. If there is an error, string is bogus
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: inline UnicodeString
sl@0: ures_getUnicodeString(const UResourceBundle *resB,
sl@0: UErrorCode* status)
sl@0: {
sl@0: int32_t len = 0;
sl@0: const UChar *r = ures_getString(resB, &len, status);
sl@0: return UnicodeString(TRUE, r, len);
sl@0: }
sl@0:
sl@0: /**
sl@0: * Returns the next string in a resource or NULL if there are no more resources
sl@0: * to iterate over.
sl@0: *
sl@0: * @param resB a resource
sl@0: * @param key fill in for key associated with this string
sl@0: * @param status fills in the outgoing error code
sl@0: * @return an UnicodeString object.
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: inline UnicodeString
sl@0: ures_getNextUnicodeString(UResourceBundle *resB,
sl@0: const char ** key,
sl@0: UErrorCode* status)
sl@0: {
sl@0: int32_t len = 0;
sl@0: const UChar* r = ures_getNextString(resB, &len, key, status);
sl@0: return UnicodeString(TRUE, r, len);
sl@0: }
sl@0:
sl@0: /**
sl@0: * Returns the string in a given resource at the specified index.
sl@0: *
sl@0: * @param resB a resource
sl@0: * @param index an index to the wanted string.
sl@0: * @param status fills in the outgoing error code
sl@0: * @return an UnicodeString object. If there is an error, string is bogus
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: inline UnicodeString
sl@0: ures_getUnicodeStringByIndex(const UResourceBundle *resB,
sl@0: int32_t indexS,
sl@0: UErrorCode* status)
sl@0: {
sl@0: int32_t len = 0;
sl@0: const UChar* r = ures_getStringByIndex(resB, indexS, &len, status);
sl@0: return UnicodeString(TRUE, r, len);
sl@0: }
sl@0:
sl@0: /**
sl@0: * Returns a string in a resource that has a given key. This procedure works only with table
sl@0: * resources.
sl@0: *
sl@0: * @param resB a resource
sl@0: * @param key a key associated with the wanted string
sl@0: * @param status fills in the outgoing error code
sl@0: * @return an UnicodeString object. If there is an error, string is bogus
sl@0: * @stable ICU 2.0
sl@0: */
sl@0: inline UnicodeString
sl@0: ures_getUnicodeStringByKey(const UResourceBundle *resB,
sl@0: const char* key,
sl@0: UErrorCode* status)
sl@0: {
sl@0: int32_t len = 0;
sl@0: const UChar* r = ures_getStringByKey(resB, key, &len, status);
sl@0: return UnicodeString(TRUE, r, len);
sl@0: }
sl@0:
sl@0: U_NAMESPACE_END
sl@0:
sl@0: #endif
sl@0:
sl@0:
sl@0: /**
sl@0: * Get a resource with multi-level fallback. Normally only the top level resources will
sl@0: * fallback to its parent. This performs fallback on subresources. For example, when a table
sl@0: * is defined in a resource bundle and a parent resource bundle, normally no fallback occurs
sl@0: * on the sub-resources because the table is defined in the current resource bundle, but this
sl@0: * function can perform fallback on the sub-resources of the table.
sl@0: * @param resB a resource
sl@0: * @param inKey a key associated with the requested resource
sl@0: * @param fillIn if NULL a new UResourceBundle struct is allocated and must be deleted by the caller.
sl@0: * Alternatively, you can supply a struct to be filled by this function.
sl@0: * @param status: fills in the outgoing error code
sl@0: * could be U_MISSING_RESOURCE_ERROR if the key is not found
sl@0: * could be a non-failing error
sl@0: * e.g.: U_USING_FALLBACK_WARNING,U_USING_DEFAULT_WARNING
sl@0: * @return a pointer to a UResourceBundle struct. If fill in param was NULL, caller must delete it
sl@0: * @internal ICU 3.0
sl@0: */
sl@0: U_INTERNAL UResourceBundle* U_EXPORT2
sl@0: ures_getByKeyWithFallback(const UResourceBundle *resB,
sl@0: const char* inKey,
sl@0: UResourceBundle *fillIn,
sl@0: UErrorCode *status);
sl@0:
sl@0:
sl@0: /**
sl@0: * Create a string enumerator, owned by the caller, of all locales located within
sl@0: * the specified resource tree.
sl@0: * @param packageName name of the tree, such as (NULL) or U_ICUDATA_ALIAS or or "ICUDATA-coll"
sl@0: * This call is similar to uloc_getAvailable().
sl@0: * @param status error code
sl@0: * @draft ICU 3.2
sl@0: */
sl@0: U_DRAFT UEnumeration* U_EXPORT2
sl@0: ures_openAvailableLocales(const char *packageName, UErrorCode *status);
sl@0:
sl@0:
sl@0: #endif /*_URES*/
sl@0: /*eof*/