Main Page   Class Hierarchy   Compound List   File List   Header Files   Sources   Compound Members   File Members  

resbund.h

00001 /*
00002 *******************************************************************************
00003 *
00004 *   Copyright (C) 1996-1999, International Business Machines
00005 *   Corporation and others.  All Rights Reserved.
00006 *
00007 *******************************************************************************
00008 *
00009 * File resbund.h
00010 *
00011 *   CREATED BY
00012 *       Richard Gillam
00013 *
00014 * Modification History:
00015 *
00016 *   Date        Name        Description
00017 *   2/5/97      aliu        Added scanForLocaleInFile.  Added
00018 *                           constructor which attempts to read resource bundle
00019 *                           from a specific file, without searching other files.
00020 *   2/11/97     aliu        Added UErrorCode return values to constructors.  Fixed
00021 *                           infinite loops in scanForFile and scanForLocale.
00022 *                           Modified getRawResourceData to not delete storage in
00023 *                           localeData and resourceData which it doesn't own.
00024 *                           Added Mac compatibility #ifdefs for tellp() and
00025 *                           ios::nocreate.
00026 *   2/18/97     helena      Updated with 100% documentation coverage.
00027 *   3/13/97     aliu        Rewrote to load in entire resource bundle and store
00028 *                           it as a Hashtable of ResourceBundleData objects.
00029 *                           Added state table to govern parsing of files.
00030 *                           Modified to load locale index out of new file distinct
00031 *                           from default.txt.
00032 *   3/25/97     aliu        Modified to support 2-d arrays, needed for timezone data.
00033 *                           Added support for custom file suffixes.  Again, needed to
00034 *                           support timezone data.
00035 *   4/7/97      aliu        Cleaned up.
00036 * 03/02/99      stephen     Removed dependency on FILE*.
00037 * 03/29/99      helena      Merged Bertrand and Stephen's changes.
00038 * 06/11/99      stephen     Removed parsing of .txt files.
00039 *                           Reworked to use new binary format.
00040 *                           Cleaned up.
00041 * 06/14/99      stephen     Removed methods taking a filename suffix.
00042 * 11/09/99              weiv            Added getLocale(), fRealLocale, removed fRealLocaleID
00043 *******************************************************************************
00044 */
00045 
00046 #ifndef RESBUND_H
00047 #define RESBUND_H
00048   
00049 #include "unicode/ures.h"
00050 #include "unicode/utypes.h"
00051 #include "unicode/unistr.h"
00052 #include "unicode/locid.h"
00053 
00054 #ifndef _FILESTRM
00055 typedef struct _FileStream FileStream;
00056 #endif
00057 
00058 /* forward declarations */
00059 class Locale;
00060 class RuleBasedCollator;
00061 class ResourceBundle;
00062 struct UHashtable;
00063 
00064 
00149 class U_COMMON_API ResourceBundle {
00150 public:
00178                         ResourceBundle( const UnicodeString&    path,
00179                                         const Locale&           locale,
00180                                         UErrorCode&              err);
00181                         ResourceBundle( const UnicodeString&    path,
00182                                         UErrorCode&              err);
00183                         ResourceBundle(UErrorCode &err);
00184                         ResourceBundle( const wchar_t* path,
00185                                         const Locale& locale,
00186                                         UErrorCode& err);
00187                         ResourceBundle( const char* path,
00188                                         const Locale& locale,
00189                                         UErrorCode& err);
00190                         ResourceBundle(const ResourceBundle &original);
00191                         ResourceBundle(UResourceBundle *res, UErrorCode &status);
00192 
00193                         ResourceBundle& operator=(const ResourceBundle& other);
00194                         ~ResourceBundle();
00195 
00203     int32_t getSize(void) const;
00214     UnicodeString getString(UErrorCode& status) const;
00215     const uint8_t *getBinary(int32_t& len, UErrorCode& status) const;
00216 
00223     UBool hasNext(void) const;
00229     void resetIterator(void);
00230 
00238     const char *getKey(void);
00239 
00240     const char *getName(void);
00241 
00242 
00249     UResType getType(void);
00250 
00258     ResourceBundle getNext(UErrorCode& status);
00259 
00268     UnicodeString getNextString(UErrorCode& status);
00278     UnicodeString getNextString(const char ** key, UErrorCode& status);
00279 
00288     ResourceBundle get(int32_t index, UErrorCode& status) const;
00289 
00298     UnicodeString getStringEx(int32_t index, UErrorCode& status) const;
00299 
00309     ResourceBundle get(const char* key, UErrorCode& status) const;
00310 
00320     UnicodeString getStringEx(const char* key, UErrorCode& status) const;
00321 
00334     const UnicodeString*    getString(  const char                *resourceTag,
00335                                         UErrorCode&                err) const;
00336 
00356     const UnicodeString*    getStringArray( const char             *resourceTag,
00357                                             int32_t&                numArrayItems,
00358                                             UErrorCode&              err) const;
00359 
00360 
00376     const UnicodeString*    getArrayItem(   const char                *resourceTag,
00377                                             int32_t                    index,
00378                                             UErrorCode&                err) const;
00379 
00399     const UnicodeString**   get2dArray(const char          *resourceTag,
00400                                        int32_t&             rowCount,
00401                                        int32_t&             columnCount,
00402                                        UErrorCode&           err) const;
00403 
00404 
00423     const UnicodeString*    get2dArrayItem( const char                *resourceTag,
00424                                             int32_t                    rowIndex,
00425                                             int32_t                    columnIndex,
00426                                             UErrorCode&                err) const;
00427 
00428 
00445     const UnicodeString*    getTaggedArrayItem( const char             *resourceTag,
00446                                                 const UnicodeString&    itemTag,
00447                                                 UErrorCode&                err) const;
00448 
00472     void                getTaggedArray( const char             *resourceTag,
00473                                         UnicodeString*&         itemTags,
00474                                         UnicodeString*&         items,
00475                                         int32_t&                numItems,
00476                                         UErrorCode&              err) const;
00477     
00497     const char*         getVersionNumber(void) const;
00498 
00499     void getVersion(UVersionInfo versionInfo) const;
00500 
00507         const Locale &getLocale(void) const ;
00508 
00509 private:
00510     UResourceBundle *resource;
00511     void constructForLocale(const UnicodeString& path, const Locale& locale, UErrorCode& error);
00512     void constructForLocale(const wchar_t* path, const Locale& locale, UErrorCode& error);
00513     void initItemCache(UErrorCode& error);
00514 
00515     friend class RuleBasedCollator;
00516 
00522                             ResourceBundle( const UnicodeString&    path,
00523                                             const char *localeName,
00524                                             UErrorCode&              status);
00525 
00526 private:
00527     static void U_CALLCONV deleteValue(void* value);
00528         Locale                                  fRealLocale;
00529 
00530     UHashtable*          fItemCache;
00531     static const char*          kDefaultSuffix;
00532     static const int32_t        kDefaultSuffixLen;
00533     static const char*          kDefaultFilename;
00534     static const char*          kDefaultLocaleName;
00535 };
00536 
00537 #endif

Generated at Wed Aug 16 16:05:35 2000 for ICU1.6 by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999