Loading...
Searching...
No Matches
resbund.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
******************************************************************************
*
* Copyright (C) 1996-2013, International Business Machines Corporation
* and others. All Rights Reserved.
*
******************************************************************************
*
* File resbund.h
*
* CREATED BY
* Richard Gillam
*
* Modification History:
*
* Date Name Description
* 2/5/97 aliu Added scanForLocaleInFile. Added
* constructor which attempts to read resource bundle
* from a specific file, without searching other files.
* 2/11/97 aliu Added UErrorCode return values to constructors. Fixed
* infinite loops in scanForFile and scanForLocale.
* Modified getRawResourceData to not delete storage
* in localeData and resourceData which it doesn't own.
* Added Mac compatibility #ifdefs for tellp() and
* ios::nocreate.
* 2/18/97 helena Updated with 100% documentation coverage.
* 3/13/97 aliu Rewrote to load in entire resource bundle and store
* it as a Hashtable of ResourceBundleData objects.
* Added state table to govern parsing of files.
* Modified to load locale index out of new file
* distinct from default.txt.
* 3/25/97 aliu Modified to support 2-d arrays, needed for timezone
* data. Added support for custom file suffixes. Again,
* needed to support timezone data.
* 4/7/97 aliu Cleaned up.
* 03/02/99 stephen Removed dependency on FILE*.
* 03/29/99 helena Merged Bertrand and Stephen's changes.
* 06/11/99 stephen Removed parsing of .txt files.
* Reworked to use new binary format.
* Cleaned up.
* 06/14/99 stephen Removed methods taking a filename suffix.
* 11/09/99 weiv Added getLocale(), fRealLocale, removed fRealLocaleID
******************************************************************************
*/
#ifndef RESBUND_H
#define RESBUND_H
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#include "unicode/uobject.h"
#include "unicode/ures.h"
#include "unicode/unistr.h"
#include "unicode/locid.h"
U_NAMESPACE_BEGIN
class U_COMMON_API ResourceBundle : public UObject {
public:
ResourceBundle(const UnicodeString& packageName,
const Locale& locale,
UErrorCode& err);
ResourceBundle(const UnicodeString& packageName,
UErrorCode& err);
ResourceBundle(UErrorCode &err);
ResourceBundle(const char* packageName,
const Locale& locale,
UErrorCode& err);
ResourceBundle(const ResourceBundle &original);
ResourceBundle(UResourceBundle *res,
UErrorCode &status);
ResourceBundle&
operator=(const ResourceBundle& other);
virtual ~ResourceBundle();
ResourceBundle *clone() const;
int32_t getSize() const;
UnicodeString
getString(UErrorCode& status) const;
const uint8_t*
getBinary(int32_t& len, UErrorCode& status) const;
const int32_t*
getIntVector(int32_t& len, UErrorCode& status) const;
uint32_t
getUInt(UErrorCode& status) const;
int32_t
getInt(UErrorCode& status) const;
UBool hasNext() const;
void resetIterator();
const char* getKey() const;
const char* getName() const;
UResType getType() const;
ResourceBundle
getNext(UErrorCode& status);
UnicodeString
getNextString(UErrorCode& status);
UnicodeString
getNextString(const char ** key,
UErrorCode& status);
ResourceBundle
get(int32_t index,
UErrorCode& status) const;
UnicodeString
getStringEx(int32_t index,
UErrorCode& status) const;
ResourceBundle
get(const char* key,
UErrorCode& status) const;
UnicodeString
getStringEx(const char* key,
UErrorCode& status) const;
#ifndef U_HIDE_DEPRECATED_API
const char* getVersionNumber() const;
#endif /* U_HIDE_DEPRECATED_API */
void
getVersion(UVersionInfo versionInfo) const;
#ifndef U_HIDE_DEPRECATED_API
const Locale& getLocale() const;
#endif /* U_HIDE_DEPRECATED_API */
Locale
getLocale(ULocDataLocaleType type, UErrorCode &status) const;
#ifndef U_HIDE_INTERNAL_API
ResourceBundle
getWithFallback(const char* key, UErrorCode& status);
#endif /* U_HIDE_INTERNAL_API */
virtual UClassID getDynamicClassID() const override;
static UClassID U_EXPORT2 getStaticClassID();
private:
ResourceBundle() = delete; // default constructor not implemented
UResourceBundle *fResource;
void constructForLocale(const UnicodeString& path, const Locale& locale, UErrorCode& error);
Locale *fLocale;
};
U_NAMESPACE_END
#endif /* U_SHOW_CPLUSPLUS_API */
#endif
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:198
icu::ResourceBundle::ResourceBundle
ResourceBundle(UResourceBundle *res, UErrorCode &status)
Constructor from a C UResourceBundle.
icu::ResourceBundle::ResourceBundle
ResourceBundle(const ResourceBundle &original)
Copy constructor.
icu::ResourceBundle::clone
ResourceBundle * clone() const
Clone this object.
icu::ResourceBundle::ResourceBundle
ResourceBundle(const char *packageName, const Locale &locale, UErrorCode &err)
Standard constructor, constructs a resource bundle for the locale-specific bundle in the specified pa...
icu::ResourceBundle::get
ResourceBundle get(int32_t index, UErrorCode &status) const
Returns the resource in a resource at the specified index.
icu::ResourceBundle::getSize
int32_t getSize() const
Returns the size of a resource.
icu::ResourceBundle::getType
UResType getType() const
Returns the type of a resource.
icu::ResourceBundle::getName
const char * getName() const
Gets the locale ID of the resource bundle as a string.
icu::ResourceBundle::ResourceBundle
ResourceBundle(const UnicodeString &packageName, UErrorCode &err)
Construct a resource bundle for the default bundle in the specified package.
icu::ResourceBundle::getInt
int32_t getInt(UErrorCode &status) const
returns a signed integer from a resource.
icu::ResourceBundle::getIntVector
const int32_t * getIntVector(int32_t &len, UErrorCode &status) const
returns an integer vector from a resource.
icu::ResourceBundle::get
ResourceBundle get(const char *key, UErrorCode &status) const
Returns a resource in a resource that has a given key.
icu::ResourceBundle::operator=
ResourceBundle & operator=(const ResourceBundle &other)
Assignment operator.
icu::ResourceBundle::getLocale
const Locale & getLocale() const
Return the Locale associated with this ResourceBundle.
icu::ResourceBundle::getVersion
void getVersion(UVersionInfo versionInfo) const
Return the version number associated with this ResourceBundle as a UVersionInfo array.
icu::ResourceBundle::getNext
ResourceBundle getNext(UErrorCode &status)
Returns the next resource in a given resource or nullptr if there are no more resources.
icu::ResourceBundle::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::ResourceBundle::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::ResourceBundle::getLocale
Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const
Return the Locale associated with this ResourceBundle.
icu::ResourceBundle::ResourceBundle
ResourceBundle(UErrorCode &err)
Construct a resource bundle for the ICU default bundle.
icu::ResourceBundle::getKey
const char * getKey() const
Returns the key associated with this resource.
icu::ResourceBundle::getStringEx
UnicodeString getStringEx(int32_t index, UErrorCode &status) const
Returns the string in a given resource at the specified index.
icu::ResourceBundle::hasNext
UBool hasNext() const
Checks whether the resource has another element to iterate over.
icu::ResourceBundle::getWithFallback
ResourceBundle getWithFallback(const char *key, UErrorCode &status)
This API implements multilevel fallback.
icu::ResourceBundle::getNextString
UnicodeString getNextString(UErrorCode &status)
Returns the next string in a resource or nullptr if there are no more resources to iterate over.
icu::ResourceBundle::resetIterator
void resetIterator()
Resets the internal context of a resource so that iteration starts from the first element.
icu::ResourceBundle::getBinary
const uint8_t * getBinary(int32_t &len, UErrorCode &status) const
returns a binary data from a resource.
icu::ResourceBundle::getUInt
uint32_t getUInt(UErrorCode &status) const
returns an unsigned integer from a resource.
icu::ResourceBundle::getVersionNumber
const char * getVersionNumber() const
Return the version number associated with this ResourceBundle as a string.
icu::ResourceBundle::~ResourceBundle
virtual ~ResourceBundle()
Destructor.
icu::ResourceBundle::getNextString
UnicodeString getNextString(const char **key, UErrorCode &status)
Returns the next string in a resource or nullptr if there are no more resources to iterate over.
icu::ResourceBundle::ResourceBundle
ResourceBundle(const UnicodeString &packageName, const Locale &locale, UErrorCode &err)
Constructor.
icu::ResourceBundle::getString
UnicodeString getString(UErrorCode &status) const
returns a string from a string resource type
icu::ResourceBundle::getStringEx
UnicodeString getStringEx(const char *key, UErrorCode &status) const
Returns a string in a resource that has a given key.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition uobject.h:222
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
locid.h
C++ API: Locale ID object.
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition uloc.h:338
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
unistr.h
C++ API: Unicode String.
uobject.h
C++ API: Common ICU base class UObject.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
ures.h
C API: Resource Bundle.
UResType
UResType
Numeric constants for types of resource items.
Definition ures.h:70
UResourceBundle
struct UResourceBundle UResourceBundle
Definition ures.h:63
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509
U_COMMON_API
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition utypes.h:315
UVersionInfo
uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]
The binary form of a version on ICU APIs is an array of 4 uint8_t.
Definition uversion.h:59