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

locid.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 locid.h
00010 *
00011 * Created by: Helena Shih
00012 *
00013 * Modification History:
00014 *
00015 *   Date        Name        Description
00016 *   02/11/97    aliu        Changed gLocPath to fgLocPath and added methods to
00017 *                           get and set it.
00018 *   04/02/97    aliu        Made operator!= inline; fixed return value of getName().
00019 *   04/15/97    aliu        Cleanup for AIX/Win32.
00020 *   04/24/97    aliu        Numerous changes per code review.
00021 *   08/18/98    stephen     Added tokenizeString(),changed getDisplayName()
00022 *   09/08/98    stephen     Moved definition of kEmptyString for Mac Port
00023 *   11/09/99    weiv        Added const char * getName() const;
00024 *   04/12/00    srl         removing unicodestring api's and cached hash code
00025 *   08/10/01    grhoten     Change the static Locales to accessor functions
00026 ******************************************************************************
00027 */
00028 
00029 #ifndef LOCID_H
00030 #define LOCID_H
00031 
00032 #include "unicode/utypes.h"
00033 #include "unicode/uobject.h"
00034 #include "unicode/unistr.h"
00035 #include "unicode/putil.h"
00036 #include "unicode/uloc.h"
00037 
00176 U_NAMESPACE_BEGIN
00177 class U_COMMON_API Locale : public UObject {
00178 public:
00179 #ifdef ICU_LOCID_USE_DEPRECATES
00180 
00184     static const Locale ENGLISH;
00185     static const Locale FRENCH;
00186     static const Locale GERMAN;
00187     static const Locale ITALIAN;
00188     static const Locale JAPANESE;
00189     static const Locale KOREAN;
00190     static const Locale CHINESE;
00191     static const Locale SIMPLIFIED_CHINESE;
00192     static const Locale TRADITIONAL_CHINESE;
00193 
00198     static const Locale FRANCE;
00199     static const Locale GERMANY;
00200     static const Locale ITALY;
00201     static const Locale JAPAN;
00202     static const Locale KOREA;
00203     static const Locale CHINA;      /* Alias for PRC */
00204     static const Locale PRC;        /* Peoples Republic of China */
00205     static const Locale TAIWAN;
00206     static const Locale UK;
00207     static const Locale US;
00208     static const Locale CANADA;
00209     static const Locale CANADA_FRENCH;
00210 #else
00211 
00217     typedef struct U_COMMON_API LocaleProxy {
00218 
00219         int32_t magicLocaleNumber;  /* Try not to access this. This is not meant for normal use. */
00220 
00222         inline const char *getLanguage( ) const;
00224         inline const char *getCountry( ) const;
00226         inline const char *getVariant( ) const;
00228         inline const char *getName() const;
00230         inline const char *getISO3Language() const;
00232         inline const char *getISO3Country() const;
00234         inline uint32_t getLCID(void) const;
00236         inline UnicodeString&  getDisplayLanguage(UnicodeString&   dispLang) const;
00238         inline UnicodeString&  getDisplayLanguage( const   Locale&         inLocale,
00239                                                     UnicodeString&  dispLang) const;
00241         inline UnicodeString&  getDisplayCountry(          UnicodeString& dispCountry) const;
00243         inline UnicodeString&  getDisplayCountry(  const   Locale&         inLocale,
00244                                                     UnicodeString&  dispCountry) const;
00246         inline UnicodeString&  getDisplayVariant(      UnicodeString& dispVar) const;
00248         inline UnicodeString&  getDisplayVariant(  const   Locale&         inLocale,
00249                                                     UnicodeString&  dispVar) const;
00250 
00252         inline UnicodeString&  getDisplayName(         UnicodeString&  name) const;
00254         inline UnicodeString&  getDisplayName( const   Locale&         inLocale,
00255                                                 UnicodeString&  name) const;
00257         inline int32_t         hashCode(void) const;
00258 
00260         operator const Locale&() const;
00261     } LocaleProxy;
00262 
00266     /* @deprecated Remove after 2002-aug-31. Use getEnglish() instead.*/
00267     static const LocaleProxy ENGLISH;
00268     /* @deprecated Remove after 2002-aug-31. Use getFrench() instead.*/
00269     static const LocaleProxy FRENCH;
00270     /* @deprecated Remove after 2002-aug-31. Use getGerman() instead.*/
00271     static const LocaleProxy GERMAN;
00272     /* @deprecated Remove after 2002-aug-31. Use getItalian() instead.*/
00273     static const LocaleProxy ITALIAN;
00274     /* @deprecated Remove after 2002-aug-31. Use getJapanese() instead.*/
00275     static const LocaleProxy JAPANESE;
00276     /* @deprecated Remove after 2002-aug-31. Use getKorean() instead.*/
00277     static const LocaleProxy KOREAN;
00278     /* @deprecated Remove after 2002-aug-31. Use getChinese() instead.*/
00279     static const LocaleProxy CHINESE;
00280     /* @deprecated Remove after 2002-aug-31. Use getSimplifiedChinese() instead.*/
00281     static const LocaleProxy SIMPLIFIED_CHINESE;
00282     /* @deprecated Remove after 2002-aug-31. Use getTraditionalChinese() instead.*/
00283     static const LocaleProxy TRADITIONAL_CHINESE;
00284 
00288     /* @deprecated Remove after 2002-aug-31. Use getFrance() instead.*/
00289     static const LocaleProxy FRANCE;
00290     /* @deprecated Remove after 2002-aug-31. Use getGermany() instead.*/
00291     static const LocaleProxy GERMANY;
00292     /* @deprecated Remove after 2002-aug-31. Use getItaly() instead.*/
00293     static const LocaleProxy ITALY;
00294     /* @deprecated Remove after 2002-aug-31. Use getJapan() instead.*/
00295     static const LocaleProxy JAPAN;
00296     /* @deprecated Remove after 2002-aug-31. Use getKorea() instead.*/
00297     static const LocaleProxy KOREA;
00298     /* @deprecated Remove after 2002-aug-31. Use getChina() instead.*/
00299     static const LocaleProxy CHINA;      /* Alias for PRC */
00300     /* @deprecated Remove after 2002-aug-31. Use getPRC() instead.*/
00301     static const LocaleProxy PRC;        /* Peoples Republic of China */
00302     /* @deprecated Remove after 2002-aug-31. Use getTaiwan() instead.*/
00303     static const LocaleProxy TAIWAN;
00304     /* @deprecated Remove after 2002-aug-31. Use getUK() instead.*/
00305     static const LocaleProxy UK;
00306     /* @deprecated Remove after 2002-aug-31. Use getUS() instead.*/
00307     static const LocaleProxy US;
00308     /* @deprecated Remove after 2002-aug-31. Use getCanada() instead.*/
00309     static const LocaleProxy CANADA;
00310     /* @deprecated Remove after 2002-aug-31. Use getCanadaFrench() instead.*/
00311     static const LocaleProxy CANADA_FRENCH;
00312 
00313 #endif /* ICU_LOCID_USE_DEPRECATES */
00314 
00316     static const Locale &getEnglish(void);
00318     static const Locale &getFrench(void);
00320     static const Locale &getGerman(void);
00322     static const Locale &getItalian(void);
00324     static const Locale &getJapanese(void);
00326     static const Locale &getKorean(void);
00328     static const Locale &getChinese(void);
00330     static const Locale &getSimplifiedChinese(void);
00332     static const Locale &getTraditionalChinese(void);
00333 
00335     static const Locale &getFrance(void);
00337     static const Locale &getGermany(void);
00339     static const Locale &getItaly(void);
00341     static const Locale &getJapan(void);
00343     static const Locale &getKorea(void);
00345     static const Locale &getChina(void);
00347     static const Locale &getPRC(void);
00349     static const Locale &getTaiwan(void);
00351     static const Locale &getUK(void);
00353     static const Locale &getUS(void);
00355     static const Locale &getCanada(void);
00357     static const Locale &getCanadaFrench(void);
00358 
00359 
00365     Locale(); 
00366 
00379     Locale( const   char * language,
00380             const   char * country  = 0, 
00381             const   char * variant  = 0);
00382 
00389     Locale(const    Locale& other);
00390 
00391 
00396     ~Locale() ;
00397 
00405     Locale& operator=(const Locale& other);
00406 
00414     UBool   operator==(const    Locale&     other) const;
00415 
00424     UBool   operator!=(const    Locale&     other) const;
00425 
00441     static  const Locale& getDefault(void);
00442 
00452     static  void    setDefault(const    Locale&     newLocale,
00453                                                     UErrorCode&  success);
00454 
00455     
00465     static Locale createFromName(const char *name);
00466 
00467     
00473     inline const char *  getLanguage( ) const;
00474 
00480     inline const char *  getCountry( ) const;
00481 
00487     inline const char *  getVariant( ) const;
00488 
00497     inline const char * getName() const;
00498 
00505     const char * getISO3Language() const;
00506 
00512     const char * getISO3Country() const;
00513 
00521     uint32_t        getLCID(void) const;
00522 
00532     UnicodeString&  getDisplayLanguage(UnicodeString&   dispLang) const;
00533 
00547     UnicodeString&  getDisplayLanguage( const   Locale&         inLocale,
00548                                                 UnicodeString&  dispLang) const;
00549 
00559     UnicodeString&  getDisplayCountry(          UnicodeString& dispCountry) const;
00560 
00575     UnicodeString&  getDisplayCountry(  const   Locale&         inLocale,
00576                                                 UnicodeString&  dispCountry) const;
00577 
00585     UnicodeString&  getDisplayVariant(      UnicodeString& dispVar) const;
00586 
00595     UnicodeString&  getDisplayVariant(  const   Locale&         inLocale,
00596                                                 UnicodeString&  dispVar) const;
00597 
00609     UnicodeString&  getDisplayName(         UnicodeString&  name) const;
00610 
00623     UnicodeString&  getDisplayName( const   Locale&         inLocale,
00624                                             UnicodeString&  name) const;
00625 
00630     int32_t         hashCode(void) const;
00631 
00640     void setToBogus();
00641 
00647     UBool isBogus(void) const;
00648 
00657     static  const   Locale*     getAvailableLocales(int32_t& count);
00658 
00667     static const char* const* getISOCountries();
00668 
00677     static const char* const*  getISOLanguages();
00678 
00684     virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00685 
00691     static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00692 
00693 protected: /* only protected for testing purposes. DO NOT USE. */
00695     void setFromPOSIXID(const char *posixID);
00696 
00697 private:
00704     Locale& init(const char* cLocaleID);
00705 
00709     static void initLocaleCache(void);
00710 
00711     char language[ULOC_LANG_CAPACITY];
00712     char country[ULOC_COUNTRY_CAPACITY];
00713     int32_t variantBegin;
00714     char* fullName;
00715     char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
00716 
00717     UBool fIsBogus;
00718 
00723     static const char fgClassID;
00724     
00725 //    static Locale *localeList;
00726 //    static int32_t localeListCount;
00727 
00728 #ifdef ICU_LOCID_USE_DEPRECATES
00729     static Locale fgDefaultLocale;
00730 #else
00731     friend struct LocaleProxy;
00732 #endif
00733 
00734     static const Locale &getLocale(int locid);
00735 
00736     friend void locale_set_default_internal(const char *);
00737 };
00738 
00739 inline UBool
00740 Locale::operator!=(const    Locale&     other) const
00741 {
00742     return !operator==(other);
00743 }
00744 
00745 inline const char *
00746 Locale::getCountry() const
00747 {
00748     return country;
00749 }
00750 
00751 inline const char *
00752 Locale::getLanguage() const
00753 {
00754     return language;
00755 }
00756 
00757 inline const char *
00758 Locale::getVariant() const
00759 {
00760     return &fullName[variantBegin];
00761 }
00762 
00763 inline const char * 
00764 Locale::getName() const
00765 {
00766     return fullName;
00767 }
00768 
00769 inline UBool 
00770 Locale::isBogus(void) const {
00771   return fIsBogus;
00772 }
00773 
00774 #ifndef ICU_LOCID_USE_DEPRECATES
00775 /* Proxy functions */
00776 inline const char *Locale::LocaleProxy::getLanguage( ) const
00777 {
00778     return ((const Locale)*this).getLanguage();
00779 }
00780 
00781 inline const char *Locale::LocaleProxy::getCountry( ) const
00782 {
00783     return ((const Locale)*this).getCountry();
00784 }
00785 
00786 inline const char *Locale::LocaleProxy::getVariant( ) const
00787 {
00788     return ((const Locale)*this).getVariant();
00789 }
00790 
00791 inline const char *Locale::LocaleProxy::getName() const
00792 {
00793     return ((const Locale)*this).getName();
00794 }
00795 
00796 inline const char *Locale::LocaleProxy::getISO3Language() const
00797 {
00798     return ((const Locale)*this).getISO3Language();
00799 }
00800 
00801 inline const char *Locale::LocaleProxy::getISO3Country() const
00802 {
00803     return ((const Locale)*this).getISO3Country();
00804 }
00805 
00806 inline uint32_t Locale::LocaleProxy::getLCID(void) const
00807 {
00808     return ((const Locale)*this).getLCID();
00809 }
00810 
00811 inline UnicodeString&  Locale::LocaleProxy::getDisplayLanguage(UnicodeString&   dispLang) const
00812 {
00813     return ((const Locale)*this).getDisplayLanguage(dispLang);
00814 }
00815 
00816 inline UnicodeString&  Locale::LocaleProxy::getDisplayLanguage( const   Locale&         inLocale,
00817                                             UnicodeString&  dispLang) const
00818 {
00819     return ((const Locale)*this).getDisplayLanguage(inLocale, dispLang);
00820 }
00821 
00822 inline UnicodeString&  Locale::LocaleProxy::getDisplayCountry(UnicodeString& dispCountry) const
00823 {
00824     return ((const Locale)*this).getDisplayCountry(dispCountry);
00825 }
00826 
00827 inline UnicodeString&  Locale::LocaleProxy::getDisplayCountry(const   Locale&         inLocale,
00828                                             UnicodeString&  dispCountry) const
00829 {
00830     return ((const Locale)*this).getDisplayCountry(inLocale, dispCountry);
00831 }
00832 
00833 inline UnicodeString&  Locale::LocaleProxy::getDisplayVariant(UnicodeString& dispVar) const
00834 {
00835     return ((const Locale)*this).getDisplayVariant(dispVar);
00836 }
00837 
00838 inline UnicodeString&  Locale::LocaleProxy::getDisplayVariant(const   Locale&         inLocale,
00839                                             UnicodeString&  dispVar) const
00840 {
00841     return ((const Locale)*this).getDisplayVariant(inLocale, dispVar);
00842 }
00843 
00844 inline UnicodeString&  Locale::LocaleProxy::getDisplayName(UnicodeString&  name) const
00845 {
00846     return ((const Locale)*this).getDisplayName(name);
00847 }
00848 
00849 inline UnicodeString&  Locale::LocaleProxy::getDisplayName(const   Locale&         inLocale,
00850                                         UnicodeString&  name) const
00851 {
00852     return ((const Locale)*this).getDisplayName(inLocale, name);
00853 }
00854 
00855 inline int32_t         Locale::LocaleProxy::hashCode(void) const
00856 {
00857     return ((const Locale)*this).hashCode();
00858 }
00859 #endif /* !ICU_LOCID_USE_DEPRECATES */
00860 U_NAMESPACE_END
00861 
00862 #endif

Generated on Thu Aug 15 14:13:26 2002 for ICU 2.2 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001