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 
00033 #include "unicode/putil.h"
00034 
00035 
00036 #define ULOC_LANG_CAPACITY 12
00037 #define ULOC_COUNTRY_CAPACITY 4
00038 #define ULOC_FULLNAME_CAPACITY 50
00039 
00040 #ifdef XP_CPLUSPLUS
00041 
00042 #include "unicode/unistr.h"
00043 
00177 U_NAMESPACE_BEGIN
00178 class U_COMMON_API Locale
00179 {
00180 public:
00181 #ifdef ICU_LOCID_USE_DEPRECATES
00182 
00186     static const Locale ENGLISH;
00187     static const Locale FRENCH;
00188     static const Locale GERMAN;
00189     static const Locale ITALIAN;
00190     static const Locale JAPANESE;
00191     static const Locale KOREAN;
00192     static const Locale CHINESE;
00193     static const Locale SIMPLIFIED_CHINESE;
00194     static const Locale TRADITIONAL_CHINESE;
00195 
00200     static const Locale FRANCE;
00201     static const Locale GERMANY;
00202     static const Locale ITALY;
00203     static const Locale JAPAN;
00204     static const Locale KOREA;
00205     static const Locale CHINA;      /* Alias for PRC */
00206     static const Locale PRC;        /* Peoples Republic of China */
00207     static const Locale TAIWAN;
00208     static const Locale UK;
00209     static const Locale US;
00210     static const Locale CANADA;
00211     static const Locale CANADA_FRENCH;
00212 #else
00213 
00219     typedef struct U_COMMON_API LocaleProxy {
00220 
00221         int32_t magicLocaleNumber;  /* Try not to access this. This is not meant for normal use. */
00222 
00224         inline const char *getLanguage( ) const;
00226         inline const char *getCountry( ) const;
00228         inline const char *getVariant( ) const;
00230         inline const char *getName() const;
00232         inline const char *getISO3Language() const;
00234         inline const char *getISO3Country() const;
00236         inline uint32_t getLCID(void) const;
00238         inline UnicodeString&  getDisplayLanguage(UnicodeString&   dispLang) const;
00240         inline UnicodeString&  getDisplayLanguage( const   Locale&         inLocale,
00241                                                     UnicodeString&  dispLang) const;
00243         inline UnicodeString&  getDisplayCountry(          UnicodeString& dispCountry) const;
00245         inline UnicodeString&  getDisplayCountry(  const   Locale&         inLocale,
00246                                                     UnicodeString&  dispCountry) const;
00248         inline UnicodeString&  getDisplayVariant(      UnicodeString& dispVar) const;
00250         inline UnicodeString&  getDisplayVariant(  const   Locale&         inLocale,
00251                                                     UnicodeString&  dispVar) const;
00252 
00254         inline UnicodeString&  getDisplayName(         UnicodeString&  name) const;
00256         inline UnicodeString&  getDisplayName( const   Locale&         inLocale,
00257                                                 UnicodeString&  name) const;
00259         inline int32_t         hashCode(void) const;
00260 
00262         operator const Locale&() const;
00263     } LocaleProxy;
00264 
00268     /* @deprecated Remove after 2002-aug-31. Use getEnglish() instead.*/
00269     static const LocaleProxy ENGLISH;
00270     /* @deprecated Remove after 2002-aug-31. Use getFrench() instead.*/
00271     static const LocaleProxy FRENCH;
00272     /* @deprecated Remove after 2002-aug-31. Use getGerman() instead.*/
00273     static const LocaleProxy GERMAN;
00274     /* @deprecated Remove after 2002-aug-31. Use getItalian() instead.*/
00275     static const LocaleProxy ITALIAN;
00276     /* @deprecated Remove after 2002-aug-31. Use getJapanese() instead.*/
00277     static const LocaleProxy JAPANESE;
00278     /* @deprecated Remove after 2002-aug-31. Use getKorean() instead.*/
00279     static const LocaleProxy KOREAN;
00280     /* @deprecated Remove after 2002-aug-31. Use getChinese() instead.*/
00281     static const LocaleProxy CHINESE;
00282     /* @deprecated Remove after 2002-aug-31. Use getSimplifiedChinese() instead.*/
00283     static const LocaleProxy SIMPLIFIED_CHINESE;
00284     /* @deprecated Remove after 2002-aug-31. Use getTraditionalChinese() instead.*/
00285     static const LocaleProxy TRADITIONAL_CHINESE;
00286 
00290     /* @deprecated Remove after 2002-aug-31. Use getFrance() instead.*/
00291     static const LocaleProxy FRANCE;
00292     /* @deprecated Remove after 2002-aug-31. Use getGermany() instead.*/
00293     static const LocaleProxy GERMANY;
00294     /* @deprecated Remove after 2002-aug-31. Use getItaly() instead.*/
00295     static const LocaleProxy ITALY;
00296     /* @deprecated Remove after 2002-aug-31. Use getJapan() instead.*/
00297     static const LocaleProxy JAPAN;
00298     /* @deprecated Remove after 2002-aug-31. Use getKorea() instead.*/
00299     static const LocaleProxy KOREA;
00300     /* @deprecated Remove after 2002-aug-31. Use getChina() instead.*/
00301     static const LocaleProxy CHINA;      /* Alias for PRC */
00302     /* @deprecated Remove after 2002-aug-31. Use getPRC() instead.*/
00303     static const LocaleProxy PRC;        /* Peoples Republic of China */
00304     /* @deprecated Remove after 2002-aug-31. Use getTaiwan() instead.*/
00305     static const LocaleProxy TAIWAN;
00306     /* @deprecated Remove after 2002-aug-31. Use getUK() instead.*/
00307     static const LocaleProxy UK;
00308     /* @deprecated Remove after 2002-aug-31. Use getUS() instead.*/
00309     static const LocaleProxy US;
00310     /* @deprecated Remove after 2002-aug-31. Use getCanada() instead.*/
00311     static const LocaleProxy CANADA;
00312     /* @deprecated Remove after 2002-aug-31. Use getCanadaFrench() instead.*/
00313     static const LocaleProxy CANADA_FRENCH;
00314 
00315 #endif /* ICU_LOCID_USE_DEPRECATES */
00316 
00318     static const Locale &getEnglish(void);
00320     static const Locale &getFrench(void);
00322     static const Locale &getGerman(void);
00324     static const Locale &getItalian(void);
00326     static const Locale &getJapanese(void);
00328     static const Locale &getKorean(void);
00330     static const Locale &getChinese(void);
00332     static const Locale &getSimplifiedChinese(void);
00334     static const Locale &getTraditionalChinese(void);
00335 
00337     static const Locale &getFrance(void);
00339     static const Locale &getGermany(void);
00341     static const Locale &getItaly(void);
00343     static const Locale &getJapan(void);
00345     static const Locale &getKorea(void);
00347     static const Locale &getChina(void);
00349     static const Locale &getPRC(void);
00351     static const Locale &getTaiwan(void);
00353     static const Locale &getUK(void);
00355     static const Locale &getUS(void);
00357     static const Locale &getCanada(void);
00359     static const Locale &getCanadaFrench(void);
00360 
00361 
00367     Locale(); 
00368 
00380     Locale( const   char * language,
00381             const   char * country  = 0, 
00382             const   char * variant  = 0);
00383 
00390     Locale(const    Locale& other);
00391 
00392 
00397     ~Locale() ;
00398 
00406     Locale& operator=(const Locale& other);
00407 
00415     UBool   operator==(const    Locale&     other) const;
00416 
00425     UBool   operator!=(const    Locale&     other) const;
00426 
00441     static  const Locale& getDefault(void);
00442 
00451     static  void    setDefault(const    Locale&     newLocale,
00452                                                     UErrorCode&  success);
00453 
00454     
00464     static Locale createFromName(const char *name);
00465 
00466     
00472     inline const char *  getLanguage( ) const;
00473 
00479     inline const char *  getCountry( ) const;
00480 
00486     inline const char *  getVariant( ) const;
00487 
00496     inline const char * getName() const;
00497 
00504     const char * getISO3Language() const;
00505 
00511     const char * getISO3Country() const;
00512 
00520     uint32_t        getLCID(void) const;
00521 
00531     UnicodeString&  getDisplayLanguage(UnicodeString&   dispLang) const;
00532 
00546     UnicodeString&  getDisplayLanguage( const   Locale&         inLocale,
00547                                                 UnicodeString&  dispLang) const;
00548 
00558     UnicodeString&  getDisplayCountry(          UnicodeString& dispCountry) const;
00559 
00574     UnicodeString&  getDisplayCountry(  const   Locale&         inLocale,
00575                                                 UnicodeString&  dispCountry) const;
00576 
00584     UnicodeString&  getDisplayVariant(      UnicodeString& dispVar) const;
00585 
00594     UnicodeString&  getDisplayVariant(  const   Locale&         inLocale,
00595                                                 UnicodeString&  dispVar) const;
00596 
00608     UnicodeString&  getDisplayName(         UnicodeString&  name) const;
00609 
00622     UnicodeString&  getDisplayName( const   Locale&         inLocale,
00623                                             UnicodeString&  name) const;
00624 
00629     int32_t         hashCode(void) const;
00630 
00639     static  const   Locale*     getAvailableLocales(int32_t& count);
00640 
00649     static const char* const* getISOCountries();
00650 
00659     static const char* const*  getISOLanguages();
00660 
00661 protected: /* only protected for testing purposes. DO NOT USE. */
00663     void setFromPOSIXID(const char *posixID);
00664 
00665 private:
00672     Locale& init(const char* cLocaleID);
00673 
00677     static void initLocaleCache(void);
00678 
00679     char language[ULOC_LANG_CAPACITY];
00680     char country[ULOC_COUNTRY_CAPACITY];
00681     int32_t variantBegin;
00682     char* fullName;
00683     char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
00684     
00685 //    static Locale *localeList;
00686 //    static int32_t localeListCount;
00687 
00688 #ifdef ICU_LOCID_USE_DEPRECATES
00689     static Locale fgDefaultLocale;
00690 #else
00691     friend struct LocaleProxy;
00692 #endif
00693 
00694     static const Locale &getLocale(int locid);
00695 
00696     friend void locale_set_default_internal(const char *);
00697 };
00698 
00699 inline UBool
00700 Locale::operator!=(const    Locale&     other) const
00701 {
00702     return !operator==(other);
00703 }
00704 
00705 inline const char *
00706 Locale::getCountry() const
00707 {
00708     return country;
00709 }
00710 
00711 inline const char *
00712 Locale::getLanguage() const
00713 {
00714     return language;
00715 }
00716 
00717 inline const char *
00718 Locale::getVariant() const
00719 {
00720     return &fullName[variantBegin];
00721 }
00722 
00723 inline const char * 
00724 Locale::getName() const
00725 {
00726     return fullName;
00727 }
00728 
00729 #ifndef ICU_LOCID_USE_DEPRECATES
00730 /* Proxy functions */
00731 inline const char *Locale::LocaleProxy::getLanguage( ) const
00732 {
00733     return ((const Locale)*this).getLanguage();
00734 }
00735 
00736 inline const char *Locale::LocaleProxy::getCountry( ) const
00737 {
00738     return ((const Locale)*this).getCountry();
00739 }
00740 
00741 inline const char *Locale::LocaleProxy::getVariant( ) const
00742 {
00743     return ((const Locale)*this).getVariant();
00744 }
00745 
00746 inline const char *Locale::LocaleProxy::getName() const
00747 {
00748     return ((const Locale)*this).getName();
00749 }
00750 
00751 inline const char *Locale::LocaleProxy::getISO3Language() const
00752 {
00753     return ((const Locale)*this).getISO3Language();
00754 }
00755 
00756 inline const char *Locale::LocaleProxy::getISO3Country() const
00757 {
00758     return ((const Locale)*this).getISO3Country();
00759 }
00760 
00761 inline uint32_t Locale::LocaleProxy::getLCID(void) const
00762 {
00763     return ((const Locale)*this).getLCID();
00764 }
00765 
00766 inline UnicodeString&  Locale::LocaleProxy::getDisplayLanguage(UnicodeString&   dispLang) const
00767 {
00768     return ((const Locale)*this).getDisplayLanguage(dispLang);
00769 }
00770 
00771 inline UnicodeString&  Locale::LocaleProxy::getDisplayLanguage( const   Locale&         inLocale,
00772                                             UnicodeString&  dispLang) const
00773 {
00774     return ((const Locale)*this).getDisplayLanguage(inLocale, dispLang);
00775 }
00776 
00777 inline UnicodeString&  Locale::LocaleProxy::getDisplayCountry(UnicodeString& dispCountry) const
00778 {
00779     return ((const Locale)*this).getDisplayCountry(dispCountry);
00780 }
00781 
00782 inline UnicodeString&  Locale::LocaleProxy::getDisplayCountry(const   Locale&         inLocale,
00783                                             UnicodeString&  dispCountry) const
00784 {
00785     return ((const Locale)*this).getDisplayCountry(inLocale, dispCountry);
00786 }
00787 
00788 inline UnicodeString&  Locale::LocaleProxy::getDisplayVariant(UnicodeString& dispVar) const
00789 {
00790     return ((const Locale)*this).getDisplayVariant(dispVar);
00791 }
00792 
00793 inline UnicodeString&  Locale::LocaleProxy::getDisplayVariant(const   Locale&         inLocale,
00794                                             UnicodeString&  dispVar) const
00795 {
00796     return ((const Locale)*this).getDisplayVariant(inLocale, dispVar);
00797 }
00798 
00799 inline UnicodeString&  Locale::LocaleProxy::getDisplayName(UnicodeString&  name) const
00800 {
00801     return ((const Locale)*this).getDisplayName(name);
00802 }
00803 
00804 inline UnicodeString&  Locale::LocaleProxy::getDisplayName(const   Locale&         inLocale,
00805                                         UnicodeString&  name) const
00806 {
00807     return ((const Locale)*this).getDisplayName(inLocale, name);
00808 }
00809 
00810 inline int32_t         Locale::LocaleProxy::hashCode(void) const
00811 {
00812     return ((const Locale)*this).hashCode();
00813 }
00814 #endif /* !ICU_LOCID_USE_DEPRECATES */
00815 U_NAMESPACE_END
00816 
00817 #endif  /* XP_CPLUSPLUS */
00818 #endif
00819 

Generated on Mon Dec 3 19:00:21 2001 for ICU 2.0 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001