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 #include "unicode/strenum.h"
00038
00044 U_NAMESPACE_BEGIN
00045
00046
00047 void U_CALLCONV locale_available_init();
00185 class U_COMMON_API Locale : public UObject {
00186 public:
00188 static const Locale &U_EXPORT2 getRoot(void);
00190 static const Locale &U_EXPORT2 getEnglish(void);
00192 static const Locale &U_EXPORT2 getFrench(void);
00194 static const Locale &U_EXPORT2 getGerman(void);
00196 static const Locale &U_EXPORT2 getItalian(void);
00198 static const Locale &U_EXPORT2 getJapanese(void);
00200 static const Locale &U_EXPORT2 getKorean(void);
00202 static const Locale &U_EXPORT2 getChinese(void);
00204 static const Locale &U_EXPORT2 getSimplifiedChinese(void);
00206 static const Locale &U_EXPORT2 getTraditionalChinese(void);
00207
00209 static const Locale &U_EXPORT2 getFrance(void);
00211 static const Locale &U_EXPORT2 getGermany(void);
00213 static const Locale &U_EXPORT2 getItaly(void);
00215 static const Locale &U_EXPORT2 getJapan(void);
00217 static const Locale &U_EXPORT2 getKorea(void);
00219 static const Locale &U_EXPORT2 getChina(void);
00221 static const Locale &U_EXPORT2 getPRC(void);
00223 static const Locale &U_EXPORT2 getTaiwan(void);
00225 static const Locale &U_EXPORT2 getUK(void);
00227 static const Locale &U_EXPORT2 getUS(void);
00229 static const Locale &U_EXPORT2 getCanada(void);
00231 static const Locale &U_EXPORT2 getCanadaFrench(void);
00232
00233
00241 Locale();
00242
00267 Locale( const char * language,
00268 const char * country = 0,
00269 const char * variant = 0,
00270 const char * keywordsAndValues = 0);
00271
00278 Locale(const Locale& other);
00279
00280
00285 virtual ~Locale() ;
00286
00294 Locale& operator=(const Locale& other);
00295
00303 UBool operator==(const Locale& other) const;
00304
00313 UBool operator!=(const Locale& other) const;
00314
00326 Locale *clone() const;
00327
00328 #ifndef U_HIDE_SYSTEM_API
00329
00344 static const Locale& U_EXPORT2 getDefault(void);
00345
00358 static void U_EXPORT2 setDefault(const Locale& newLocale,
00359 UErrorCode& success);
00360 #endif
00361
00371 static Locale U_EXPORT2 createFromName(const char *name);
00372
00381 static Locale U_EXPORT2 createCanonical(const char* name);
00382
00388 inline const char * getLanguage( ) const;
00389
00397 inline const char * getScript( ) const;
00398
00404 inline const char * getCountry( ) const;
00405
00411 inline const char * getVariant( ) const;
00412
00421 inline const char * getName() const;
00422
00430 const char * getBaseName() const;
00431
00432
00441 StringEnumeration * createKeywords(UErrorCode &status) const;
00442
00454 int32_t getKeywordValue(const char* keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const;
00455
00470 void setKeywordValue(const char* keywordName, const char* keywordValue, UErrorCode &status);
00471
00478 const char * getISO3Language() const;
00479
00485 const char * getISO3Country() const;
00486
00494 uint32_t getLCID(void) const;
00495
00509 UBool isRightToLeft() const;
00510
00520 UnicodeString& getDisplayLanguage(UnicodeString& dispLang) const;
00521
00535 UnicodeString& getDisplayLanguage( const Locale& displayLocale,
00536 UnicodeString& dispLang) const;
00537
00547 UnicodeString& getDisplayScript( UnicodeString& dispScript) const;
00548
00563 UnicodeString& getDisplayScript( const Locale& displayLocale,
00564 UnicodeString& dispScript) const;
00565
00575 UnicodeString& getDisplayCountry( UnicodeString& dispCountry) const;
00576
00591 UnicodeString& getDisplayCountry( const Locale& displayLocale,
00592 UnicodeString& dispCountry) const;
00593
00601 UnicodeString& getDisplayVariant( UnicodeString& dispVar) const;
00602
00611 UnicodeString& getDisplayVariant( const Locale& displayLocale,
00612 UnicodeString& dispVar) const;
00613
00625 UnicodeString& getDisplayName( UnicodeString& name) const;
00626
00639 UnicodeString& getDisplayName( const Locale& displayLocale,
00640 UnicodeString& name) const;
00641
00646 int32_t hashCode(void) const;
00647
00656 void setToBogus();
00657
00663 UBool isBogus(void) const;
00664
00673 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
00674
00683 static const char* const* U_EXPORT2 getISOCountries();
00684
00693 static const char* const* U_EXPORT2 getISOLanguages();
00694
00700 static UClassID U_EXPORT2 getStaticClassID();
00701
00707 virtual UClassID getDynamicClassID() const;
00708
00709 protected:
00710 #ifndef U_HIDE_INTERNAL_API
00711
00715 void setFromPOSIXID(const char *posixID);
00716 #endif
00717
00718 private:
00726 Locale& init(const char* cLocaleID, UBool canonicalize);
00727
00728
00729
00730
00731
00732
00733 enum ELocaleType {
00734 eBOGUS
00735 };
00736 Locale(ELocaleType);
00737
00741 static Locale *getLocaleCache(void);
00742
00743 char language[ULOC_LANG_CAPACITY];
00744 char script[ULOC_SCRIPT_CAPACITY];
00745 char country[ULOC_COUNTRY_CAPACITY];
00746 int32_t variantBegin;
00747 char* fullName;
00748 char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
00749
00750 char* baseName;
00751 void initBaseName(UErrorCode& status);
00752
00753 UBool fIsBogus;
00754
00755 static const Locale &getLocale(int locid);
00756
00761 friend Locale *locale_set_default_internal(const char *, UErrorCode& status);
00762
00766 friend void U_CALLCONV locale_available_init();
00767 };
00768
00769 inline UBool
00770 Locale::operator!=(const Locale& other) const
00771 {
00772 return !operator==(other);
00773 }
00774
00775 inline const char *
00776 Locale::getCountry() const
00777 {
00778 return country;
00779 }
00780
00781 inline const char *
00782 Locale::getLanguage() const
00783 {
00784 return language;
00785 }
00786
00787 inline const char *
00788 Locale::getScript() const
00789 {
00790 return script;
00791 }
00792
00793 inline const char *
00794 Locale::getVariant() const
00795 {
00796 return &baseName[variantBegin];
00797 }
00798
00799 inline const char *
00800 Locale::getName() const
00801 {
00802 return fullName;
00803 }
00804
00805 inline UBool
00806 Locale::isBogus(void) const {
00807 return fIsBogus;
00808 }
00809
00810 U_NAMESPACE_END
00811
00812 #endif