Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

locid.h

Go to the documentation of this file.
00001 /* 00002 ****************************************************************************** 00003 * 00004 * Copyright (C) 1996-2003, International Business Machines 00005 * Corporation and others. All Rights Reserved. 00006 * 00007 ****************************************************************************** 00008 * 00009 * File locid.h 00010 * 00011 * Created by: Helena Shih 00012 * 00013 * Modification History: 00014 * 00015 * Date Name Description 00016 * 02/11/97 aliu Changed gLocPath to fgLocPath and added methods to 00017 * get and set it. 00018 * 04/02/97 aliu Made operator!= inline; fixed return value of getName(). 00019 * 04/15/97 aliu Cleanup for AIX/Win32. 00020 * 04/24/97 aliu Numerous changes per code review. 00021 * 08/18/98 stephen Added tokenizeString(),changed getDisplayName() 00022 * 09/08/98 stephen Moved definition of kEmptyString for Mac Port 00023 * 11/09/99 weiv Added const char * getName() const; 00024 * 04/12/00 srl removing unicodestring api's and cached hash code 00025 * 08/10/01 grhoten Change the static Locales to accessor functions 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 &getEnglish(void); 00186 static const Locale &getFrench(void); 00188 static const Locale &getGerman(void); 00190 static const Locale &getItalian(void); 00192 static const Locale &getJapanese(void); 00194 static const Locale &getKorean(void); 00196 static const Locale &getChinese(void); 00198 static const Locale &getSimplifiedChinese(void); 00200 static const Locale &getTraditionalChinese(void); 00201 00203 static const Locale &getFrance(void); 00205 static const Locale &getGermany(void); 00207 static const Locale &getItaly(void); 00209 static const Locale &getJapan(void); 00211 static const Locale &getKorea(void); 00213 static const Locale &getChina(void); 00215 static const Locale &getPRC(void); 00217 static const Locale &getTaiwan(void); 00219 static const Locale &getUK(void); 00221 static const Locale &getUS(void); 00223 static const Locale &getCanada(void); 00225 static const Locale &getCanadaFrench(void); 00226 00227 00235 Locale(); 00236 00261 Locale( const char * language, 00262 const char * country = 0, 00263 const char * variant = 0, 00264 const char * keywordsAndValues = 0); 00265 00272 Locale(const Locale& other); 00273 00274 00279 ~Locale() ; 00280 00288 Locale& operator=(const Locale& other); 00289 00297 UBool operator==(const Locale& other) const; 00298 00307 UBool operator!=(const Locale& other) const; 00308 00320 Locale *clone() const; 00321 00337 static const Locale& getDefault(void); 00338 00351 static void setDefault(const Locale& newLocale, 00352 UErrorCode& success); 00353 00354 00364 static Locale createFromName(const char *name); 00365 00366 00372 inline const char * getLanguage( ) const; 00373 00381 inline const char * getScript( ) const; 00382 00388 inline const char * getCountry( ) const; 00389 00395 inline const char * getVariant( ) const; 00396 00405 inline const char * getName() const; 00406 00414 const char * getBaseName() const; 00415 00416 00424 StringEnumeration * createKeywords(UErrorCode &status) const; 00425 00436 int32_t getKeywordValue(const char* keywordName, char *buffer, int32_t bufLen, UErrorCode &status) const; 00437 00444 const char * getISO3Language() const; 00445 00451 const char * getISO3Country() const; 00452 00460 uint32_t getLCID(void) const; 00461 00471 UnicodeString& getDisplayLanguage(UnicodeString& dispLang) const; 00472 00486 UnicodeString& getDisplayLanguage( const Locale& displayLocale, 00487 UnicodeString& dispLang) const; 00488 00498 UnicodeString& getDisplayScript( UnicodeString& dispScript) const; 00499 00514 UnicodeString& getDisplayScript( const Locale& displayLocale, 00515 UnicodeString& dispScript) const; 00516 00526 UnicodeString& getDisplayCountry( UnicodeString& dispCountry) const; 00527 00542 UnicodeString& getDisplayCountry( const Locale& displayLocale, 00543 UnicodeString& dispCountry) const; 00544 00552 UnicodeString& getDisplayVariant( UnicodeString& dispVar) const; 00553 00562 UnicodeString& getDisplayVariant( const Locale& displayLocale, 00563 UnicodeString& dispVar) const; 00564 00576 UnicodeString& getDisplayName( UnicodeString& name) const; 00577 00590 UnicodeString& getDisplayName( const Locale& displayLocale, 00591 UnicodeString& name) const; 00592 00597 int32_t hashCode(void) const; 00598 00607 void setToBogus(); 00608 00614 UBool isBogus(void) const; 00615 00624 static const Locale* getAvailableLocales(int32_t& count); 00625 00634 static const char* const* getISOCountries(); 00635 00644 static const char* const* getISOLanguages(); 00645 00651 static UClassID getStaticClassID(); 00652 00658 virtual UClassID getDynamicClassID() const; 00659 00660 protected: /* only protected for testing purposes. DO NOT USE. */ 00665 void setFromPOSIXID(const char *posixID); 00666 00667 private: 00674 Locale& init(const char* cLocaleID); 00675 00676 /* 00677 * Internal constructor to allow construction of a locale object with 00678 * NO side effects. (Default constructor tries to get 00679 * the default locale.) 00680 */ 00681 enum ELocaleType { 00682 eBOGUS 00683 }; 00684 Locale(ELocaleType); 00685 00689 static Locale *getLocaleCache(void); 00690 00691 char language[ULOC_LANG_CAPACITY]; 00692 char script[ULOC_SCRIPT_CAPACITY]; 00693 char country[ULOC_COUNTRY_CAPACITY]; 00694 int32_t variantBegin; 00695 char* fullName; 00696 char fullNameBuffer[ULOC_FULLNAME_CAPACITY]; 00697 // name without keywords 00698 char* baseName; 00699 char baseNameBuffer[ULOC_FULLNAME_CAPACITY]; 00700 00701 UBool fIsBogus; 00702 00703 static const Locale &getLocale(int locid); 00704 00709 friend void locale_set_default_internal(const char *); 00710 }; 00711 00712 inline UBool 00713 Locale::operator!=(const Locale& other) const 00714 { 00715 return !operator==(other); 00716 } 00717 00718 inline const char * 00719 Locale::getCountry() const 00720 { 00721 return country; 00722 } 00723 00724 inline const char * 00725 Locale::getLanguage() const 00726 { 00727 return language; 00728 } 00729 00730 inline const char * 00731 Locale::getScript() const 00732 { 00733 return script; 00734 } 00735 00736 inline const char * 00737 Locale::getVariant() const 00738 { 00739 return &fullName[variantBegin]; 00740 } 00741 00742 inline const char * 00743 Locale::getName() const 00744 { 00745 return fullName; 00746 } 00747 00748 inline UBool 00749 Locale::isBogus(void) const { 00750 return fIsBogus; 00751 } 00752 00753 U_NAMESPACE_END 00754 00755 #endif 00756

Generated on Wed Jul 28 09:15:54 2004 for ICU 2.8 by doxygen 1.3.7