ICU 72.1 72.1
|
A class representing a collection of resource information pertaining to a given locale. More...
#include <resbund.h>
Public Member Functions | |
ResourceBundle (const UnicodeString &packageName, const Locale &locale, UErrorCode &err) | |
Constructor. More... | |
ResourceBundle (const UnicodeString &packageName, UErrorCode &err) | |
Construct a resource bundle for the default bundle in the specified package. More... | |
ResourceBundle (UErrorCode &err) | |
Construct a resource bundle for the ICU default bundle. More... | |
ResourceBundle (const char *packageName, const Locale &locale, UErrorCode &err) | |
Standard constructor, constructs a resource bundle for the locale-specific bundle in the specified package. More... | |
ResourceBundle (const ResourceBundle &original) | |
Copy constructor. More... | |
ResourceBundle (UResourceBundle *res, UErrorCode &status) | |
Constructor from a C UResourceBundle. More... | |
ResourceBundle & | operator= (const ResourceBundle &other) |
Assignment operator. More... | |
virtual | ~ResourceBundle () |
Destructor. More... | |
ResourceBundle * | clone () const |
Clone this object. More... | |
int32_t | getSize (void) const |
Returns the size of a resource. More... | |
UnicodeString | getString (UErrorCode &status) const |
returns a string from a string resource type More... | |
const uint8_t * | getBinary (int32_t &len, UErrorCode &status) const |
returns a binary data from a resource. More... | |
const int32_t * | getIntVector (int32_t &len, UErrorCode &status) const |
returns an integer vector from a resource. More... | |
uint32_t | getUInt (UErrorCode &status) const |
returns an unsigned integer from a resource. More... | |
int32_t | getInt (UErrorCode &status) const |
returns a signed integer from a resource. More... | |
UBool | hasNext (void) const |
Checks whether the resource has another element to iterate over. More... | |
void | resetIterator (void) |
Resets the internal context of a resource so that iteration starts from the first element. More... | |
const char * | getKey (void) const |
Returns the key associated with this resource. More... | |
const char * | getName (void) const |
Gets the locale ID of the resource bundle as a string. More... | |
UResType | getType (void) const |
Returns the type of a resource. More... | |
ResourceBundle | getNext (UErrorCode &status) |
Returns the next resource in a given resource or NULL if there are no more resources. More... | |
UnicodeString | getNextString (UErrorCode &status) |
Returns the next string in a resource or NULL if there are no more resources to iterate over. More... | |
UnicodeString | getNextString (const char **key, UErrorCode &status) |
Returns the next string in a resource or NULL if there are no more resources to iterate over. More... | |
ResourceBundle | get (int32_t index, UErrorCode &status) const |
Returns the resource in a resource at the specified index. More... | |
UnicodeString | getStringEx (int32_t index, UErrorCode &status) const |
Returns the string in a given resource at the specified index. More... | |
ResourceBundle | get (const char *key, UErrorCode &status) const |
Returns a resource in a resource that has a given key. More... | |
UnicodeString | getStringEx (const char *key, UErrorCode &status) const |
Returns a string in a resource that has a given key. More... | |
const char * | getVersionNumber (void) const |
Return the version number associated with this ResourceBundle as a string. More... | |
void | getVersion (UVersionInfo versionInfo) const |
Return the version number associated with this ResourceBundle as a UVersionInfo array. More... | |
const Locale & | getLocale (void) const |
Return the Locale associated with this ResourceBundle. More... | |
const Locale | getLocale (ULocDataLocaleType type, UErrorCode &status) const |
Return the Locale associated with this ResourceBundle. More... | |
ResourceBundle | getWithFallback (const char *key, UErrorCode &status) |
This API implements multilevel fallback. More... | |
virtual UClassID | getDynamicClassID () const override |
ICU "poor man's RTTI", returns a UClassID for the actual class. More... | |
Public Member Functions inherited from icu::UObject | |
virtual | ~UObject () |
Destructor. More... | |
virtual UClassID | getDynamicClassID () const |
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class. More... | |
Static Public Member Functions | |
static UClassID | getStaticClassID () |
ICU "poor man's RTTI", returns a UClassID for this class. More... | |
A class representing a collection of resource information pertaining to a given locale.
A resource bundle provides a way of accessing locale- specific information in a data file. You create a resource bundle that manages the resources for a given locale and then ask it for individual resources.
Resource bundles in ICU4C are currently defined using text files which conform to the following BNF definition. More on resource bundle concepts and syntax can be found in the Users Guide.
The ResourceBundle class is not suitable for subclassing.
icu::ResourceBundle::ResourceBundle | ( | const UnicodeString & | packageName, |
const Locale & | locale, | ||
UErrorCode & | err | ||
) |
Constructor.
packageName | The packageName and locale together point to an ICU udata object, as defined by udata_open( packageName, "res", locale, err) or equivalent. Typically, packageName will refer to a (.dat) file, or to a package registered with udata_setAppData(). Using a full file or directory pathname for packageName is deprecated. |
locale | This is the locale this resource bundle is for. To get resources for the French locale, for example, you would create a ResourceBundle passing Locale::FRENCH for the "locale" parameter, and all subsequent calls to that resource bundle will return resources that pertain to the French locale. If the caller doesn't pass a locale parameter, the default locale for the system (as returned by Locale::getDefault()) will be used. |
err | The Error Code. The UErrorCode& err parameter is used to return status information to the user. To check whether the construction succeeded or not, you should check the value of U_SUCCESS(err). If you wish more detailed information, you can check for informational error results which still indicate success. U_USING_FALLBACK_WARNING indicates that a fall back locale was used. For example, 'de_CH' was requested, but nothing was found there, so 'de' was used. U_USING_DEFAULT_WARNING indicates that the default locale data was used; neither the requested locale nor any of its fall back locales could be found. |
icu::ResourceBundle::ResourceBundle | ( | const UnicodeString & | packageName, |
UErrorCode & | err | ||
) |
Construct a resource bundle for the default bundle in the specified package.
packageName | The packageName and locale together point to an ICU udata object, as defined by udata_open( packageName, "res", locale, err) or equivalent. Typically, packageName will refer to a (.dat) file, or to a package registered with udata_setAppData(). Using a full file or directory pathname for packageName is deprecated. |
err | A UErrorCode value |
icu::ResourceBundle::ResourceBundle | ( | UErrorCode & | err | ) |
Construct a resource bundle for the ICU default bundle.
err | A UErrorCode value |
icu::ResourceBundle::ResourceBundle | ( | const char * | packageName, |
const Locale & | locale, | ||
UErrorCode & | err | ||
) |
Standard constructor, constructs a resource bundle for the locale-specific bundle in the specified package.
packageName | The packageName and locale together point to an ICU udata object, as defined by udata_open( packageName, "res", locale, err) or equivalent. Typically, packageName will refer to a (.dat) file, or to a package registered with udata_setAppData(). Using a full file or directory pathname for packageName is deprecated. NULL is used to refer to ICU data. |
locale | The locale for which to open a resource bundle. |
err | A UErrorCode value |
icu::ResourceBundle::ResourceBundle | ( | const ResourceBundle & | original | ) |
icu::ResourceBundle::ResourceBundle | ( | UResourceBundle * | res, |
UErrorCode & | status | ||
) |
Constructor from a C UResourceBundle.
The resource bundle is copied and not adopted. ures_close will still need to be used on the original resource bundle.
res | A pointer to the C resource bundle. |
status | A UErrorCode value. |
|
virtual |
Destructor.
ResourceBundle * icu::ResourceBundle::clone | ( | ) | const |
Clone this object.
Clones can be used concurrently in multiple threads. If an error occurs, then NULL is returned. The caller must delete the clone.
ResourceBundle icu::ResourceBundle::get | ( | const char * | key, |
UErrorCode & | status | ||
) | const |
Returns a resource in a resource that has a given key.
This procedure works only with table resources.
key | a key associated with the wanted resource |
status | fills in the outgoing error code. |
ResourceBundle icu::ResourceBundle::get | ( | int32_t | index, |
UErrorCode & | status | ||
) | const |
Returns the resource in a resource at the specified index.
index | an index to the wanted resource. |
status | fills in the outgoing error code |
const uint8_t * icu::ResourceBundle::getBinary | ( | int32_t & | len, |
UErrorCode & | status | ||
) | const |
returns a binary data from a resource.
Can be used at most primitive resource types (binaries, strings, ints)
len | fills in the length of resulting byte chunk |
status | fills in the outgoing error code could be U_MISSING_RESOURCE_ERROR if the key is not found could be a warning e.g.: U_USING_FALLBACK_WARNING ,U_USING_DEFAULT_WARNING |
|
overridevirtual |
ICU "poor man's RTTI", returns a UClassID for the actual class.
Reimplemented from icu::UObject.
int32_t icu::ResourceBundle::getInt | ( | UErrorCode & | status | ) | const |
returns a signed integer from a resource.
This integer is originally 28 bit and the sign gets propagated.
status | fills in the outgoing error code could be U_MISSING_RESOURCE_ERROR if the key is not found could be a warning e.g.: U_USING_FALLBACK_WARNING ,U_USING_DEFAULT_WARNING |
const int32_t * icu::ResourceBundle::getIntVector | ( | int32_t & | len, |
UErrorCode & | status | ||
) | const |
returns an integer vector from a resource.
len | fills in the length of resulting integer vector |
status | fills in the outgoing error code could be U_MISSING_RESOURCE_ERROR if the key is not found could be a warning e.g.: U_USING_FALLBACK_WARNING ,U_USING_DEFAULT_WARNING |
const char * icu::ResourceBundle::getKey | ( | void | ) | const |
Returns the key associated with this resource.
Not all the resources have a key - only those that are members of a table.
const Locale icu::ResourceBundle::getLocale | ( | ULocDataLocaleType | type, |
UErrorCode & | status | ||
) | const |
Return the Locale associated with this ResourceBundle.
type | You can choose between requested, valid and actual locale. For description see the definition of ULocDataLocaleType in uloc.h |
status | just for catching illegal arguments |
const Locale & icu::ResourceBundle::getLocale | ( | void | ) | const |
Return the Locale associated with this ResourceBundle.
const char * icu::ResourceBundle::getName | ( | void | ) | const |
Gets the locale ID of the resource bundle as a string.
Same as getLocale().getName() .
ResourceBundle icu::ResourceBundle::getNext | ( | UErrorCode & | status | ) |
Returns the next resource in a given resource or NULL if there are no more resources.
status | fills in the outgoing error code |
UnicodeString icu::ResourceBundle::getNextString | ( | const char ** | key, |
UErrorCode & | status | ||
) |
Returns the next string in a resource or NULL if there are no more resources to iterate over.
key | fill in for key associated with this string |
status | fills in the outgoing error code |
UnicodeString icu::ResourceBundle::getNextString | ( | UErrorCode & | status | ) |
Returns the next string in a resource or NULL if there are no more resources to iterate over.
status | fills in the outgoing error code |
int32_t icu::ResourceBundle::getSize | ( | void | ) | const |
Returns the size of a resource.
Size for scalar types is always 1, and for vector/table types is the number of child resources.
|
static |
ICU "poor man's RTTI", returns a UClassID for this class.
UnicodeString icu::ResourceBundle::getString | ( | UErrorCode & | status | ) | const |
returns a string from a string resource type
status | fills in the outgoing error code could be U_MISSING_RESOURCE_ERROR if the key is not found could be a warning e.g.: U_USING_FALLBACK_WARNING ,U_USING_DEFAULT_WARNING |
UnicodeString icu::ResourceBundle::getStringEx | ( | const char * | key, |
UErrorCode & | status | ||
) | const |
Returns a string in a resource that has a given key.
This procedure works only with table resources.
key | a key associated with the wanted string |
status | fills in the outgoing error code |
UnicodeString icu::ResourceBundle::getStringEx | ( | int32_t | index, |
UErrorCode & | status | ||
) | const |
Returns the string in a given resource at the specified index.
index | an index to the wanted string. |
status | fills in the outgoing error code |
UResType icu::ResourceBundle::getType | ( | void | ) | const |
Returns the type of a resource.
Available types are defined in enum UResType
uint32_t icu::ResourceBundle::getUInt | ( | UErrorCode & | status | ) | const |
returns an unsigned integer from a resource.
This integer is originally 28 bits.
status | fills in the outgoing error code could be U_MISSING_RESOURCE_ERROR if the key is not found could be a warning e.g.: U_USING_FALLBACK_WARNING ,U_USING_DEFAULT_WARNING |
void icu::ResourceBundle::getVersion | ( | UVersionInfo | versionInfo | ) | const |
Return the version number associated with this ResourceBundle as a UVersionInfo array.
versionInfo | A UVersionInfo array that is filled with the version number as specified in the resource bundle or its parent. |
const char * icu::ResourceBundle::getVersionNumber | ( | void | ) | const |
Return the version number associated with this ResourceBundle as a string.
Please use getVersion, as this method is going to be deprecated.
ResourceBundle icu::ResourceBundle::getWithFallback | ( | const char * | key, |
UErrorCode & | status | ||
) |
This API implements multilevel fallback.
UBool icu::ResourceBundle::hasNext | ( | void | ) | const |
Checks whether the resource has another element to iterate over.
ResourceBundle & icu::ResourceBundle::operator= | ( | const ResourceBundle & | other | ) |
void icu::ResourceBundle::resetIterator | ( | void | ) |
Resets the internal context of a resource so that iteration starts from the first element.