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

resbund.h

This is the verbatim text of the resbund.h include file.
/*
*******************************************************************************
*
*   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/utypes.h"
#include "unicode/unistr.h"
#include "unicode/locid.h"
#include <wchar.h>


class RBHashtable;
class ResourceBundleData;
class ResourceBundleCache;
class VisitedFileCache;
#ifndef _FILESTRM
typedef struct _FileStream FileStream;
#endif

/* forward declarations */
class Locale;
class RuleBasedCollator;
class ResourceBundle;
extern int32_t T_ResourceBundle_countArrayItemsImplementation(
                const ResourceBundle* resourceBundle, 
                const char* resourceKey,
                UErrorCode& err);
extern const UnicodeString** listInstalledLocalesImplementation(
                const char* path,
                int32_t* numInstalledLocales);
extern void getTaggedArrayUCharsImplementation(
                const ResourceBundle*   bundle,
                const char           *resourceTag,
                UChar const**         itemTags,
                UChar const**         items,
                int32_t                    maxItems,
                int32_t&                numItems,
                UErrorCode&              err);

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();

    void                getString(  const char             *resourceTag,
                                    UnicodeString&          theString,
                                    UErrorCode&              err) const;

    const UnicodeString*    getString(  const char                *resourceTag,
                                        UErrorCode&                err) const;

    const UnicodeString*    getStringArray( const char             *resourceTag,
                                            int32_t&                numArrayItems,
                                            UErrorCode&              err) const;

    void                getArrayItem(   const char             *resourceTag,
                                        int32_t                 index,
                                        UnicodeString&          theArrayItem,
                                        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;

    void                get2dArrayItem(const char          *resourceTag,
                                       int32_t              rowIndex,
                                       int32_t              columnIndex,
                                       UnicodeString&       theArrayItem,
                                       UErrorCode&           err) const;

    const UnicodeString*    get2dArrayItem( const char                *resourceTag,
                                            int32_t                    rowIndex,
                                            int32_t                    columnIndex,
                                            UErrorCode&                err) const;

    void                getTaggedArrayItem( const char             *resourceTag,
                                            const UnicodeString&    itemTag,
                                            UnicodeString&          theArrayItem,
                                            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:
    class U_COMMON_API PathInfo {
    public:
        PathInfo();
        PathInfo(const PathInfo& source);
        PathInfo(const UnicodeString& path);
        PathInfo(const UnicodeString& path, const UnicodeString& suffix);
        PathInfo(const wchar_t* path, const wchar_t* suffix);
        ~PathInfo();

        PathInfo& operator=(const PathInfo& source);

        bool_t fileExists(const UnicodeString& localeName) const;
        UnicodeString makeCacheKey(const UnicodeString& localeName) const;
        UnicodeString makeHashkey(const UnicodeString& localeName) const;
        FileStream* openFile(const UnicodeString& localeName) const;

    private:
        static const UChar        kSeparator;
        UnicodeString                fPrefix;
        UnicodeString                fSuffix;
        wchar_t*                    fWPrefix;
        wchar_t*                    fWSuffix;
    };

private:
    friend class Locale;
    friend class RuleBasedCollator;
    friend int32_t T_ResourceBundle_countArrayItemsImplementation(const ResourceBundle* resourceBundle, 
                                  const char* resourceKey,
                                  UErrorCode& err) ;
    friend const UnicodeString** listInstalledLocalesImplementation(const char* path,
                                   int32_t* numInstalledLocales);
    friend void getTaggedArrayUCharsImplementation(
                             const ResourceBundle*   bundle,
                             const char           *resourceTag,
                             UChar const**         itemTags,
                             UChar const**         items,
                             int32_t                    maxItems,
                             int32_t&                numItems,
                             UErrorCode&              err);


                            ResourceBundle( const UnicodeString&    path,
                                            const UnicodeString&    localeName,
                                            UErrorCode&              status);

    static const UnicodeString* listInstalledLocales(const UnicodeString& path,
                                                     int32_t&   numInstalledLocales);

    static const UHashtable* getFromCache(const PathInfo& path,
                                         const UnicodeString& localeName,
                     ResourceBundleCache* someCache);

    static const UHashtable* getFromCacheWithFallback(const PathInfo& path,
                                                     const UnicodeString& desiredLocale,
                                                     UnicodeString& returnedLocale,
                             ResourceBundleCache* someCache,
                                                     UErrorCode& error);

    typedef void (*Handler)(const UnicodeString& localeName,
                            UHashtable* hashtable,
                            void* context,
                ResourceBundleCache* someCache);

    static void parse(const PathInfo& path, 
              const UnicodeString& localeName,
                      Handler handler,
                      void* context,
              ResourceBundleCache* someCache,
                      UErrorCode &error);

    static bool_t parseIfUnparsed(const PathInfo& path,
                                const UnicodeString& locale,
                                ResourceBundleCache* fCache,
                  VisitedFileCache* vCache,
                  UErrorCode& error);

    const UHashtable* getHashtableForLocale(const UnicodeString& localeName,
                                           UnicodeString& returnedLocale,
                                           UErrorCode& err);

    const UHashtable* getHashtableForLocale(const UnicodeString& desiredLocale,
                                           UErrorCode& error);

    const ResourceBundleData* getDataForTag(const char *tag,
                                            UErrorCode& err) const;

    void constructForLocale(const PathInfo& path,
                            const Locale& locale,
                            UErrorCode& error);

    static void addToCache(const UnicodeString& localeName,
                           UHashtable* hashtable,
                           void* context,
               ResourceBundleCache* someCache);

    static void saveCollationHashtable(const UnicodeString& localeName,
                                       UHashtable* hashtable,
                                       void* context,
                       ResourceBundleCache* cache);
private:
    class LocaleFallbackIterator
    {
    public:
        LocaleFallbackIterator(const UnicodeString& startingLocale,
                               const UnicodeString& root,
                               bool_t useDefaultLocale);

        const UnicodeString& getLocale(void) const { return fLocale; }

        bool_t nextLocale(UErrorCode& status);

    private:
        void chopLocale(void);

        UnicodeString fLocale;
        UnicodeString fDefaultLocale;
        UnicodeString fRoot;
        bool_t fUseDefaultLocale;
        bool_t fTriedDefaultLocale;
        bool_t fTriedRoot;
    };

private:
    static const char*          kDefaultSuffix;
    static const int32_t        kDefaultSuffixLen;
    static const char*          kDefaultFilename;
    static const char*          kDefaultLocaleName;
    static const char*          kIndexLocaleName;
    static const char*          kIndexFilename;
    static const char*          kIndexTag;

    static const char*          kDefaultMinorVersion;
    static const char*          kVersionSeparator;
    static const char*          kVersionTag;

    static ResourceBundleCache* fgUserCache;
    static VisitedFileCache*    fgUserVisitedFiles;

    ResourceBundleCache* fgCache;
    VisitedFileCache*    fgVisitedFiles;

    PathInfo                fPath;

    enum {                  kDataCount = 4 };
    const UHashtable*        fData[kDataCount]; // These aren't const if fIsDataOwned is true
    bool_t                  fLoaded[kDataCount];
    UErrorCode              fDataStatus[kDataCount]; // Returns the appropriate error code for each data table.
    bool_t                  fIsDataOwned;
        Locale                                  fRealLocale;
    LocaleFallbackIterator* fLocaleIterator;
    char*                   fVersionID;
};

#endif

Generated at Thu Feb 10 15:30:52 2000 for icu by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999