Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

locid.h

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 /* all ULOC constants are now in uloc.h. */
00036 #include "unicode/uloc.h"
00037 
00038 #ifdef XP_CPLUSPLUS
00039 
00040 #include "unicode/unistr.h"
00041 
00175 U_NAMESPACE_BEGIN
00176 class U_COMMON_API Locale
00177 {
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 
00378     Locale( const   char * language,
00379             const   char * country  = 0, 
00380             const   char * variant  = 0);
00381 
00388     Locale(const    Locale& other);
00389 
00390 
00395     ~Locale() ;
00396 
00404     Locale& operator=(const Locale& other);
00405 
00413     UBool   operator==(const    Locale&     other) const;
00414 
00423     UBool   operator!=(const    Locale&     other) const;
00424 
00439     static  const Locale& getDefault(void);
00440 
00449     static  void    setDefault(const    Locale&     newLocale,
00450                                                     UErrorCode&  success);
00451 
00452     
00462     static Locale createFromName(const char *name);
00463 
00464     
00470     inline const char *  getLanguage( ) const;
00471 
00477     inline const char *  getCountry( ) const;
00478 
00484     inline const char *  getVariant( ) const;
00485 
00494     inline const char * getName() const;
00495 
00502     const char * getISO3Language() const;
00503 
00509     const char * getISO3Country() const;
00510 
00518     uint32_t        getLCID(void) const;
00519 
00529     UnicodeString&  getDisplayLanguage(UnicodeString&   dispLang) const;
00530 
00544     UnicodeString&  getDisplayLanguage( const   Locale&         inLocale,
00545                                                 UnicodeString&  dispLang) const;
00546 
00556     UnicodeString&  getDisplayCountry(          UnicodeString& dispCountry) const;
00557 
00572     UnicodeString&  getDisplayCountry(  const   Locale&         inLocale,
00573                                                 UnicodeString&  dispCountry) const;
00574 
00582     UnicodeString&  getDisplayVariant(      UnicodeString& dispVar) const;
00583 
00592     UnicodeString&  getDisplayVariant(  const   Locale&         inLocale,
00593                                                 UnicodeString&  dispVar) const;
00594 
00606     UnicodeString&  getDisplayName(         UnicodeString&  name) const;
00607 
00620     UnicodeString&  getDisplayName( const   Locale&         inLocale,
00621                                             UnicodeString&  name) const;
00622 
00627     int32_t         hashCode(void) const;
00628 
00637     void setToBogus();
00638 
00644     UBool isBogus(void) const;
00645 
00654     static  const   Locale*     getAvailableLocales(int32_t& count);
00655 
00664     static const char* const* getISOCountries();
00665 
00674     static const char* const*  getISOLanguages();
00675 
00676 protected: /* only protected for testing purposes. DO NOT USE. */
00678     void setFromPOSIXID(const char *posixID);
00679 
00680 private:
00687     Locale& init(const char* cLocaleID);
00688 
00692     static void initLocaleCache(void);
00693 
00694     char language[ULOC_LANG_CAPACITY];
00695     char country[ULOC_COUNTRY_CAPACITY];
00696     int32_t variantBegin;
00697     char* fullName;
00698     char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
00699 
00700     UBool fIsBogus;
00701     
00702 //    static Locale *localeList;
00703 //    static int32_t localeListCount;
00704 
00705 #ifdef ICU_LOCID_USE_DEPRECATES
00706     static Locale fgDefaultLocale;
00707 #else
00708     friend struct LocaleProxy;
00709 #endif
00710 
00711     static const Locale &getLocale(int locid);
00712 
00713     friend void locale_set_default_internal(const char *);
00714 };
00715 
00716 inline UBool
00717 Locale::operator!=(const    Locale&     other) const
00718 {
00719     return !operator==(other);
00720 }
00721 
00722 inline const char *
00723 Locale::getCountry() const
00724 {
00725     return country;
00726 }
00727 
00728 inline const char *
00729 Locale::getLanguage() const
00730 {
00731     return language;
00732 }
00733 
00734 inline const char *
00735 Locale::getVariant() const
00736 {
00737     return &fullName[variantBegin];
00738 }
00739 
00740 inline const char * 
00741 Locale::getName() const
00742 {
00743     return fullName;
00744 }
00745 
00746 inline UBool 
00747 Locale::isBogus(void) const {
00748   return fIsBogus;
00749 }
00750 
00751 #ifndef ICU_LOCID_USE_DEPRECATES
00752 /* Proxy functions */
00753 inline const char *Locale::LocaleProxy::getLanguage( ) const
00754 {
00755     return ((const Locale)*this).getLanguage();
00756 }
00757 
00758 inline const char *Locale::LocaleProxy::getCountry( ) const
00759 {
00760     return ((const Locale)*this).getCountry();
00761 }
00762 
00763 inline const char *Locale::LocaleProxy::getVariant( ) const
00764 {
00765     return ((const Locale)*this).getVariant();
00766 }
00767 
00768 inline const char *Locale::LocaleProxy::getName() const
00769 {
00770     return ((const Locale)*this).getName();
00771 }
00772 
00773 inline const char *Locale::LocaleProxy::getISO3Language() const
00774 {
00775     return ((const Locale)*this).getISO3Language();
00776 }
00777 
00778 inline const char *Locale::LocaleProxy::getISO3Country() const
00779 {
00780     return ((const Locale)*this).getISO3Country();
00781 }
00782 
00783 inline uint32_t Locale::LocaleProxy::getLCID(void) const
00784 {
00785     return ((const Locale)*this).getLCID();
00786 }
00787 
00788 inline UnicodeString&  Locale::LocaleProxy::getDisplayLanguage(UnicodeString&   dispLang) const
00789 {
00790     return ((const Locale)*this).getDisplayLanguage(dispLang);
00791 }
00792 
00793 inline UnicodeString&  Locale::LocaleProxy::getDisplayLanguage( const   Locale&         inLocale,
00794                                             UnicodeString&  dispLang) const
00795 {
00796     return ((const Locale)*this).getDisplayLanguage(inLocale, dispLang);
00797 }
00798 
00799 inline UnicodeString&  Locale::LocaleProxy::getDisplayCountry(UnicodeString& dispCountry) const
00800 {
00801     return ((const Locale)*this).getDisplayCountry(dispCountry);
00802 }
00803 
00804 inline UnicodeString&  Locale::LocaleProxy::getDisplayCountry(const   Locale&         inLocale,
00805                                             UnicodeString&  dispCountry) const
00806 {
00807     return ((const Locale)*this).getDisplayCountry(inLocale, dispCountry);
00808 }
00809 
00810 inline UnicodeString&  Locale::LocaleProxy::getDisplayVariant(UnicodeString& dispVar) const
00811 {
00812     return ((const Locale)*this).getDisplayVariant(dispVar);
00813 }
00814 
00815 inline UnicodeString&  Locale::LocaleProxy::getDisplayVariant(const   Locale&         inLocale,
00816                                             UnicodeString&  dispVar) const
00817 {
00818     return ((const Locale)*this).getDisplayVariant(inLocale, dispVar);
00819 }
00820 
00821 inline UnicodeString&  Locale::LocaleProxy::getDisplayName(UnicodeString&  name) const
00822 {
00823     return ((const Locale)*this).getDisplayName(name);
00824 }
00825 
00826 inline UnicodeString&  Locale::LocaleProxy::getDisplayName(const   Locale&         inLocale,
00827                                         UnicodeString&  name) const
00828 {
00829     return ((const Locale)*this).getDisplayName(inLocale, name);
00830 }
00831 
00832 inline int32_t         Locale::LocaleProxy::hashCode(void) const
00833 {
00834     return ((const Locale)*this).hashCode();
00835 }
00836 #endif /* !ICU_LOCID_USE_DEPRECATES */
00837 U_NAMESPACE_END
00838 
00839 #endif  /* XP_CPLUSPLUS */
00840 #endif
00841 

Generated on Fri Mar 7 20:02:44 2003 for ICU 2.1 by doxygen1.3-rc3