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
00179 U_NAMESPACE_BEGIN
00180 class U_COMMON_API Locale : public UObject {
00181 public:
00183 static const Locale &getEnglish(void);
00185 static const Locale &getFrench(void);
00187 static const Locale &getGerman(void);
00189 static const Locale &getItalian(void);
00191 static const Locale &getJapanese(void);
00193 static const Locale &getKorean(void);
00195 static const Locale &getChinese(void);
00197 static const Locale &getSimplifiedChinese(void);
00199 static const Locale &getTraditionalChinese(void);
00200
00202 static const Locale &getFrance(void);
00204 static const Locale &getGermany(void);
00206 static const Locale &getItaly(void);
00208 static const Locale &getJapan(void);
00210 static const Locale &getKorea(void);
00212 static const Locale &getChina(void);
00214 static const Locale &getPRC(void);
00216 static const Locale &getTaiwan(void);
00218 static const Locale &getUK(void);
00220 static const Locale &getUS(void);
00222 static const Locale &getCanada(void);
00224 static const Locale &getCanadaFrench(void);
00225
00226
00234 Locale();
00235
00258 Locale( const char * language,
00259 const char * country = 0,
00260 const char * variant = 0);
00261
00268 Locale(const Locale& other);
00269
00270
00275 ~Locale() ;
00276
00284 Locale& operator=(const Locale& other);
00285
00293 UBool operator==(const Locale& other) const;
00294
00303 UBool operator!=(const Locale& other) const;
00304
00320 static const Locale& getDefault(void);
00321
00333 static void setDefault(const Locale& newLocale,
00334 UErrorCode& success);
00335
00336
00346 static Locale createFromName(const char *name);
00347
00348
00354 inline const char * getLanguage( ) const;
00355
00361 inline const char * getCountry( ) const;
00362
00368 inline const char * getVariant( ) const;
00369
00378 inline const char * getName() const;
00379
00386 const char * getISO3Language() const;
00387
00393 const char * getISO3Country() const;
00394
00402 uint32_t getLCID(void) const;
00403
00413 UnicodeString& getDisplayLanguage(UnicodeString& dispLang) const;
00414
00428 UnicodeString& getDisplayLanguage( const Locale& inLocale,
00429 UnicodeString& dispLang) const;
00430
00440 UnicodeString& getDisplayCountry( UnicodeString& dispCountry) const;
00441
00456 UnicodeString& getDisplayCountry( const Locale& inLocale,
00457 UnicodeString& dispCountry) const;
00458
00466 UnicodeString& getDisplayVariant( UnicodeString& dispVar) const;
00467
00476 UnicodeString& getDisplayVariant( const Locale& inLocale,
00477 UnicodeString& dispVar) const;
00478
00490 UnicodeString& getDisplayName( UnicodeString& name) const;
00491
00504 UnicodeString& getDisplayName( const Locale& inLocale,
00505 UnicodeString& name) const;
00506
00511 int32_t hashCode(void) const;
00512
00521 void setToBogus();
00522
00528 UBool isBogus(void) const;
00529
00538 static const Locale* getAvailableLocales(int32_t& count);
00539
00548 static const char* const* getISOCountries();
00549
00558 static const char* const* getISOLanguages();
00559
00565 virtual inline UClassID getDynamicClassID() const;
00566
00572 static inline UClassID getStaticClassID();
00573
00574 protected:
00579 void setFromPOSIXID(const char *posixID);
00580
00581 private:
00588 Locale& init(const char* cLocaleID);
00589
00590
00591
00592
00593
00594
00595 enum ELocaleType {
00596 eBOGUS
00597 };
00598 Locale(ELocaleType);
00599
00603 static Locale *getLocaleCache(void);
00604
00605 char language[ULOC_LANG_CAPACITY];
00606 char country[ULOC_COUNTRY_CAPACITY];
00607 int32_t variantBegin;
00608 char* fullName;
00609 char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
00610
00611 UBool fIsBogus;
00612
00617 static const char fgClassID;
00618
00619 static const Locale &getLocale(int locid);
00620
00621 friend void locale_set_default_internal(const char *);
00622 };
00623
00624 inline UClassID
00625 Locale::getStaticClassID()
00626 { return (UClassID)&fgClassID; }
00627
00628 inline UClassID
00629 Locale::getDynamicClassID() const
00630 { return Locale::getStaticClassID(); }
00631
00632 inline UBool
00633 Locale::operator!=(const Locale& other) const
00634 {
00635 return !operator==(other);
00636 }
00637
00638 inline const char *
00639 Locale::getCountry() const
00640 {
00641 return country;
00642 }
00643
00644 inline const char *
00645 Locale::getLanguage() const
00646 {
00647 return language;
00648 }
00649
00650 inline const char *
00651 Locale::getVariant() const
00652 {
00653 return &fullName[variantBegin];
00654 }
00655
00656 inline const char *
00657 Locale::getName() const
00658 {
00659 return fullName;
00660 }
00661
00662 inline UBool
00663 Locale::isBogus(void) const {
00664 return fIsBogus;
00665 }
00666
00667 U_NAMESPACE_END
00668
00669 #endif