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
00030
00031 #ifndef LOCID_H
00032 #define LOCID_H
00033
00034 #include "unicode/utypes.h"
00035 #include "unicode/uobject.h"
00036 #include "unicode/putil.h"
00037 #include "unicode/uloc.h"
00038
00044 U_NAMESPACE_BEGIN
00045
00046
00047 void U_CALLCONV locale_available_init();
00049 class StringEnumeration;
00050 class UnicodeString;
00051
00188 class U_COMMON_API Locale : public UObject {
00189 public:
00191 static const Locale &U_EXPORT2 getRoot(void);
00193 static const Locale &U_EXPORT2 getEnglish(void);
00195 static const Locale &U_EXPORT2 getFrench(void);
00197 static const Locale &U_EXPORT2 getGerman(void);
00199 static const Locale &U_EXPORT2 getItalian(void);
00201 static const Locale &U_EXPORT2 getJapanese(void);
00203 static const Locale &U_EXPORT2 getKorean(void);
00205 static const Locale &U_EXPORT2 getChinese(void);
00207 static const Locale &U_EXPORT2 getSimplifiedChinese(void);
00209 static const Locale &U_EXPORT2 getTraditionalChinese(void);
00210
00212 static const Locale &U_EXPORT2 getFrance(void);
00214 static const Locale &U_EXPORT2 getGermany(void);
00216 static const Locale &U_EXPORT2 getItaly(void);
00218 static const Locale &U_EXPORT2 getJapan(void);
00220 static const Locale &U_EXPORT2 getKorea(void);
00222 static const Locale &U_EXPORT2 getChina(void);
00224 static const Locale &U_EXPORT2 getPRC(void);
00226 static const Locale &U_EXPORT2 getTaiwan(void);
00228 static const Locale &U_EXPORT2 getUK(void);
00230 static const Locale &U_EXPORT2 getUS(void);
00232 static const Locale &U_EXPORT2 getCanada(void);
00234 static const Locale &U_EXPORT2 getCanadaFrench(void);
00235
00236
00244 Locale();
00245
00270 Locale( const char * language,
00271 const char * country = 0,
00272 const char * variant = 0,
00273 const char * keywordsAndValues = 0);
00274
00281 Locale(const Locale& other);
00282
00283
00288 virtual ~Locale() ;
00289
00297 Locale& operator=(const Locale& other);
00298
00306 UBool operator==(const Locale& other) const;
00307
00316 UBool operator!=(const Locale& other) const;
00317
00329 Locale *clone() const;
00330
00331 #ifndef U_HIDE_SYSTEM_API
00332
00347 static const Locale& U_EXPORT2 getDefault(void);
00348
00361 static void U_EXPORT2 setDefault(const Locale& newLocale,
00362 UErrorCode& success);
00363 #endif
00364
00374 static Locale U_EXPORT2 createFromName(const char *name);
00375
00384 static Locale U_EXPORT2 createCanonical(const char* name);
00385
00391 inline const char * getLanguage( ) const;
00392
00400 inline const char * getScript( ) const;
00401
00407 inline const char * getCountry( ) const;
00408
00414 inline const char * getVariant( ) const;
00415
00424 inline const char * getName() const;
00425
00433 const char * getBaseName() const;
00434
00435
00444 StringEnumeration * createKeywords(UErrorCode &status) const;
00445
00457 int32_t getKeywordValue(const char* keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const;
00458
00473 void setKeywordValue(const char* keywordName, const char* keywordValue, UErrorCode &status);
00474
00481 const char * getISO3Language() const;
00482
00488 const char * getISO3Country() const;
00489
00497 uint32_t getLCID(void) const;
00498
00512 UBool isRightToLeft() const;
00513
00523 UnicodeString& getDisplayLanguage(UnicodeString& dispLang) const;
00524
00538 UnicodeString& getDisplayLanguage( const Locale& displayLocale,
00539 UnicodeString& dispLang) const;
00540
00550 UnicodeString& getDisplayScript( UnicodeString& dispScript) const;
00551
00566 UnicodeString& getDisplayScript( const Locale& displayLocale,
00567 UnicodeString& dispScript) const;
00568
00578 UnicodeString& getDisplayCountry( UnicodeString& dispCountry) const;
00579
00594 UnicodeString& getDisplayCountry( const Locale& displayLocale,
00595 UnicodeString& dispCountry) const;
00596
00604 UnicodeString& getDisplayVariant( UnicodeString& dispVar) const;
00605
00614 UnicodeString& getDisplayVariant( const Locale& displayLocale,
00615 UnicodeString& dispVar) const;
00616
00628 UnicodeString& getDisplayName( UnicodeString& name) const;
00629
00642 UnicodeString& getDisplayName( const Locale& displayLocale,
00643 UnicodeString& name) const;
00644
00649 int32_t hashCode(void) const;
00650
00659 void setToBogus();
00660
00666 UBool isBogus(void) const;
00667
00676 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
00677
00686 static const char* const* U_EXPORT2 getISOCountries();
00687
00696 static const char* const* U_EXPORT2 getISOLanguages();
00697
00703 static UClassID U_EXPORT2 getStaticClassID();
00704
00710 virtual UClassID getDynamicClassID() const;
00711
00712 protected:
00713 #ifndef U_HIDE_INTERNAL_API
00714
00718 void setFromPOSIXID(const char *posixID);
00719 #endif
00720
00721 private:
00729 Locale& init(const char* cLocaleID, UBool canonicalize);
00730
00731
00732
00733
00734
00735
00736 enum ELocaleType {
00737 eBOGUS
00738 };
00739 Locale(ELocaleType);
00740
00744 static Locale *getLocaleCache(void);
00745
00746 char language[ULOC_LANG_CAPACITY];
00747 char script[ULOC_SCRIPT_CAPACITY];
00748 char country[ULOC_COUNTRY_CAPACITY];
00749 int32_t variantBegin;
00750 char* fullName;
00751 char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
00752
00753 char* baseName;
00754 void initBaseName(UErrorCode& status);
00755
00756 UBool fIsBogus;
00757
00758 static const Locale &getLocale(int locid);
00759
00764 friend Locale *locale_set_default_internal(const char *, UErrorCode& status);
00765
00769 friend void U_CALLCONV locale_available_init();
00770 };
00771
00772 inline UBool
00773 Locale::operator!=(const Locale& other) const
00774 {
00775 return !operator==(other);
00776 }
00777
00778 inline const char *
00779 Locale::getCountry() const
00780 {
00781 return country;
00782 }
00783
00784 inline const char *
00785 Locale::getLanguage() const
00786 {
00787 return language;
00788 }
00789
00790 inline const char *
00791 Locale::getScript() const
00792 {
00793 return script;
00794 }
00795
00796 inline const char *
00797 Locale::getVariant() const
00798 {
00799 return &baseName[variantBegin];
00800 }
00801
00802 inline const char *
00803 Locale::getName() const
00804 {
00805 return fullName;
00806 }
00807
00808 inline UBool
00809 Locale::isBogus(void) const {
00810 return fIsBogus;
00811 }
00812
00813 U_NAMESPACE_END
00814
00815 #endif