00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
00374 static Locale createCanonical(const
char* name);
00375
00381 inline const
char * getLanguage( ) const;
00382
00390 inline const
char * getScript( ) const;
00391
00397 inline const
char * getCountry( ) const;
00398
00404 inline const
char * getVariant( ) const;
00405
00414 inline const
char * getName() const;
00415
00423 const
char * getBaseName() const;
00424
00425
00433
StringEnumeration * createKeywords(UErrorCode &status) const;
00434
00446 int32_t getKeywordValue(const
char* keywordName,
char *buffer, int32_t bufferCapacity, UErrorCode &status) const;
00447
00454 const
char * getISO3Language() const;
00455
00461 const
char * getISO3Country() const;
00462
00470
uint32_t getLCID(
void) const;
00471
00481
UnicodeString& getDisplayLanguage(
UnicodeString& dispLang) const;
00482
00496
UnicodeString& getDisplayLanguage( const Locale& displayLocale,
00497
UnicodeString& dispLang) const;
00498
00508
UnicodeString& getDisplayScript(
UnicodeString& dispScript) const;
00509
00524
UnicodeString& getDisplayScript( const Locale& displayLocale,
00525
UnicodeString& dispScript) const;
00526
00536
UnicodeString& getDisplayCountry(
UnicodeString& dispCountry) const;
00537
00552
UnicodeString& getDisplayCountry( const Locale& displayLocale,
00553
UnicodeString& dispCountry) const;
00554
00562
UnicodeString& getDisplayVariant(
UnicodeString& dispVar) const;
00563
00572
UnicodeString& getDisplayVariant( const Locale& displayLocale,
00573
UnicodeString& dispVar) const;
00574
00586
UnicodeString& getDisplayName(
UnicodeString& name) const;
00587
00600
UnicodeString& getDisplayName( const Locale& displayLocale,
00601
UnicodeString& name) const;
00602
00607 int32_t hashCode(
void) const;
00608
00617
void setToBogus();
00618
00624 UBool isBogus(
void) const;
00625
00634 static const Locale* getAvailableLocales(int32_t& count);
00635
00644 static const
char* const* getISOCountries();
00645
00654 static const
char* const* getISOLanguages();
00655
00661 static
UClassID getStaticClassID();
00662
00668 virtual UClassID getDynamicClassID() const;
00669
00670 protected:
00675
void setFromPOSIXID(const
char *posixID);
00676
00677 private:
00684 Locale& init(const
char* cLocaleID, UBool canonicalize);
00685
00686
00687
00688
00689
00690
00691 enum ELocaleType {
00692 eBOGUS
00693 };
00694 Locale(ELocaleType);
00695
00699
static Locale *getLocaleCache(
void);
00700
00701
char language[
ULOC_LANG_CAPACITY];
00702
char script[
ULOC_SCRIPT_CAPACITY];
00703
char country[
ULOC_COUNTRY_CAPACITY];
00704
int32_t variantBegin;
00705
char* fullName;
00706
char fullNameBuffer[
ULOC_FULLNAME_CAPACITY];
00707
00708
char* baseName;
00709
char baseNameBuffer[
ULOC_FULLNAME_CAPACITY];
00710
00711
UBool fIsBogus;
00712
00713
static const Locale &getLocale(
int locid);
00714
00719
friend void locale_set_default_internal(
const char *);
00720 };
00721
00722
inline UBool
00723
Locale::operator!=(
const Locale& other)
const
00724
{
00725
return !
operator==(other);
00726 }
00727
00728
inline const char *
00729
Locale::getCountry()
const
00730
{
00731
return country;
00732 }
00733
00734
inline const char *
00735
Locale::getLanguage()
const
00736
{
00737
return language;
00738 }
00739
00740
inline const char *
00741
Locale::getScript()
const
00742
{
00743
return script;
00744 }
00745
00746
inline const char *
00747
Locale::getVariant()
const
00748
{
00749
return &fullName[variantBegin];
00750 }
00751
00752
inline const char *
00753
Locale::getName()
const
00754
{
00755
return fullName;
00756 }
00757
00758
inline UBool
00759
Locale::isBogus(
void)
const {
00760
return fIsBogus;
00761 }
00762
00763
U_NAMESPACE_END
00764
00765
#endif
00766