Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

locid.h

Go to the documentation of this file.
00001 /*
00002 ******************************************************************************
00003 *
00004 *   Copyright (C) 1996-2001, 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 ******************************************************************************
00026 */
00027 
00028 #ifndef LOCID_H
00029 #define LOCID_H
00030 
00031 
00032 #include "unicode/putil.h"
00033 
00034 #define ULOC_LANG_CAPACITY 12
00035 #define ULOC_COUNTRY_CAPACITY 3
00036 #define ULOC_FULLNAME_CAPACITY 50
00037 
00038 #ifdef XP_CPLUSPLUS
00039 
00040 #include "unicode/unistr.h"
00041 
00042 typedef struct ULocale ULocale;
00043 typedef struct UHashtable UHashtable;
00044 
00177 class U_COMMON_API Locale 
00178 {
00179 public:
00183     static const Locale ENGLISH;
00184     static const Locale FRENCH;
00185     static const Locale GERMAN;
00186     static const Locale ITALIAN;
00187     static const Locale JAPANESE;
00188     static const Locale KOREAN;
00189     static const Locale CHINESE;
00190     static const Locale SIMPLIFIED_CHINESE;
00191     static const Locale TRADITIONAL_CHINESE;
00192 
00196     static const Locale FRANCE;
00197     static const Locale GERMANY;
00198     static const Locale ITALY;
00199     static const Locale JAPAN;
00200     static const Locale KOREA;
00201     static const Locale CHINA;      /* Alias for PRC */
00202     static const Locale PRC;        /* Peoples Republic of China */
00203     static const Locale TAIWAN;
00204     static const Locale UK;
00205     static const Locale US;
00206     static const Locale CANADA;
00207     static const Locale CANADA_FRENCH;
00208 
00214     Locale(); 
00215 
00225     Locale( const   char * language,
00226             const   char * country  = 0, 
00227             const   char * variant  = 0);
00228 
00229 #ifdef ICU_LOCID_USE_DEPRECATES
00230 
00239     Locale( const   UnicodeString&  language, 
00240             const   UnicodeString&  country , 
00241             const   UnicodeString&  variant );
00242 
00250     Locale( const   UnicodeString&  language, 
00251                             const   UnicodeString&  country );
00252 
00259     Locale( const   UnicodeString&  language);
00260 
00261 
00262 #endif /* ICU_LOCID_USE_DEPRECATES */
00263 
00269     Locale(const    Locale& other);
00270 
00271 
00276     ~Locale() ;
00277 
00285     Locale& operator=(const Locale& other);
00286 
00294     UBool   operator==(const    Locale&     other) const;
00295 
00304     UBool   operator!=(const    Locale&     other) const;
00305 
00320     static  Locale& getDefault(void);
00321 
00330     static  void    setDefault(const    Locale&     newLocale,
00331                                                     UErrorCode&  success);
00332 
00333     
00343     static Locale createFromName(const char *name);
00344 
00345     
00351     const char *  getLanguage( ) const;
00352 
00358     const char *  getCountry( ) const;
00359 
00365     const char *  getVariant( ) const;
00366 
00374     const char * getName() const;
00375 
00382     const char * getISO3Language() const;
00383 
00389     const char * getISO3Country() const;
00390 
00391 #ifdef ICU_LOCID_USE_DEPRECATES
00392 /* begin deprecated versions */
00393 
00400                 UnicodeString&    getLanguage(        UnicodeString&  lang) const;
00407                 UnicodeString&   getCountry(         UnicodeString&  cntry) const;
00414                 UnicodeString&  getVariant(         UnicodeString&  var) const;
00415 
00425                 UnicodeString&  getName(        UnicodeString&  name) const;
00426 
00427 
00436                 UnicodeString&  getISO3Language(UnicodeString&  name, UErrorCode& status) const;
00437 
00445                 UnicodeString&  getISO3Country( UnicodeString&  name, UErrorCode& status) const;
00446 
00447 /* END deprecated [ ICU_LOCID_USE_DEPRECATES ] */
00448 #endif /* ICU_LOCID_USE_DEPRECATES */
00449 
00456     uint32_t        getLCID(void) const;
00457 
00467     UnicodeString&  getDisplayLanguage(UnicodeString&   dispLang) const;
00468 
00482     UnicodeString&  getDisplayLanguage( const   Locale&         inLocale,
00483                                                 UnicodeString&  dispLang) const;
00484 
00494     UnicodeString&  getDisplayCountry(          UnicodeString& dispCountry) const;
00495 
00510     UnicodeString&  getDisplayCountry(  const   Locale&         inLocale,
00511                                                 UnicodeString&  dispCountry) const;
00512 
00520     UnicodeString&  getDisplayVariant(      UnicodeString& dispVar) const;
00521 
00530     UnicodeString&  getDisplayVariant(  const   Locale&         inLocale,
00531                                                 UnicodeString&  dispVar) const;
00532 
00544     UnicodeString&  getDisplayName(         UnicodeString&  name) const;
00545 
00558     UnicodeString&  getDisplayName( const   Locale&         inLocale,
00559                                             UnicodeString&  name) const;
00560 
00565     int32_t         hashCode(void) const;
00566 
00575     static  const   Locale*     getAvailableLocales(int32_t& count);
00576 
00585     static const char* const* getISOCountries();
00586 
00595     static const char* const*  getISOLanguages();
00596 
00597 
00598 #ifdef ICU_LOCID_USE_DEPRECATES
00599 
00607     static const UnicodeString* getISOCountries(int32_t& count);
00608 
00620     static const UnicodeString* getISOLanguages(int32_t& count);
00621 #endif /* ICU_LOCID_NO_DEPRECATES */
00622     
00623 protected: /* only protected for testing purposes. DO NOT USE. */
00624     void setFromPOSIXID(const char *posixID); /* set it from a single string. */
00625 
00641     static const UnicodeString* getLanguagesForCountry(const UnicodeString& country, 
00642                                                        int32_t& count);
00643 
00644 
00645 private:
00652     Locale& init(const char* cLocaleID);
00653 
00654 
00655     char language[ULOC_LANG_CAPACITY];
00656     char country[ULOC_COUNTRY_CAPACITY];
00657     char* variant;
00658     char* fullName;
00659     char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
00660     
00661     static Locale *localeList;
00662     static int32_t localeListCount;
00663 
00664 /* Begin deprecated fields */
00665     static UnicodeString *isoLanguages;
00666     static int32_t isoLanguagesCount;
00667     static UnicodeString *isoCountries;
00668     static int32_t isoCountriesCount;
00669 /* End deprecated fields */
00670 
00671     static UHashtable *ctry2LangMapping;
00672     static const UnicodeString compressedCtry2LangMapping;
00673 
00674     static Locale fgDefaultLocale;
00675 
00676 friend  void locale_set_default_internal(const char *);
00677 
00678 };
00679 
00680 inline UBool
00681 Locale::operator!=(const    Locale&     other) const
00682 {
00683     return !operator==(other);
00684 }
00685 
00686 #endif  /* XP_CPLUSPLUS */
00687 #endif
00688 
00689 

Generated at Thu Mar 22 16:12:36 2001 for ICU 1.8 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000