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
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;
00206 static const Locale PRC;
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;
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
00269 static const LocaleProxy ENGLISH;
00270
00271 static const LocaleProxy FRENCH;
00272
00273 static const LocaleProxy GERMAN;
00274
00275 static const LocaleProxy ITALIAN;
00276
00277 static const LocaleProxy JAPANESE;
00278
00279 static const LocaleProxy KOREAN;
00280
00281 static const LocaleProxy CHINESE;
00282
00283 static const LocaleProxy SIMPLIFIED_CHINESE;
00284
00285 static const LocaleProxy TRADITIONAL_CHINESE;
00286
00290
00291 static const LocaleProxy FRANCE;
00292
00293 static const LocaleProxy GERMANY;
00294
00295 static const LocaleProxy ITALY;
00296
00297 static const LocaleProxy JAPAN;
00298
00299 static const LocaleProxy KOREA;
00300
00301 static const LocaleProxy CHINA;
00302
00303 static const LocaleProxy PRC;
00304
00305 static const LocaleProxy TAIWAN;
00306
00307 static const LocaleProxy UK;
00308
00309 static const LocaleProxy US;
00310
00311 static const LocaleProxy CANADA;
00312
00313 static const LocaleProxy CANADA_FRENCH;
00314
00315 #endif
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:
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
00686
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
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
00815 U_NAMESPACE_END
00816
00817 #endif
00818 #endif
00819