- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- Search for |

- File List
- Globals

# locid.h

Go to the documentation of this file.

    00001 /*
    00002 ******************************************************************************
    00003 *
    00004 *   Copyright (C) 1996-2006, 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 &U_EXPORT2 getEnglish(void);
    00186     static const Locale &U_EXPORT2 getFrench(void);
    00188     static const Locale &U_EXPORT2 getGerman(void);
    00190     static const Locale &U_EXPORT2 getItalian(void);
    00192     static const Locale &U_EXPORT2 getJapanese(void);
    00194     static const Locale &U_EXPORT2 getKorean(void);
    00196     static const Locale &U_EXPORT2 getChinese(void);
    00198     static const Locale &U_EXPORT2 getSimplifiedChinese(void);
    00200     static const Locale &U_EXPORT2 getTraditionalChinese(void);
    00201
    00203     static const Locale &U_EXPORT2 getFrance(void);
    00205     static const Locale &U_EXPORT2 getGermany(void);
    00207     static const Locale &U_EXPORT2 getItaly(void);
    00209     static const Locale &U_EXPORT2 getJapan(void);
    00211     static const Locale &U_EXPORT2 getKorea(void);
    00213     static const Locale &U_EXPORT2 getChina(void);
    00215     static const Locale &U_EXPORT2 getPRC(void);
    00217     static const Locale &U_EXPORT2 getTaiwan(void);
    00219     static const Locale &U_EXPORT2 getUK(void);
    00221     static const Locale &U_EXPORT2 getUS(void);
    00223     static const Locale &U_EXPORT2 getCanada(void);
    00225     static const Locale &U_EXPORT2 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     virtual ~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& U_EXPORT2 getDefault(void);
    00338
    00351     static void U_EXPORT2 setDefault(const Locale& newLocale,
    00352                                      UErrorCode&   success);
    00353
    00363     static Locale U_EXPORT2 createFromName(const char *name);
    00364
    00373     static Locale U_EXPORT2 createCanonical(const char* name);
    00374
    00380     inline const char *  getLanguage( ) const;
    00381
    00389     inline const char *  getScript( ) const;
    00390
    00396     inline const char *  getCountry( ) const;
    00397
    00403     inline const char *  getVariant( ) const;
    00404
    00413     inline const char * getName() const;
    00414
    00422     const char * getBaseName() const;
    00423
    00424
    00432     StringEnumeration * createKeywords(UErrorCode &status) const;
    00433
    00445     int32_t getKeywordValue(const char* keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const;
    00446
    00453     const char * getISO3Language() const;
    00454
    00460     const char * getISO3Country() const;
    00461
    00469     uint32_t        getLCID(void) const;
    00470
    00480     UnicodeString&  getDisplayLanguage(UnicodeString&   dispLang) const;
    00481
    00495     UnicodeString&  getDisplayLanguage( const   Locale&         displayLocale,
    00496                                                 UnicodeString&  dispLang) const;
    00497
    00507     UnicodeString&  getDisplayScript(          UnicodeString& dispScript) const;
    00508
    00523     UnicodeString&  getDisplayScript(  const   Locale&         displayLocale,
    00524                                                UnicodeString&  dispScript) const;
    00525
    00535     UnicodeString&  getDisplayCountry(          UnicodeString& dispCountry) const;
    00536
    00551     UnicodeString&  getDisplayCountry(  const   Locale&         displayLocale,
    00552                                                 UnicodeString&  dispCountry) const;
    00553
    00561     UnicodeString&  getDisplayVariant(      UnicodeString& dispVar) const;
    00562
    00571     UnicodeString&  getDisplayVariant(  const   Locale&         displayLocale,
    00572                                                 UnicodeString&  dispVar) const;
    00573
    00585     UnicodeString&  getDisplayName(         UnicodeString&  name) const;
    00586
    00599     UnicodeString&  getDisplayName( const   Locale&         displayLocale,
    00600                                             UnicodeString&  name) const;
    00601
    00606     int32_t         hashCode(void) const;
    00607
    00616     void setToBogus();
    00617
    00623     UBool isBogus(void) const;
    00624
    00633     static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
    00634
    00643     static const char* const* U_EXPORT2 getISOCountries();
    00644
    00653     static const char* const* U_EXPORT2 getISOLanguages();
    00654
    00660     static UClassID U_EXPORT2 getStaticClassID();
    00661
    00667     virtual UClassID getDynamicClassID() const;
    00668
    00669 protected: /* only protected for testing purposes. DO NOT USE. */
    00674     void setFromPOSIXID(const char *posixID);
    00675
    00676 private:
    00683     Locale& init(const char* cLocaleID, UBool canonicalize);
    00684
    00685     /*
    00686      * Internal constructor to allow construction of a locale object with
    00687      *   NO side effects.   (Default constructor tries to get
    00688      *   the default locale.)
    00689      */
    00690     enum ELocaleType {
    00691         eBOGUS
    00692     };
    00693     Locale(ELocaleType);
    00694
    00698     static Locale *getLocaleCache(void);
    00699
    00700     char language[ULOC_LANG_CAPACITY];
    00701     char script[ULOC_SCRIPT_CAPACITY];
    00702     char country[ULOC_COUNTRY_CAPACITY];
    00703     int32_t variantBegin;
    00704     char* fullName;
    00705     char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
    00706     // name without keywords
    00707     char* baseName;
    00708     char baseNameBuffer[ULOC_FULLNAME_CAPACITY];
    00709
    00710     UBool fIsBogus;
    00711
    00712     static const Locale &getLocale(int locid);
    00713
    00718     friend void locale_set_default_internal(const char *);
    00719 };
    00720
    00721 inline UBool
    00722 Locale::operator!=(const    Locale&     other) const
    00723 {
    00724     return !operator==(other);
    00725 }
    00726
    00727 inline const char *
    00728 Locale::getCountry() const
    00729 {
    00730     return country;
    00731 }
    00732
    00733 inline const char *
    00734 Locale::getLanguage() const
    00735 {
    00736     return language;
    00737 }
    00738
    00739 inline const char *
    00740 Locale::getScript() const
    00741 {
    00742     return script;
    00743 }
    00744
    00745 inline const char *
    00746 Locale::getVariant() const
    00747 {
    00748     return &fullName[variantBegin];
    00749 }
    00750
    00751 inline const char *
    00752 Locale::getName() const
    00753 {
    00754     return fullName;
    00755 }
    00756
    00757 inline UBool
    00758 Locale::isBogus(void) const {
    00759     return fIsBogus;
    00760 }
    00761
    00762 U_NAMESPACE_END
    00763
    00764 #endif
    00765