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

resbund.h

Go to the documentation of this file.
00001 /*
00002 ******************************************************************************
00003 *
00004 *   Copyright (C) 1996-2001, 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
00023 *                           in 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
00031 *                           distinct from default.txt.
00032 *   3/25/97     aliu        Modified to support 2-d arrays, needed for timezone
00033 *                           data. Added support for custom file suffixes.  Again,
00034 *                           needed to 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 
00063 #ifdef ICU_RESBUND_USE_DEPRECATES
00064 struct UHashtable;
00065 #endif
00066 
00167 class U_COMMON_API ResourceBundle {
00168 public:
00196     ResourceBundle( const UnicodeString&    path,
00197                     const Locale&           locale,
00198                     UErrorCode&              err);
00199     ResourceBundle( const UnicodeString&    path,
00200                     UErrorCode&              err);
00201     ResourceBundle(UErrorCode &err);
00202     ResourceBundle( const wchar_t* path,
00203                     const Locale& locale,
00204                     UErrorCode& err);
00205     ResourceBundle( const char* path,
00206                     const Locale& locale,
00207                     UErrorCode& err);
00208     ResourceBundle(const ResourceBundle &original);
00209     ResourceBundle(UResourceBundle *res, UErrorCode &status);
00210 
00211     ResourceBundle& operator=(const ResourceBundle& other);
00212     ~ResourceBundle();
00213 
00221     int32_t getSize(void) const;
00222 
00233     UnicodeString getString(UErrorCode& status) const;
00234 
00248     const uint8_t *getBinary(int32_t& len, UErrorCode& status) const;
00249 
00256     UBool hasNext(void) const;
00257 
00263     void resetIterator(void);
00264 
00272     const char *getKey(void);
00273 
00274     const char *getName(void);
00275 
00276 
00283     UResType getType(void);
00284 
00292     ResourceBundle getNext(UErrorCode& status);
00293 
00302     UnicodeString getNextString(UErrorCode& status);
00303 
00313     UnicodeString getNextString(const char ** key, UErrorCode& status);
00314 
00323     ResourceBundle get(int32_t index, UErrorCode& status) const;
00324 
00333     UnicodeString getStringEx(int32_t index, UErrorCode& status) const;
00334 
00344     ResourceBundle get(const char* key, UErrorCode& status) const;
00345 
00355     UnicodeString getStringEx(const char* key, UErrorCode& status) const;
00356 
00357 #ifdef ICU_RESBUND_USE_DEPRECATES
00358 
00370     const UnicodeString*    getString(  const char                *resourceTag,
00371                                         UErrorCode&                err) const;
00372 
00392     const UnicodeString*    getStringArray( const char             *resourceTag,
00393                                             int32_t&                numArrayItems,
00394                                             UErrorCode&              err) const;
00395 
00396 
00412     const UnicodeString*    getArrayItem(   const char                *resourceTag,
00413                                             int32_t                    index,
00414                                             UErrorCode&                err) const;
00415 
00435     const UnicodeString**   get2dArray(const char          *resourceTag,
00436                                        int32_t&             rowCount,
00437                                        int32_t&             columnCount,
00438                                        UErrorCode&           err) const;
00439 
00440 
00459     const UnicodeString*    get2dArrayItem( const char                *resourceTag,
00460                                             int32_t                    rowIndex,
00461                                             int32_t                    columnIndex,
00462                                             UErrorCode&                err) const;
00463 
00464 
00481     const UnicodeString*    getTaggedArrayItem( const char             *resourceTag,
00482                                                 const UnicodeString&    itemTag,
00483                                                 UErrorCode&                err) const;
00484 
00508     void                getTaggedArray( const char             *resourceTag,
00509                                         UnicodeString*&         itemTags,
00510                                         UnicodeString*&         items,
00511                                         int32_t&                numItems,
00512                                         UErrorCode&              err) const;
00513 #endif
00514     
00534     const char*         getVersionNumber(void) const;
00535 
00536     void getVersion(UVersionInfo versionInfo) const;
00537 
00544     const Locale &getLocale(void) const ;
00545 
00546 private:
00547     UResourceBundle *resource;
00548     void constructForLocale(const UnicodeString& path, const Locale& locale, UErrorCode& error);
00549     void constructForLocale(const wchar_t* path, const Locale& locale, UErrorCode& error);
00550 #ifdef ICU_RESBUND_USE_DEPRECATES
00551     void initItemCache(UErrorCode& error);
00552 #endif
00553 
00554     friend class RuleBasedCollator;
00555 
00561     ResourceBundle( const UnicodeString&    path,
00562                     const char *localeName,
00563                     UErrorCode&              status);
00564 
00565 private:
00566     static void U_CALLCONV deleteValue(void* value);
00567     Locale                      fRealLocale;
00568 
00569 #ifdef ICU_RESBUND_USE_DEPRECATES
00570     UHashtable*                 fItemCache;
00571 #endif
00572 
00573     static const char*          kDefaultSuffix;
00574     static const int32_t        kDefaultSuffixLen;
00575     static const char*          kDefaultFilename;
00576     static const char*          kDefaultLocaleName;
00577 };
00578 
00579 #endif

Generated at Tue Jun 12 14:03:58 2001 for ICU 1.8.1 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000