/* ******************************************************************************* * * Copyright (C) 1996-1999, 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/ures.h" #include "unicode/utypes.h" #include "unicode/unistr.h" #include "unicode/locid.h" #include <wchar.h> #ifndef _FILESTRM typedef struct _FileStream FileStream; #endif /* forward declarations */ class Locale; class RuleBasedCollator; class ResourceBundle; struct UHashtable; class U_COMMON_API ResourceBundle { public: ResourceBundle( const UnicodeString& path, const Locale& locale, UErrorCode& err); ResourceBundle( const UnicodeString& path, UErrorCode& err); ResourceBundle( const wchar_t* path, const Locale& locale, UErrorCode& err); ResourceBundle(const ResourceBundle &original); ResourceBundle(UResourceBundle *res); ResourceBundle& operator=(const ResourceBundle& other); ~ResourceBundle(); int32_t getSize(void) const; UnicodeString getString(UErrorCode& status) const; const uint8_t *getBinary(int32_t& len, UErrorCode& status) const; UBool hasNext(void) const; void resetIterator(void); const char *getKey(void); const char *getName(void); UResType getType(void); 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; const UnicodeString* getString( const char *resourceTag, UErrorCode& err) const; const UnicodeString* getStringArray( const char *resourceTag, int32_t& numArrayItems, UErrorCode& err) const; const UnicodeString* getArrayItem( const char *resourceTag, int32_t index, UErrorCode& err) const; const UnicodeString** get2dArray(const char *resourceTag, int32_t& rowCount, int32_t& columnCount, UErrorCode& err) const; const UnicodeString* get2dArrayItem( const char *resourceTag, int32_t rowIndex, int32_t columnIndex, UErrorCode& err) const; const UnicodeString* getTaggedArrayItem( const char *resourceTag, const UnicodeString& itemTag, UErrorCode& err) const; void getTaggedArray( const char *resourceTag, UnicodeString*& itemTags, UnicodeString*& items, int32_t& numItems, UErrorCode& err) const; const char* getVersionNumber(void) const; const Locale &getLocale(void) const ; private: UResourceBundle *resource; void constructForLocale(const UnicodeString& path, const Locale& locale, UErrorCode& error); void constructForLocale(const wchar_t* path, const Locale& locale, UErrorCode& error); void initItemCache(UErrorCode& error); friend class RuleBasedCollator; ResourceBundle( const UnicodeString& path, const char *localeName, UErrorCode& status); private: static void U_CALLCONV deleteValue(void* value); Locale fRealLocale; UHashtable* fItemCache; static const char* kDefaultSuffix; static const int32_t kDefaultSuffixLen; static const char* kDefaultFilename; static const char* kDefaultLocaleName; }; #endif