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-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/putil.h"
00033 
00034 #define ULOC_LANG_CAPACITY 3
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 #ifndef ICU_LOCID_NO_DEPRECATES
00229 
00238                                 Locale( const   UnicodeString&  language, 
00239                                         const   UnicodeString&  country , 
00240                                         const   UnicodeString&  variant );
00241 
00249                Locale( const   UnicodeString&  language, 
00250                                         const   UnicodeString&  country );
00251                 
00258                 Locale( const   UnicodeString&  language);
00259 
00260 
00261 #endif /* ICU_LOCID_NO_DEPRECATES */
00262 
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 
00319     static  Locale&             getDefault(void);
00320 
00329     static      void            setDefault(const    Locale&     newLocale,
00330                                                     UErrorCode&  success);
00331 
00337                 const char *  getLanguage( ) const;
00343                 const char *   getCountry( ) const;
00349                 const char *  getVariant( ) const;
00350 
00358                 const char * getName() const;
00359 
00366                 const char * getISO3Language() const;
00367 
00373                 const char * getISO3Country() const;
00374 
00375 #ifndef ICU_LOCID_NO_DEPRECATES
00376 /* begin deprecated versions */
00377 
00384                 UnicodeString&    getLanguage(        UnicodeString&  lang) const;
00391                 UnicodeString&   getCountry(         UnicodeString&  cntry) const;
00398                 UnicodeString&  getVariant(         UnicodeString&  var) const;
00399 
00409                 UnicodeString&  getName(        UnicodeString&  name) const;
00410 
00411 
00420                 UnicodeString&  getISO3Language(UnicodeString&  name, UErrorCode& status) const;
00421 
00429                 UnicodeString&  getISO3Country( UnicodeString&  name, UErrorCode& status) const;
00430 
00431 /* END deprecated [ ICU_LOCID_NO_DEPRECATES ] */
00432 #endif /* ICU_LOCID_NO_DEPRECATES */
00433 
00440                 uint32_t        getLCID(void) const;
00441 
00451                 UnicodeString&  getDisplayLanguage(UnicodeString&   dispLang) const;
00452 
00466                 UnicodeString&  getDisplayLanguage( const   Locale&         inLocale,
00467                                                             UnicodeString&  dispLang) const;
00477                 UnicodeString&  getDisplayCountry(          UnicodeString& dispCountry) const;
00492                 UnicodeString&  getDisplayCountry(  const   Locale&         inLocale,
00493                                                             UnicodeString&  dispCountry) const;
00494 
00502                 UnicodeString&  getDisplayVariant(      UnicodeString& dispVar) const;
00511                 UnicodeString&  getDisplayVariant(  const   Locale&         inLocale,
00512                                                             UnicodeString&  dispVar) const;
00524                 UnicodeString&  getDisplayName(         UnicodeString&  name) const;
00537                 UnicodeString&  getDisplayName( const   Locale&         inLocale,
00538                                                         UnicodeString&  name) const;
00543                 int32_t         hashCode(void) const;
00544 
00553     static  const   Locale*     getAvailableLocales(int32_t& count);
00554 
00563     static const char* const* getISOCountries();
00564 
00573     static const char* const*  getISOLanguages();
00574 
00575 
00576 #ifndef ICU_LOCID_NO_DEPRECATES
00577 
00585     static const UnicodeString* getISOCountries(int32_t& count);
00586 
00598     static const UnicodeString* getISOLanguages(int32_t& count);
00599 #endif /* ICU_LOCID_NO_DEPRECATES */
00600     
00601 protected: /* only protected for testing purposes. DO NOT USE. */
00602     void setFromPOSIXID(const char *posixID); /* set it from a single string. */
00603 
00619     static const UnicodeString* getLanguagesForCountry(    const UnicodeString& country, 
00620                                                         int32_t& count);
00621 
00622 
00623 private:
00630     Locale& init(const char* cLocaleID);
00631     
00632     
00633     char language[ULOC_LANG_CAPACITY];
00634     char country[ULOC_COUNTRY_CAPACITY];
00635     char* variant;
00636     char* fullName;
00637     char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
00638     
00639     static Locale *localeList;
00640     static int32_t localeListCount;
00641 
00642 /* Begin deprecated fields */
00643     static UnicodeString *isoLanguages;
00644     static int32_t isoLanguagesCount;
00645     static UnicodeString *isoCountries;
00646     static int32_t isoCountriesCount;
00647 /* End deprecated fields */
00648 
00649     static UHashtable *ctry2LangMapping;
00650     static const UnicodeString compressedCtry2LangMapping;
00651 
00652     static Locale fgDefaultLocale;
00653 
00654 friend  void locale_set_default_internal(const char *);
00655 
00656 };
00657 
00658 inline UBool
00659 Locale::operator!=(const    Locale&     other) const
00660 {
00661     return !operator==(other);
00662 }
00663 
00664 #endif  /* XP_CPLUSPLUS */
00665 #endif
00666 
00667 

Generated at Fri Dec 15 12:12:33 2000 for ICU 1.7 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000