Go to the documentation of this file.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
00180 U_NAMESPACE_BEGIN
00181 class U_COMMON_API Locale : public UObject {
00182 public:
00184 static const Locale &U_EXPORT2 getRoot(void);
00186 static const Locale &U_EXPORT2 getEnglish(void);
00188 static const Locale &U_EXPORT2 getFrench(void);
00190 static const Locale &U_EXPORT2 getGerman(void);
00192 static const Locale &U_EXPORT2 getItalian(void);
00194 static const Locale &U_EXPORT2 getJapanese(void);
00196 static const Locale &U_EXPORT2 getKorean(void);
00198 static const Locale &U_EXPORT2 getChinese(void);
00200 static const Locale &U_EXPORT2 getSimplifiedChinese(void);
00202 static const Locale &U_EXPORT2 getTraditionalChinese(void);
00203
00205 static const Locale &U_EXPORT2 getFrance(void);
00207 static const Locale &U_EXPORT2 getGermany(void);
00209 static const Locale &U_EXPORT2 getItaly(void);
00211 static const Locale &U_EXPORT2 getJapan(void);
00213 static const Locale &U_EXPORT2 getKorea(void);
00215 static const Locale &U_EXPORT2 getChina(void);
00217 static const Locale &U_EXPORT2 getPRC(void);
00219 static const Locale &U_EXPORT2 getTaiwan(void);
00221 static const Locale &U_EXPORT2 getUK(void);
00223 static const Locale &U_EXPORT2 getUS(void);
00225 static const Locale &U_EXPORT2 getCanada(void);
00227 static const Locale &U_EXPORT2 getCanadaFrench(void);
00228
00229
00237 Locale();
00238
00263 Locale( const char * language,
00264 const char * country = 0,
00265 const char * variant = 0,
00266 const char * keywordsAndValues = 0);
00267
00274 Locale(const Locale& other);
00275
00276
00281 virtual ~Locale() ;
00282
00290 Locale& operator=(const Locale& other);
00291
00299 UBool operator==(const Locale& other) const;
00300
00309 UBool operator!=(const Locale& other) const;
00310
00322 Locale *clone() const;
00323
00339 static const Locale& U_EXPORT2 getDefault(void);
00340
00353 static void U_EXPORT2 setDefault(const Locale& newLocale,
00354 UErrorCode& success);
00355
00365 static Locale U_EXPORT2 createFromName(const char *name);
00366
00375 static Locale U_EXPORT2 createCanonical(const char* name);
00376
00382 inline const char * getLanguage( ) const;
00383
00391 inline const char * getScript( ) const;
00392
00398 inline const char * getCountry( ) const;
00399
00405 inline const char * getVariant( ) const;
00406
00415 inline const char * getName() const;
00416
00424 const char * getBaseName() const;
00425
00426
00435 StringEnumeration * createKeywords(UErrorCode &status) const;
00436
00448 int32_t getKeywordValue(const char* keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const;
00449
00461 void setKeywordValue(const char* keywordName, const char* keywordValue, UErrorCode &status);
00462
00469 const char * getISO3Language() const;
00470
00476 const char * getISO3Country() const;
00477
00485 uint32_t getLCID(void) const;
00486
00496 UnicodeString& getDisplayLanguage(UnicodeString& dispLang) const;
00497
00511 UnicodeString& getDisplayLanguage( const Locale& displayLocale,
00512 UnicodeString& dispLang) const;
00513
00523 UnicodeString& getDisplayScript( UnicodeString& dispScript) const;
00524
00539 UnicodeString& getDisplayScript( const Locale& displayLocale,
00540 UnicodeString& dispScript) const;
00541
00551 UnicodeString& getDisplayCountry( UnicodeString& dispCountry) const;
00552
00567 UnicodeString& getDisplayCountry( const Locale& displayLocale,
00568 UnicodeString& dispCountry) const;
00569
00577 UnicodeString& getDisplayVariant( UnicodeString& dispVar) const;
00578
00587 UnicodeString& getDisplayVariant( const Locale& displayLocale,
00588 UnicodeString& dispVar) const;
00589
00601 UnicodeString& getDisplayName( UnicodeString& name) const;
00602
00615 UnicodeString& getDisplayName( const Locale& displayLocale,
00616 UnicodeString& name) const;
00617
00622 int32_t hashCode(void) const;
00623
00632 void setToBogus();
00633
00639 UBool isBogus(void) const;
00640
00649 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
00650
00659 static const char* const* U_EXPORT2 getISOCountries();
00660
00669 static const char* const* U_EXPORT2 getISOLanguages();
00670
00676 static UClassID U_EXPORT2 getStaticClassID();
00677
00683 virtual UClassID getDynamicClassID() const;
00684
00685 protected:
00690 void setFromPOSIXID(const char *posixID);
00691
00692 private:
00699 Locale& init(const char* cLocaleID, UBool canonicalize);
00700
00701
00702
00703
00704
00705
00706 enum ELocaleType {
00707 eBOGUS
00708 };
00709 Locale(ELocaleType);
00710
00714 static Locale *getLocaleCache(void);
00715
00716 char language[ULOC_LANG_CAPACITY];
00717 char script[ULOC_SCRIPT_CAPACITY];
00718 char country[ULOC_COUNTRY_CAPACITY];
00719 int32_t variantBegin;
00720 char* fullName;
00721 char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
00722
00723 char* baseName;
00724 char baseNameBuffer[ULOC_FULLNAME_CAPACITY];
00725
00726 UBool fIsBogus;
00727
00728 static const Locale &getLocale(int locid);
00729
00734 friend void locale_set_default_internal(const char *);
00735 };
00736
00737 inline UBool
00738 Locale::operator!=(const Locale& other) const
00739 {
00740 return !operator==(other);
00741 }
00742
00743 inline const char *
00744 Locale::getCountry() const
00745 {
00746 return country;
00747 }
00748
00749 inline const char *
00750 Locale::getLanguage() const
00751 {
00752 return language;
00753 }
00754
00755 inline const char *
00756 Locale::getScript() const
00757 {
00758 return script;
00759 }
00760
00761 inline const char *
00762 Locale::getVariant() const
00763 {
00764 getBaseName();
00765 return &baseName[variantBegin];
00766 }
00767
00768 inline const char *
00769 Locale::getName() const
00770 {
00771 return fullName;
00772 }
00773
00774 inline UBool
00775 Locale::isBogus(void) const {
00776 return fIsBogus;
00777 }
00778
00779 U_NAMESPACE_END
00780
00781 #endif