00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
00178 U_NAMESPACE_BEGIN
00179 class U_COMMON_API Locale : public UObject {
00180 public:
00181 #ifdef ICU_LOCID_USE_DEPRECATES
00182
00188 typedef struct U_COMMON_API LocaleProxy {
00189
00190
00191 int32_t magicLocaleNumber;
00192
00194 inline const char *getLanguage( ) const;
00196 inline const char *getCountry( ) const;
00198 inline const char *getVariant( ) const;
00200 inline const char *getName() const;
00202 inline const char *getISO3Language() const;
00204 inline const char *getISO3Country() const;
00206 inline uint32_t getLCID(void) const;
00208 inline UnicodeString& getDisplayLanguage(UnicodeString& dispLang) const;
00210 inline UnicodeString& getDisplayLanguage( const Locale& inLocale,
00211 UnicodeString& dispLang) const;
00213 inline UnicodeString& getDisplayCountry( UnicodeString& dispCountry) const;
00215 inline UnicodeString& getDisplayCountry( const Locale& inLocale,
00216 UnicodeString& dispCountry) const;
00218 inline UnicodeString& getDisplayVariant( UnicodeString& dispVar) const;
00220 inline UnicodeString& getDisplayVariant( const Locale& inLocale,
00221 UnicodeString& dispVar) const;
00222
00224 inline UnicodeString& getDisplayName( UnicodeString& name) const;
00226 inline UnicodeString& getDisplayName( const Locale& inLocale,
00227 UnicodeString& name) const;
00229 inline int32_t hashCode(void) const;
00230
00232 operator const Locale&() const;
00233 } LocaleProxy;
00234
00239 static const LocaleProxy ENGLISH;
00241 static const LocaleProxy FRENCH;
00243 static const LocaleProxy GERMAN;
00245 static const LocaleProxy ITALIAN;
00247 static const LocaleProxy JAPANESE;
00249 static const LocaleProxy KOREAN;
00251 static const LocaleProxy CHINESE;
00253 static const LocaleProxy SIMPLIFIED_CHINESE;
00255 static const LocaleProxy TRADITIONAL_CHINESE;
00256
00261 static const LocaleProxy FRANCE;
00263 static const LocaleProxy GERMANY;
00265 static const LocaleProxy ITALY;
00267 static const LocaleProxy JAPAN;
00269 static const LocaleProxy KOREA;
00271 static const LocaleProxy CHINA;
00273 static const LocaleProxy PRC;
00275 static const LocaleProxy TAIWAN;
00277 static const LocaleProxy UK;
00279 static const LocaleProxy US;
00281 static const LocaleProxy CANADA;
00283 static const LocaleProxy CANADA_FRENCH;
00284
00285 #endif
00286
00288 static const Locale &getEnglish(void);
00290 static const Locale &getFrench(void);
00292 static const Locale &getGerman(void);
00294 static const Locale &getItalian(void);
00296 static const Locale &getJapanese(void);
00298 static const Locale &getKorean(void);
00300 static const Locale &getChinese(void);
00302 static const Locale &getSimplifiedChinese(void);
00304 static const Locale &getTraditionalChinese(void);
00305
00307 static const Locale &getFrance(void);
00309 static const Locale &getGermany(void);
00311 static const Locale &getItaly(void);
00313 static const Locale &getJapan(void);
00315 static const Locale &getKorea(void);
00317 static const Locale &getChina(void);
00319 static const Locale &getPRC(void);
00321 static const Locale &getTaiwan(void);
00323 static const Locale &getUK(void);
00325 static const Locale &getUS(void);
00327 static const Locale &getCanada(void);
00329 static const Locale &getCanadaFrench(void);
00330
00331
00337 Locale();
00338
00354 Locale( const char * language,
00355 const char * country = 0,
00356 const char * variant = 0);
00357
00364 Locale(const Locale& other);
00365
00366
00371 ~Locale() ;
00372
00380 Locale& operator=(const Locale& other);
00381
00389 UBool operator==(const Locale& other) const;
00390
00399 UBool operator!=(const Locale& other) const;
00400
00416 static const Locale& getDefault(void);
00417
00427 static void setDefault(const Locale& newLocale,
00428 UErrorCode& success);
00429
00430
00440 static Locale createFromName(const char *name);
00441
00442
00448 inline const char * getLanguage( ) const;
00449
00455 inline const char * getCountry( ) const;
00456
00462 inline const char * getVariant( ) const;
00463
00472 inline const char * getName() const;
00473
00480 const char * getISO3Language() const;
00481
00487 const char * getISO3Country() const;
00488
00496 uint32_t getLCID(void) const;
00497
00507 UnicodeString& getDisplayLanguage(UnicodeString& dispLang) const;
00508
00522 UnicodeString& getDisplayLanguage( const Locale& inLocale,
00523 UnicodeString& dispLang) const;
00524
00534 UnicodeString& getDisplayCountry( UnicodeString& dispCountry) const;
00535
00550 UnicodeString& getDisplayCountry( const Locale& inLocale,
00551 UnicodeString& dispCountry) const;
00552
00560 UnicodeString& getDisplayVariant( UnicodeString& dispVar) const;
00561
00570 UnicodeString& getDisplayVariant( const Locale& inLocale,
00571 UnicodeString& dispVar) const;
00572
00584 UnicodeString& getDisplayName( UnicodeString& name) const;
00585
00598 UnicodeString& getDisplayName( const Locale& inLocale,
00599 UnicodeString& name) const;
00600
00605 int32_t hashCode(void) const;
00606
00615 void setToBogus();
00616
00622 UBool isBogus(void) const;
00623
00632 static const Locale* getAvailableLocales(int32_t& count);
00633
00642 static const char* const* getISOCountries();
00643
00652 static const char* const* getISOLanguages();
00653
00659 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00660
00666 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00667
00668 protected:
00673 void setFromPOSIXID(const char *posixID);
00674
00675 private:
00682 Locale& init(const char* cLocaleID);
00683
00687 static void initLocaleCache(void);
00688
00689 char language[ULOC_LANG_CAPACITY];
00690 char country[ULOC_COUNTRY_CAPACITY];
00691 int32_t variantBegin;
00692 char* fullName;
00693 char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
00694
00695 UBool fIsBogus;
00696
00701 static const char fgClassID;
00702
00703
00704
00705
00706 #ifdef ICU_LOCID_USE_DEPRECATES
00707 friend struct LocaleProxy;
00708 #endif
00709
00710 static const Locale &getLocale(int locid);
00711
00712 friend void locale_set_default_internal(const char *);
00713 };
00714
00715 inline UBool
00716 Locale::operator!=(const Locale& other) const
00717 {
00718 return !operator==(other);
00719 }
00720
00721 inline const char *
00722 Locale::getCountry() const
00723 {
00724 return country;
00725 }
00726
00727 inline const char *
00728 Locale::getLanguage() const
00729 {
00730 return language;
00731 }
00732
00733 inline const char *
00734 Locale::getVariant() const
00735 {
00736 return &fullName[variantBegin];
00737 }
00738
00739 inline const char *
00740 Locale::getName() const
00741 {
00742 return fullName;
00743 }
00744
00745 inline UBool
00746 Locale::isBogus(void) const {
00747 return fIsBogus;
00748 }
00749
00750 #ifdef ICU_LOCID_USE_DEPRECATES
00751
00752 inline const char *Locale::LocaleProxy::getLanguage( ) const
00753 {
00754 return ((const Locale)*this).getLanguage();
00755 }
00756
00757 inline const char *Locale::LocaleProxy::getCountry( ) const
00758 {
00759 return ((const Locale)*this).getCountry();
00760 }
00761
00762 inline const char *Locale::LocaleProxy::getVariant( ) const
00763 {
00764 return ((const Locale)*this).getVariant();
00765 }
00766
00767 inline const char *Locale::LocaleProxy::getName() const
00768 {
00769 return ((const Locale)*this).getName();
00770 }
00771
00772 inline const char *Locale::LocaleProxy::getISO3Language() const
00773 {
00774 return ((const Locale)*this).getISO3Language();
00775 }
00776
00777 inline const char *Locale::LocaleProxy::getISO3Country() const
00778 {
00779 return ((const Locale)*this).getISO3Country();
00780 }
00781
00782 inline uint32_t Locale::LocaleProxy::getLCID(void) const
00783 {
00784 return ((const Locale)*this).getLCID();
00785 }
00786
00787 inline UnicodeString& Locale::LocaleProxy::getDisplayLanguage(UnicodeString& dispLang) const
00788 {
00789 return ((const Locale)*this).getDisplayLanguage(dispLang);
00790 }
00791
00792 inline UnicodeString& Locale::LocaleProxy::getDisplayLanguage( const Locale& inLocale,
00793 UnicodeString& dispLang) const
00794 {
00795 return ((const Locale)*this).getDisplayLanguage(inLocale, dispLang);
00796 }
00797
00798 inline UnicodeString& Locale::LocaleProxy::getDisplayCountry(UnicodeString& dispCountry) const
00799 {
00800 return ((const Locale)*this).getDisplayCountry(dispCountry);
00801 }
00802
00803 inline UnicodeString& Locale::LocaleProxy::getDisplayCountry(const Locale& inLocale,
00804 UnicodeString& dispCountry) const
00805 {
00806 return ((const Locale)*this).getDisplayCountry(inLocale, dispCountry);
00807 }
00808
00809 inline UnicodeString& Locale::LocaleProxy::getDisplayVariant(UnicodeString& dispVar) const
00810 {
00811 return ((const Locale)*this).getDisplayVariant(dispVar);
00812 }
00813
00814 inline UnicodeString& Locale::LocaleProxy::getDisplayVariant(const Locale& inLocale,
00815 UnicodeString& dispVar) const
00816 {
00817 return ((const Locale)*this).getDisplayVariant(inLocale, dispVar);
00818 }
00819
00820 inline UnicodeString& Locale::LocaleProxy::getDisplayName(UnicodeString& name) const
00821 {
00822 return ((const Locale)*this).getDisplayName(name);
00823 }
00824
00825 inline UnicodeString& Locale::LocaleProxy::getDisplayName(const Locale& inLocale,
00826 UnicodeString& name) const
00827 {
00828 return ((const Locale)*this).getDisplayName(inLocale, name);
00829 }
00830
00831 inline int32_t Locale::LocaleProxy::hashCode(void) const
00832 {
00833 return ((const Locale)*this).hashCode();
00834 }
00835 #endif
00836 U_NAMESPACE_END
00837
00838 #endif