Main Page   Class Hierarchy   Compound List   File List   Header Files   Sources   Compound Members   File Members  

locid.h

00001 /*
00002 *****************************************************************************************
00003 *
00004 *   Copyright (C) 1996-1999, 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/unistr.h"
00033 
00034 typedef struct ULocale ULocale;
00035 typedef struct UHashtable UHashtable;
00036 
00037 #define ULOC_LANG_CAPACITY 3
00038 #define ULOC_COUNTRY_CAPACITY 3
00039 #define ULOC_FULLNAME_CAPACITY 50
00040 
00173 class U_COMMON_API Locale 
00174 {
00175 public:
00179     static const Locale ENGLISH;
00180     static const Locale FRENCH;
00181     static const Locale GERMAN;
00182     static const Locale ITALIAN;
00183     static const Locale JAPANESE;
00184     static const Locale KOREAN;
00185     static const Locale CHINESE;
00186     static const Locale SIMPLIFIED_CHINESE;
00187     static const Locale TRADITIONAL_CHINESE;
00188 
00192     static const Locale FRANCE;
00193     static const Locale GERMANY;
00194     static const Locale ITALY;
00195     static const Locale JAPAN;
00196     static const Locale KOREA;
00197     static const Locale CHINA;      // Alias for PRC
00198     static const Locale PRC;        // Peoples Republic of China
00199     static const Locale TAIWAN;
00200     static const Locale UK;
00201     static const Locale US;
00202     static const Locale CANADA;
00203     static const Locale CANADA_FRENCH;
00204 
00210                                 Locale(); 
00211 
00221                                 Locale( const   char * language,
00222                                         const   char * country  = 0, 
00223                                         const   char * variant  = 0);
00224 #ifndef ICU_LOCID_NO_DEPRECATES
00234                                 Locale( const   UnicodeString&  language, 
00235                                         const   UnicodeString&  country , 
00236                                         const   UnicodeString&  variant );
00237 
00245                Locale( const   UnicodeString&  language, 
00246                                         const   UnicodeString&  country );
00247                 
00254                 Locale( const   UnicodeString&  language);
00255 
00256 
00257 #endif // ICU_LOCID_NO_DEPRECATES
00264                                 Locale(const    Locale& other);
00265 
00266 
00271                                 ~Locale() ;
00272                   
00280     Locale&                     operator=(const Locale& other);
00281 
00289                 UBool          operator==(const    Locale&     other) const;   
00290 
00299                 UBool          operator!=(const    Locale&     other) const;
00300 
00315     static  Locale&             getDefault(void);
00316 
00325     static      void            setDefault(const    Locale&     newLocale,
00326                                                     UErrorCode&  success);
00327 
00333                 const char *  getLanguage( ) const;
00339                 const char *   getCountry( ) const;
00345                 const char *  getVariant( ) const;
00346 
00354                 const char * getName() const;
00355 
00362                 const char * getISO3Language() const;
00363 
00369                 const char * getISO3Country() const;
00370 
00371 #ifndef ICU_LOCID_NO_DEPRECATES
00372 // begin deprecated versions
00373 
00380                 UnicodeString&    getLanguage(        UnicodeString&  lang) const;
00387                 UnicodeString&   getCountry(         UnicodeString&  cntry) const;
00394                 UnicodeString&  getVariant(         UnicodeString&  var) const;
00395 
00405                 UnicodeString&  getName(        UnicodeString&  name) const;
00406 
00407 
00416                 UnicodeString&  getISO3Language(UnicodeString&  name, UErrorCode& status) const;
00417 
00425                 UnicodeString&  getISO3Country( UnicodeString&  name, UErrorCode& status) const;
00426 
00427 // END deprecated [ ICU_LOCID_NO_DEPRECATES ]
00428 #endif // ICU_LOCID_NO_DEPRECATES
00436                 uint32_t        getLCID(void) const;
00437 
00447                 UnicodeString&  getDisplayLanguage(UnicodeString&   dispLang) const;
00448 
00462                 UnicodeString&  getDisplayLanguage( const   Locale&         inLocale,
00463                                                             UnicodeString&  dispLang) const;
00473                 UnicodeString&  getDisplayCountry(          UnicodeString& dispCountry) const;
00488                 UnicodeString&  getDisplayCountry(  const   Locale&         inLocale,
00489                                                             UnicodeString&  dispCountry) const;
00490 
00498                 UnicodeString&  getDisplayVariant(      UnicodeString& dispVar) const;
00507                 UnicodeString&  getDisplayVariant(  const   Locale&         inLocale,
00508                                                             UnicodeString&  dispVar) const;
00520                 UnicodeString&  getDisplayName(         UnicodeString&  name) const;
00533                 UnicodeString&  getDisplayName( const   Locale&         inLocale,
00534                                                         UnicodeString&  name) const;
00539                 int32_t         hashCode(void) const;
00540 
00549     static  const   Locale*     getAvailableLocales(int32_t& count);
00550 
00559     static const char* const* getISOCountries();
00560 
00569     static const char* const*  getISOLanguages();
00570 
00571 
00572 #ifndef ICU_LOCID_NO_DEPRECATES
00581     static const UnicodeString* getISOCountries(int32_t& count);
00582 
00594     static const UnicodeString* getISOLanguages(int32_t& count);
00595 #endif // ICU_LOCID_NO_DEPRECATES
00596     
00597 protected: // only protected for testing purposes. DO NOT USE.
00598     void setFromPOSIXID(const char *posixID); // set it from a single string.
00599 
00615     static const UnicodeString* getLanguagesForCountry(    const UnicodeString& country, 
00616                                                         int32_t& count);
00617 
00618 
00619 private:
00626     Locale& init(const char* cLocaleID);
00627     
00628     
00629     char language[ULOC_LANG_CAPACITY];
00630     char country[ULOC_COUNTRY_CAPACITY];
00631     char* variant;
00632     char* fullName;
00633     char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
00634     
00635     static Locale *localeList;
00636     static int32_t localeListCount;
00637 
00638 // Begin deprecated fields
00639     static UnicodeString *isoLanguages;
00640     static int32_t isoLanguagesCount;
00641     static UnicodeString *isoCountries;
00642     static int32_t isoCountriesCount;
00643 // End deprecated fields
00644 
00645     static UHashtable *ctry2LangMapping;
00646     static const UnicodeString compressedCtry2LangMapping;
00647 
00648     static Locale fgDefaultLocale;
00649 
00650 friend  void locale_set_default_internal(const char *);
00651 
00652 };
00653 
00654 inline UBool
00655 Locale::operator!=(const    Locale&     other) const
00656 {
00657     return !operator==(other);
00658 }
00659 
00660 #endif
00661 
00662 

Generated at Mon Jun 5 12:53:03 2000 for ICU1.5 by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999