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 #include <wchar.h>
00054 
00055 
00056 #ifndef _FILESTRM
00057 typedef struct _FileStream FileStream;
00058 #endif
00059 
00060 /* forward declarations */
00061 class Locale;
00062 class RuleBasedCollator;
00063 class ResourceBundle;
00064 struct UHashtable;
00065 
00066 
00151 class U_COMMON_API ResourceBundle {
00152 public:
00180                         ResourceBundle( const UnicodeString&    path,
00181                                         const Locale&           locale,
00182                                         UErrorCode&              err);
00183                         ResourceBundle( const UnicodeString&    path,
00184                                         UErrorCode&              err);
00185                         ResourceBundle( const wchar_t* path,
00186                                         const Locale& locale,
00187                                         UErrorCode& err);
00188                         ResourceBundle(const ResourceBundle &original);
00189                         ResourceBundle(UResourceBundle *res);
00190 
00191                         ResourceBundle& operator=(const ResourceBundle& other);
00192                         ~ResourceBundle();
00193 
00201     int32_t getSize(void) const;
00212     UnicodeString getString(UErrorCode& status) const;
00213     const uint8_t *getBinary(int32_t& len, UErrorCode& status) const;
00214 
00221     UBool hasNext(void) const;
00227     void resetIterator(void);
00228 
00236     const char *getKey(void);
00237 
00238     const char *getName(void);
00239 
00240 
00247     UResType getType(void);
00248 
00256     ResourceBundle getNext(UErrorCode& status);
00257 
00266     UnicodeString getNextString(UErrorCode& status);
00276     UnicodeString getNextString(const char ** key, UErrorCode& status);
00277 
00286     ResourceBundle get(int32_t index, UErrorCode& status) const;
00287 
00296     UnicodeString getStringEx(int32_t index, UErrorCode& status) const;
00297 
00307     ResourceBundle get(const char* key, UErrorCode& status) const;
00308 
00318     UnicodeString getStringEx(const char* key, UErrorCode& status) const;
00319 
00348     const UnicodeString*    getString(  const char                *resourceTag,
00349                                         UErrorCode&                err) const;
00350 
00370     const UnicodeString*    getStringArray( const char             *resourceTag,
00371                                             int32_t&                numArrayItems,
00372                                             UErrorCode&              err) const;
00373 
00409     const UnicodeString*    getArrayItem(   const char                *resourceTag,
00410                                             int32_t                    index,
00411                                             UErrorCode&                err) const;
00412 
00432     const UnicodeString**   get2dArray(const char          *resourceTag,
00433                                        int32_t&             rowCount,
00434                                        int32_t&             columnCount,
00435                                        UErrorCode&           err) const;
00436 
00479     const UnicodeString*    get2dArrayItem( const char                *resourceTag,
00480                                             int32_t                    rowIndex,
00481                                             int32_t                    columnIndex,
00482                                             UErrorCode&                err) const;
00483 
00521     const UnicodeString*    getTaggedArrayItem( const char             *resourceTag,
00522                                                 const UnicodeString&    itemTag,
00523                                                 UErrorCode&                err) const;
00524 
00548     void                getTaggedArray( const char             *resourceTag,
00549                                         UnicodeString*&         itemTags,
00550                                         UnicodeString*&         items,
00551                                         int32_t&                numItems,
00552                                         UErrorCode&              err) const;
00553     
00573     const char*         getVersionNumber(void) const;
00574 
00581         const Locale &getLocale(void) const ;
00582 
00583 private:
00584     UResourceBundle *resource;
00585     void constructForLocale(const UnicodeString& path, const Locale& locale, UErrorCode& error);
00586     void constructForLocale(const wchar_t* path, const Locale& locale, UErrorCode& error);
00587     void initItemCache(UErrorCode& error);
00588 
00589     friend class RuleBasedCollator;
00590 
00596                             ResourceBundle( const UnicodeString&    path,
00597                                             const char *localeName,
00598                                             UErrorCode&              status);
00599 
00600 private:
00601     static void U_CALLCONV deleteValue(void* value);
00602         Locale                                  fRealLocale;
00603 
00604     UHashtable*          fItemCache;
00605     static const char*          kDefaultSuffix;
00606     static const int32_t        kDefaultSuffixLen;
00607     static const char*          kDefaultFilename;
00608     static const char*          kDefaultLocaleName;
00609 };
00610 
00611 #endif

Generated at Mon Jun 5 12:53:04 2000 for ICU1.5 by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999