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-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 
00165 class U_COMMON_API ResourceBundle {
00166 public:
00194                         ResourceBundle( const UnicodeString&    path,
00195                                         const Locale&           locale,
00196                                         UErrorCode&              err);
00197                         ResourceBundle( const UnicodeString&    path,
00198                                         UErrorCode&              err);
00199                         ResourceBundle(UErrorCode &err);
00200                         ResourceBundle( const wchar_t* path,
00201                                         const Locale& locale,
00202                                         UErrorCode& err);
00203                         ResourceBundle( const char* path,
00204                                         const Locale& locale,
00205                                         UErrorCode& err);
00206                         ResourceBundle(const ResourceBundle &original);
00207                         ResourceBundle(UResourceBundle *res, UErrorCode &status);
00208 
00209                         ResourceBundle& operator=(const ResourceBundle& other);
00210                         ~ResourceBundle();
00211 
00219     int32_t getSize(void) const;
00230     UnicodeString getString(UErrorCode& status) const;
00231     const uint8_t *getBinary(int32_t& len, UErrorCode& status) const;
00232 
00239     UBool hasNext(void) const;
00245     void resetIterator(void);
00246 
00254     const char *getKey(void);
00255 
00256     const char *getName(void);
00257 
00258 
00265     UResType getType(void);
00266 
00274     ResourceBundle getNext(UErrorCode& status);
00275 
00284     UnicodeString getNextString(UErrorCode& status);
00294     UnicodeString getNextString(const char ** key, UErrorCode& status);
00295 
00304     ResourceBundle get(int32_t index, UErrorCode& status) const;
00305 
00314     UnicodeString getStringEx(int32_t index, UErrorCode& status) const;
00315 
00325     ResourceBundle get(const char* key, UErrorCode& status) const;
00326 
00336     UnicodeString getStringEx(const char* key, UErrorCode& status) const;
00337 
00350     const UnicodeString*    getString(  const char                *resourceTag,
00351                                         UErrorCode&                err) const;
00352 
00372     const UnicodeString*    getStringArray( const char             *resourceTag,
00373                                             int32_t&                numArrayItems,
00374                                             UErrorCode&              err) const;
00375 
00376 
00392     const UnicodeString*    getArrayItem(   const char                *resourceTag,
00393                                             int32_t                    index,
00394                                             UErrorCode&                err) const;
00395 
00415     const UnicodeString**   get2dArray(const char          *resourceTag,
00416                                        int32_t&             rowCount,
00417                                        int32_t&             columnCount,
00418                                        UErrorCode&           err) const;
00419 
00420 
00439     const UnicodeString*    get2dArrayItem( const char                *resourceTag,
00440                                             int32_t                    rowIndex,
00441                                             int32_t                    columnIndex,
00442                                             UErrorCode&                err) const;
00443 
00444 
00461     const UnicodeString*    getTaggedArrayItem( const char             *resourceTag,
00462                                                 const UnicodeString&    itemTag,
00463                                                 UErrorCode&                err) const;
00464 
00488     void                getTaggedArray( const char             *resourceTag,
00489                                         UnicodeString*&         itemTags,
00490                                         UnicodeString*&         items,
00491                                         int32_t&                numItems,
00492                                         UErrorCode&              err) const;
00493     
00513     const char*         getVersionNumber(void) const;
00514 
00515     void getVersion(UVersionInfo versionInfo) const;
00516 
00523     const Locale &getLocale(void) const ;
00524 
00525 private:
00526     UResourceBundle *resource;
00527     void constructForLocale(const UnicodeString& path, const Locale& locale, UErrorCode& error);
00528     void constructForLocale(const wchar_t* path, const Locale& locale, UErrorCode& error);
00529     void initItemCache(UErrorCode& error);
00530 
00531     friend class RuleBasedCollator;
00532 
00538                             ResourceBundle( const UnicodeString&    path,
00539                                             const char *localeName,
00540                                             UErrorCode&              status);
00541 
00542 private:
00543     static void U_CALLCONV deleteValue(void* value);
00544     Locale                      fRealLocale;
00545 
00546     UHashtable*                 fItemCache;
00547     static const char*          kDefaultSuffix;
00548     static const int32_t        kDefaultSuffixLen;
00549     static const char*          kDefaultFilename;
00550     static const char*          kDefaultLocaleName;
00551 };
00552 
00553 #endif

Generated at Fri Dec 15 12:12:34 2000 for ICU 1.7 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000