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 #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;
00204 static const Locale PRC;
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;
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
00267 static const LocaleProxy ENGLISH;
00268
00269 static const LocaleProxy FRENCH;
00270
00271 static const LocaleProxy GERMAN;
00272
00273 static const LocaleProxy ITALIAN;
00274
00275 static const LocaleProxy JAPANESE;
00276
00277 static const LocaleProxy KOREAN;
00278
00279 static const LocaleProxy CHINESE;
00280
00281 static const LocaleProxy SIMPLIFIED_CHINESE;
00282
00283 static const LocaleProxy TRADITIONAL_CHINESE;
00284
00288
00289 static const LocaleProxy FRANCE;
00290
00291 static const LocaleProxy GERMANY;
00292
00293 static const LocaleProxy ITALY;
00294
00295 static const LocaleProxy JAPAN;
00296
00297 static const LocaleProxy KOREA;
00298
00299 static const LocaleProxy CHINA;
00300
00301 static const LocaleProxy PRC;
00302
00303 static const LocaleProxy TAIWAN;
00304
00305 static const LocaleProxy UK;
00306
00307 static const LocaleProxy US;
00308
00309 static const LocaleProxy CANADA;
00310
00311 static const LocaleProxy CANADA_FRENCH;
00312
00313 #endif
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
00634 void setBogus(UBool isBogus);
00635
00641 UBool isBogus(void) const;
00642
00651 static const Locale* getAvailableLocales(int32_t& count);
00652
00661 static const char* const* getISOCountries();
00662
00671 static const char* const* getISOLanguages();
00672
00673 protected:
00675 void setFromPOSIXID(const char *posixID);
00676
00677 private:
00684 Locale& init(const char* cLocaleID);
00685
00689 static void initLocaleCache(void);
00690
00691 char language[ULOC_LANG_CAPACITY];
00692 char country[ULOC_COUNTRY_CAPACITY];
00693 int32_t variantBegin;
00694 char* fullName;
00695 char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
00696
00697 UBool fIsBogus;
00698
00699
00700
00701
00702 #ifdef ICU_LOCID_USE_DEPRECATES
00703 static Locale fgDefaultLocale;
00704 #else
00705 friend struct LocaleProxy;
00706 #endif
00707
00708 static const Locale &getLocale(int locid);
00709
00710 friend void locale_set_default_internal(const char *);
00711 };
00712
00713 inline UBool
00714 Locale::operator!=(const Locale& other) const
00715 {
00716 return !operator==(other);
00717 }
00718
00719 inline const char *
00720 Locale::getCountry() const
00721 {
00722 return country;
00723 }
00724
00725 inline const char *
00726 Locale::getLanguage() const
00727 {
00728 return language;
00729 }
00730
00731 inline const char *
00732 Locale::getVariant() const
00733 {
00734 return &fullName[variantBegin];
00735 }
00736
00737 inline const char *
00738 Locale::getName() const
00739 {
00740 return fullName;
00741 }
00742
00743 inline void
00744 Locale::setBogus(UBool isBogus) {
00745 fIsBogus = isBogus;
00746 }
00747
00748
00749 inline UBool
00750 Locale::isBogus(void) const {
00751 return fIsBogus;
00752 }
00753
00754 #ifndef ICU_LOCID_USE_DEPRECATES
00755
00756 inline const char *Locale::LocaleProxy::getLanguage( ) const
00757 {
00758 return ((const Locale)*this).getLanguage();
00759 }
00760
00761 inline const char *Locale::LocaleProxy::getCountry( ) const
00762 {
00763 return ((const Locale)*this).getCountry();
00764 }
00765
00766 inline const char *Locale::LocaleProxy::getVariant( ) const
00767 {
00768 return ((const Locale)*this).getVariant();
00769 }
00770
00771 inline const char *Locale::LocaleProxy::getName() const
00772 {
00773 return ((const Locale)*this).getName();
00774 }
00775
00776 inline const char *Locale::LocaleProxy::getISO3Language() const
00777 {
00778 return ((const Locale)*this).getISO3Language();
00779 }
00780
00781 inline const char *Locale::LocaleProxy::getISO3Country() const
00782 {
00783 return ((const Locale)*this).getISO3Country();
00784 }
00785
00786 inline uint32_t Locale::LocaleProxy::getLCID(void) const
00787 {
00788 return ((const Locale)*this).getLCID();
00789 }
00790
00791 inline UnicodeString& Locale::LocaleProxy::getDisplayLanguage(UnicodeString& dispLang) const
00792 {
00793 return ((const Locale)*this).getDisplayLanguage(dispLang);
00794 }
00795
00796 inline UnicodeString& Locale::LocaleProxy::getDisplayLanguage( const Locale& inLocale,
00797 UnicodeString& dispLang) const
00798 {
00799 return ((const Locale)*this).getDisplayLanguage(inLocale, dispLang);
00800 }
00801
00802 inline UnicodeString& Locale::LocaleProxy::getDisplayCountry(UnicodeString& dispCountry) const
00803 {
00804 return ((const Locale)*this).getDisplayCountry(dispCountry);
00805 }
00806
00807 inline UnicodeString& Locale::LocaleProxy::getDisplayCountry(const Locale& inLocale,
00808 UnicodeString& dispCountry) const
00809 {
00810 return ((const Locale)*this).getDisplayCountry(inLocale, dispCountry);
00811 }
00812
00813 inline UnicodeString& Locale::LocaleProxy::getDisplayVariant(UnicodeString& dispVar) const
00814 {
00815 return ((const Locale)*this).getDisplayVariant(dispVar);
00816 }
00817
00818 inline UnicodeString& Locale::LocaleProxy::getDisplayVariant(const Locale& inLocale,
00819 UnicodeString& dispVar) const
00820 {
00821 return ((const Locale)*this).getDisplayVariant(inLocale, dispVar);
00822 }
00823
00824 inline UnicodeString& Locale::LocaleProxy::getDisplayName(UnicodeString& name) const
00825 {
00826 return ((const Locale)*this).getDisplayName(name);
00827 }
00828
00829 inline UnicodeString& Locale::LocaleProxy::getDisplayName(const Locale& inLocale,
00830 UnicodeString& name) const
00831 {
00832 return ((const Locale)*this).getDisplayName(inLocale, name);
00833 }
00834
00835 inline int32_t Locale::LocaleProxy::hashCode(void) const
00836 {
00837 return ((const Locale)*this).hashCode();
00838 }
00839 #endif
00840 U_NAMESPACE_END
00841
00842 #endif
00843 #endif
00844