Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

ResourceBundle Class Reference

A class representing a collection of resource information pertaining to a given locale. More...

#include <resbund.h>

Inheritance diagram for ResourceBundle::

UObject UMemory List of all members.

Public Methods

 ResourceBundle (const UnicodeString &path, const Locale &locale, UErrorCode &err)
 Constructor. More...

 ResourceBundle (const UnicodeString &path, UErrorCode &err)
 Construct a resource bundle for the root bundle in the specified path. More...

 ResourceBundle (UErrorCode &err)
 Construct a resource bundle for the ICU root bundle. More...

 ResourceBundle (const char *path, const Locale &locale, UErrorCode &err)
 Standard constructor, onstructs a resource bundle for the locale-specific bundle in the specified path. 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...

 ~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)
 Returns the key associated with this resource. More...

const char * getName (void)
 Gets the locale ID of the resource bundle as a string. More...

UResType getType (void)
 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 LocalegetLocale (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...

virtual UClassID getDynamicClassID () const
 ICU "poor man's RTTI", returns a UClassID for the actual class. More...


Static Public Methods

UClassID getStaticClassID ()
 ICU "poor man's RTTI", returns a UClassID for this class. More...


Private Methods

 ResourceBundle ()
void constructForLocale (const UnicodeString &path, const Locale &locale, UErrorCode &error)

Private Attributes

UResourceBundleresource
LocalelocName

Detailed Description

A class representing a collection of resource information pertaining to a given locale.

A resource bundle provides a way of accessing locale- specfic 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.

Stable:
ICU 2.0

Definition at line 73 of file resbund.h.


Constructor & Destructor Documentation

ResourceBundle::ResourceBundle const UnicodeString   path,
const Locale   locale,
UErrorCode   err
 

Constructor.

Parameters:
path  This is a full pathname in the platform-specific format for the directory containing the resource data files we want to load resources from. We use locale IDs to generate filenames, and the filenames have this string prepended to them before being passed to the C++ I/O functions. Therefore, this string must always end with a directory delimiter (whatever that is for the target OS) for this class to work correctly.
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.
Stable:
ICU 2.0

ResourceBundle::ResourceBundle const UnicodeString   path,
UErrorCode   err
 

Construct a resource bundle for the root bundle in the specified path.

Parameters:
path  A path/basename for the data file(s) containing the bundle.
err  A UErrorCode value
Stable:
ICU 2.0

ResourceBundle::ResourceBundle UErrorCode   err
 

Construct a resource bundle for the ICU root bundle.

Parameters:
err  A UErrorCode value
Stable:
ICU 2.0

ResourceBundle::ResourceBundle const char *    path,
const Locale   locale,
UErrorCode   err
 

Standard constructor, onstructs a resource bundle for the locale-specific bundle in the specified path.

Parameters:
path  A path/basename for the data file(s) containing the bundle. NULL is used for ICU data.
locale  The locale for which to open a resource bundle.
err  A UErrorCode value
Stable:
ICU 2.0

ResourceBundle::ResourceBundle const ResourceBundle &    original
 

Copy constructor.

Parameters:
original  The resource bundle to copy.
Stable:
ICU 2.0

ResourceBundle::ResourceBundle UResourceBundle   res,
UErrorCode   status
 

Constructor from a C UResourceBundle.

Parameters:
res  A pointer to the C resource bundle.
status  A UErrorCode value.
Stable:
ICU 2.0

ResourceBundle::~ResourceBundle  
 

Destructor.

Stable:
ICU 2.0

ResourceBundle::ResourceBundle   [private]
 


Member Function Documentation

ResourceBundle* ResourceBundle::clone void    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.

Returns:
a clone of this object
See also:
getDynamicClassID
Draft:
This API has been introduced in ICU 2.8. It is still in draft state and may be modified in a future release.

void ResourceBundle::constructForLocale const UnicodeString   path,
const Locale   locale,
UErrorCode   error
[private]
 

ResourceBundle 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.

Parameters:
key  a key associated with the wanted resource
status  fills in the outgoing error code.
Returns:
ResourceBundle object. If there is an error, resource is invalid.
Stable:
ICU 2.0

ResourceBundle ResourceBundle::get int32_t    index,
UErrorCode   status
const
 

Returns the resource in a resource at the specified index.

Parameters:
index  an index to the wanted resource.
status  fills in the outgoing error code
Returns:
ResourceBundle object. If there is an error, resource is invalid.
Stable:
ICU 2.0

const uint8_t* 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)

Parameters:
len  fills in the length of resulting byte chunk
status  fills in the outgoing error code could be U_MISSING_RESOURCE_ERROR</T> if the key is not found could be a warning e.g.: U_USING_FALLBACK_WARNING,U_USING_DEFAULT_WARNING
Returns:
a pointer to a chunk of unsigned bytes which live in a memory mapped/DLL file.
Stable:
ICU 2.0

virtual UClassID ResourceBundle::getDynamicClassID void    const [virtual]
 

ICU "poor man's RTTI", returns a UClassID for the actual class.

Stable:
ICU 2.2

Reimplemented from UObject.

int32_t ResourceBundle::getInt UErrorCode   status const
 

returns a signed integer from a resource.

This integer is originally 28 bit and the sign gets propagated.

Parameters:
status  fills in the outgoing error code could be U_MISSING_RESOURCE_ERROR</T> if the key is not found could be a warning e.g.: U_USING_FALLBACK_WARNING,U_USING_DEFAULT_WARNING
Returns:
a signed integer value
Stable:
ICU 2.0

const int32_t* ResourceBundle::getIntVector int32_t &    len,
UErrorCode   status
const
 

returns an integer vector from a resource.

Parameters:
len  fills in the length of resulting integer vector
status  fills in the outgoing error code could be U_MISSING_RESOURCE_ERROR</T> if the key is not found could be a warning e.g.: U_USING_FALLBACK_WARNING,U_USING_DEFAULT_WARNING
Returns:
a pointer to a vector of integers that lives in a memory mapped/DLL file.
Stable:
ICU 2.0

const char* ResourceBundle::getKey void   
 

Returns the key associated with this resource.

Not all the resources have a key - only those that are members of a table.

Returns:
a key associated to this resource, or NULL if it doesn't have a key
Stable:
ICU 2.0

const Locale ResourceBundle::getLocale ULocDataLocaleType    type,
UErrorCode   status
const
 

Return the Locale associated with this ResourceBundle.

Parameters:
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
Returns:
a Locale object
Draft:
This API has been introduced in ICU 2.8. It is still in draft state and may be modified in a future release.

const Locale& ResourceBundle::getLocale void    const
 

Return the Locale associated with this ResourceBundle.

Returns:
a Locale object
Deprecated:
ICU 2.8 Use getLocale(ULocDataLocaleType type, UErrorCode &status) overload instead.

const char* ResourceBundle::getName void   
 

Gets the locale ID of the resource bundle as a string.

Same as getLocale().getName() .

Returns:
the locale ID of the resource bundle as a string
Stable:
ICU 2.0

ResourceBundle ResourceBundle::getNext UErrorCode   status
 

Returns the next resource in a given resource or NULL if there are no more resources.

Parameters:
status  fills in the outgoing error code
Returns:
ResourceBundle object.
Stable:
ICU 2.0

UnicodeString 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.

Parameters:
key  fill in for key associated with this string
status  fills in the outgoing error code
Returns:
an UnicodeString object.
Stable:
ICU 2.0

UnicodeString ResourceBundle::getNextString UErrorCode   status
 

Returns the next string in a resource or NULL if there are no more resources to iterate over.

Parameters:
status  fills in the outgoing error code
Returns:
an UnicodeString object.
Stable:
ICU 2.0

int32_t 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.

Warning:
Integer array is treated as a scalar type. There are no APIs to access individual members of an integer array. It is always returned as a whole.
Returns:
number of resources in a given resource.
Stable:
ICU 2.0

UClassID ResourceBundle::getStaticClassID void    [static]
 

ICU "poor man's RTTI", returns a UClassID for this class.

Stable:
ICU 2.2

UnicodeString ResourceBundle::getString UErrorCode   status const
 

returns a string from a string resource type.

Parameters:
status  fills in the outgoing error code could be U_MISSING_RESOURCE_ERROR</T> if the key is not found could be a warning e.g.: U_USING_FALLBACK_WARNING,U_USING_DEFAULT_WARNING
Returns:
a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.
Stable:
ICU 2.0

UnicodeString 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.

Parameters:
key  a key associated with the wanted string
status  fills in the outgoing error code
Returns:
an UnicodeString object. If there is an error, string is bogus
Stable:
ICU 2.0

UnicodeString ResourceBundle::getStringEx int32_t    index,
UErrorCode   status
const
 

Returns the string in a given resource at the specified index.

Parameters:
index  an index to the wanted string.
status  fills in the outgoing error code
Returns:
an UnicodeString object. If there is an error, string is bogus
Stable:
ICU 2.0

UResType ResourceBundle::getType void   
 

Returns the type of a resource.

Available types are defined in enum UResType

Returns:
type of the given resource.
Stable:
ICU 2.0

uint32_t ResourceBundle::getUInt UErrorCode   status const
 

returns an unsigned integer from a resource.

This integer is originally 28 bits.

Parameters:
status  fills in the outgoing error code could be U_MISSING_RESOURCE_ERROR</T> if the key is not found could be a warning e.g.: U_USING_FALLBACK_WARNING,U_USING_DEFAULT_WARNING
Returns:
an unsigned integer value
Stable:
ICU 2.0

void ResourceBundle::getVersion UVersionInfo    versionInfo const
 

Return the version number associated with this ResourceBundle as a UVersionInfo array.

Parameters:
versionInfo  A UVersionInfo array that is filled with the version number as specified in the resource bundle or its parent.
Stable:
ICU 2.0

const char* 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.

Returns:
A version number string as specified in the resource bundle or its parent. The caller does not own this string.
See also:
getVersion
Deprecated:
ICU 2.8 Use getVersion instead.

UBool ResourceBundle::hasNext void    const
 

Checks whether the resource has another element to iterate over.

Returns:
TRUE if there are more elements, FALSE if there is no more elements
Stable:
ICU 2.0

ResourceBundle& ResourceBundle::operator= const ResourceBundle &    other
 

Assignment operator.

Parameters:
other  The resource bundle to copy.
Stable:
ICU 2.0

void ResourceBundle::resetIterator void   
 

Resets the internal context of a resource so that iteration starts from the first element.

Stable:
ICU 2.0


Member Data Documentation

Locale* ResourceBundle::locName [private]
 

Definition at line 462 of file resbund.h.

UResourceBundle* ResourceBundle::resource [private]
 

Definition at line 460 of file resbund.h.


The documentation for this class was generated from the following file:
Generated on Mon Nov 24 14:36:46 2003 for ICU 2.8 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001