Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/common/unicode/locid.h
38827 views
/*1******************************************************************************2*3* Copyright (C) 1996-2015, International Business Machines4* Corporation and others. All Rights Reserved.5*6******************************************************************************7*8* File locid.h9*10* Created by: Helena Shih11*12* Modification History:13*14* Date Name Description15* 02/11/97 aliu Changed gLocPath to fgLocPath and added methods to16* get and set it.17* 04/02/97 aliu Made operator!= inline; fixed return value of getName().18* 04/15/97 aliu Cleanup for AIX/Win32.19* 04/24/97 aliu Numerous changes per code review.20* 08/18/98 stephen Added tokenizeString(),changed getDisplayName()21* 09/08/98 stephen Moved definition of kEmptyString for Mac Port22* 11/09/99 weiv Added const char * getName() const;23* 04/12/00 srl removing unicodestring api's and cached hash code24* 08/10/01 grhoten Change the static Locales to accessor functions25******************************************************************************26*/2728#ifndef LOCID_H29#define LOCID_H3031#include "unicode/utypes.h"32#include "unicode/uobject.h"33#include "unicode/unistr.h"34#include "unicode/putil.h"35#include "unicode/uloc.h"36#include "unicode/strenum.h"3738/**39* \file40* \brief C++ API: Locale ID object.41*/4243U_NAMESPACE_BEGIN4445// Forward Declarations46void U_CALLCONV locale_available_init(); /**< @internal */4748/**49* A <code>Locale</code> object represents a specific geographical, political,50* or cultural region. An operation that requires a <code>Locale</code> to perform51* its task is called <em>locale-sensitive</em> and uses the <code>Locale</code>52* to tailor information for the user. For example, displaying a number53* is a locale-sensitive operation--the number should be formatted54* according to the customs/conventions of the user's native country,55* region, or culture.56*57* The Locale class is not suitable for subclassing.58*59* <P>60* You can create a <code>Locale</code> object using the constructor in61* this class:62* \htmlonly<blockquote>\endhtmlonly63* <pre>64* Locale( const char* language,65* const char* country,66* const char* variant);67* </pre>68* \htmlonly</blockquote>\endhtmlonly69* The first argument to the constructors is a valid <STRONG>ISO70* Language Code.</STRONG> These codes are the lower-case two-letter71* codes as defined by ISO-639.72* You can find a full list of these codes at:73* <BR><a href ="http://www.loc.gov/standards/iso639-2/">74* http://www.loc.gov/standards/iso639-2/</a>75*76* <P>77* The second argument to the constructors is a valid <STRONG>ISO Country78* Code.</STRONG> These codes are the upper-case two-letter codes79* as defined by ISO-3166.80* You can find a full list of these codes at a number of sites, such as:81* <BR><a href="http://www.iso.org/iso/en/prods-services/iso3166ma/index.html">82* http://www.iso.org/iso/en/prods-services/iso3166ma/index.html</a>83*84* <P>85* The third constructor requires a third argument--the <STRONG>Variant.</STRONG>86* The Variant codes are vendor and browser-specific.87* For example, use REVISED for a langauge's revised script orthography, and POSIX for POSIX.88* Where there are two variants, separate them with an underscore, and89* put the most important one first. For90* example, a Traditional Spanish collation might be referenced, with91* "ES", "ES", "Traditional_POSIX".92*93* <P>94* Because a <code>Locale</code> object is just an identifier for a region,95* no validity check is performed when you construct a <code>Locale</code>.96* If you want to see whether particular resources are available for the97* <code>Locale</code> you construct, you must query those resources. For98* example, ask the <code>NumberFormat</code> for the locales it supports99* using its <code>getAvailableLocales</code> method.100* <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular101* locale, you get back the best available match, not necessarily102* precisely what you asked for. For more information, look at103* <code>ResourceBundle</code>.104*105* <P>106* The <code>Locale</code> class provides a number of convenient constants107* that you can use to create <code>Locale</code> objects for commonly used108* locales. For example, the following refers to a <code>Locale</code> object109* for the United States:110* \htmlonly<blockquote>\endhtmlonly111* <pre>112* Locale::getUS()113* </pre>114* \htmlonly</blockquote>\endhtmlonly115*116* <P>117* Once you've created a <code>Locale</code> you can query it for information about118* itself. Use <code>getCountry</code> to get the ISO Country Code and119* <code>getLanguage</code> to get the ISO Language Code. You can120* use <code>getDisplayCountry</code> to get the121* name of the country suitable for displaying to the user. Similarly,122* you can use <code>getDisplayLanguage</code> to get the name of123* the language suitable for displaying to the user. Interestingly,124* the <code>getDisplayXXX</code> methods are themselves locale-sensitive125* and have two versions: one that uses the default locale and one126* that takes a locale as an argument and displays the name or country in127* a language appropriate to that locale.128*129* <P>130* ICU provides a number of classes that perform locale-sensitive131* operations. For example, the <code>NumberFormat</code> class formats132* numbers, currency, or percentages in a locale-sensitive manner. Classes133* such as <code>NumberFormat</code> have a number of convenience methods134* for creating a default object of that type. For example, the135* <code>NumberFormat</code> class provides these three convenience methods136* for creating a default <code>NumberFormat</code> object:137* \htmlonly<blockquote>\endhtmlonly138* <pre>139* UErrorCode success = U_ZERO_ERROR;140* Locale myLocale;141* NumberFormat *nf;142*143* nf = NumberFormat::createInstance( success ); delete nf;144* nf = NumberFormat::createCurrencyInstance( success ); delete nf;145* nf = NumberFormat::createPercentInstance( success ); delete nf;146* </pre>147* \htmlonly</blockquote>\endhtmlonly148* Each of these methods has two variants; one with an explicit locale149* and one without; the latter using the default locale.150* \htmlonly<blockquote>\endhtmlonly151* <pre>152* nf = NumberFormat::createInstance( myLocale, success ); delete nf;153* nf = NumberFormat::createCurrencyInstance( myLocale, success ); delete nf;154* nf = NumberFormat::createPercentInstance( myLocale, success ); delete nf;155* </pre>156* \htmlonly</blockquote>\endhtmlonly157* A <code>Locale</code> is the mechanism for identifying the kind of object158* (<code>NumberFormat</code>) that you would like to get. The locale is159* <STRONG>just</STRONG> a mechanism for identifying objects,160* <STRONG>not</STRONG> a container for the objects themselves.161*162* <P>163* Each class that performs locale-sensitive operations allows you164* to get all the available objects of that type. You can sift165* through these objects by language, country, or variant,166* and use the display names to present a menu to the user.167* For example, you can create a menu of all the collation objects168* suitable for a given language. Such classes implement these169* three class methods:170* \htmlonly<blockquote>\endhtmlonly171* <pre>172* static Locale* getAvailableLocales(int32_t& numLocales)173* static UnicodeString& getDisplayName(const Locale& objectLocale,174* const Locale& displayLocale,175* UnicodeString& displayName)176* static UnicodeString& getDisplayName(const Locale& objectLocale,177* UnicodeString& displayName)178* </pre>179* \htmlonly</blockquote>\endhtmlonly180*181* @stable ICU 2.0182* @see ResourceBundle183*/184class U_COMMON_API Locale : public UObject {185public:186/** Useful constant for the Root locale. @stable ICU 4.4 */187static const Locale &U_EXPORT2 getRoot(void);188/** Useful constant for this language. @stable ICU 2.0 */189static const Locale &U_EXPORT2 getEnglish(void);190/** Useful constant for this language. @stable ICU 2.0 */191static const Locale &U_EXPORT2 getFrench(void);192/** Useful constant for this language. @stable ICU 2.0 */193static const Locale &U_EXPORT2 getGerman(void);194/** Useful constant for this language. @stable ICU 2.0 */195static const Locale &U_EXPORT2 getItalian(void);196/** Useful constant for this language. @stable ICU 2.0 */197static const Locale &U_EXPORT2 getJapanese(void);198/** Useful constant for this language. @stable ICU 2.0 */199static const Locale &U_EXPORT2 getKorean(void);200/** Useful constant for this language. @stable ICU 2.0 */201static const Locale &U_EXPORT2 getChinese(void);202/** Useful constant for this language. @stable ICU 2.0 */203static const Locale &U_EXPORT2 getSimplifiedChinese(void);204/** Useful constant for this language. @stable ICU 2.0 */205static const Locale &U_EXPORT2 getTraditionalChinese(void);206207/** Useful constant for this country/region. @stable ICU 2.0 */208static const Locale &U_EXPORT2 getFrance(void);209/** Useful constant for this country/region. @stable ICU 2.0 */210static const Locale &U_EXPORT2 getGermany(void);211/** Useful constant for this country/region. @stable ICU 2.0 */212static const Locale &U_EXPORT2 getItaly(void);213/** Useful constant for this country/region. @stable ICU 2.0 */214static const Locale &U_EXPORT2 getJapan(void);215/** Useful constant for this country/region. @stable ICU 2.0 */216static const Locale &U_EXPORT2 getKorea(void);217/** Useful constant for this country/region. @stable ICU 2.0 */218static const Locale &U_EXPORT2 getChina(void);219/** Useful constant for this country/region. @stable ICU 2.0 */220static const Locale &U_EXPORT2 getPRC(void);221/** Useful constant for this country/region. @stable ICU 2.0 */222static const Locale &U_EXPORT2 getTaiwan(void);223/** Useful constant for this country/region. @stable ICU 2.0 */224static const Locale &U_EXPORT2 getUK(void);225/** Useful constant for this country/region. @stable ICU 2.0 */226static const Locale &U_EXPORT2 getUS(void);227/** Useful constant for this country/region. @stable ICU 2.0 */228static const Locale &U_EXPORT2 getCanada(void);229/** Useful constant for this country/region. @stable ICU 2.0 */230static const Locale &U_EXPORT2 getCanadaFrench(void);231232233/**234* Construct a default locale object, a Locale for the default locale ID.235*236* @see getDefault237* @see uloc_getDefault238* @stable ICU 2.0239*/240Locale();241242/**243* Construct a locale from language, country, variant.244* If an error occurs, then the constructed object will be "bogus"245* (isBogus() will return TRUE).246*247* @param language Lowercase two-letter or three-letter ISO-639 code.248* This parameter can instead be an ICU style C locale (e.g. "en_US"),249* but the other parameters must not be used.250* This parameter can be NULL; if so,251* the locale is initialized to match the current default locale.252* (This is the same as using the default constructor.)253* Please note: The Java Locale class does NOT accept the form254* 'new Locale("en_US")' but only 'new Locale("en","US")'255*256* @param country Uppercase two-letter ISO-3166 code. (optional)257* @param variant Uppercase vendor and browser specific code. See class258* description. (optional)259* @param keywordsAndValues A string consisting of keyword/values pairs, such as260* "collation=phonebook;currency=euro"261*262* @see getDefault263* @see uloc_getDefault264* @stable ICU 2.0265*/266Locale( const char * language,267const char * country = 0,268const char * variant = 0,269const char * keywordsAndValues = 0);270271/**272* Initializes a Locale object from another Locale object.273*274* @param other The Locale object being copied in.275* @stable ICU 2.0276*/277Locale(const Locale& other);278279280/**281* Destructor282* @stable ICU 2.0283*/284virtual ~Locale() ;285286/**287* Replaces the entire contents of *this with the specified value.288*289* @param other The Locale object being copied in.290* @return *this291* @stable ICU 2.0292*/293Locale& operator=(const Locale& other);294295/**296* Checks if two locale keys are the same.297*298* @param other The locale key object to be compared with this.299* @return True if the two locale keys are the same, false otherwise.300* @stable ICU 2.0301*/302UBool operator==(const Locale& other) const;303304/**305* Checks if two locale keys are not the same.306*307* @param other The locale key object to be compared with this.308* @return True if the two locale keys are not the same, false309* otherwise.310* @stable ICU 2.0311*/312UBool operator!=(const Locale& other) const;313314/**315* Clone this object.316* Clones can be used concurrently in multiple threads.317* If an error occurs, then NULL is returned.318* The caller must delete the clone.319*320* @return a clone of this object321*322* @see getDynamicClassID323* @stable ICU 2.8324*/325Locale *clone() const;326327#ifndef U_HIDE_SYSTEM_API328/**329* Common methods of getting the current default Locale. Used for the330* presentation: menus, dialogs, etc. Generally set once when your applet or331* application is initialized, then never reset. (If you do reset the332* default locale, you probably want to reload your GUI, so that the change333* is reflected in your interface.)334*335* More advanced programs will allow users to use different locales for336* different fields, e.g. in a spreadsheet.337*338* Note that the initial setting will match the host system.339* @return a reference to the Locale object for the default locale ID340* @system341* @stable ICU 2.0342*/343static const Locale& U_EXPORT2 getDefault(void);344345/**346* Sets the default. Normally set once at the beginning of a process,347* then never reset.348* setDefault() only changes ICU's default locale ID, <strong>not</strong>349* the default locale ID of the runtime environment.350*351* @param newLocale Locale to set to. If NULL, set to the value obtained352* from the runtime environement.353* @param success The error code.354* @system355* @stable ICU 2.0356*/357static void U_EXPORT2 setDefault(const Locale& newLocale,358UErrorCode& success);359#endif /* U_HIDE_SYSTEM_API */360361/**362* Creates a locale which has had minimal canonicalization363* as per uloc_getName().364* @param name The name to create from. If name is null,365* the default Locale is used.366* @return new locale object367* @stable ICU 2.0368* @see uloc_getName369*/370static Locale U_EXPORT2 createFromName(const char *name);371372/**373* Creates a locale from the given string after canonicalizing374* the string by calling uloc_canonicalize().375* @param name the locale ID to create from. Must not be NULL.376* @return a new locale object corresponding to the given name377* @stable ICU 3.0378* @see uloc_canonicalize379*/380static Locale U_EXPORT2 createCanonical(const char* name);381382/**383* Returns the locale's ISO-639 language code.384* @return An alias to the code385* @stable ICU 2.0386*/387inline const char * getLanguage( ) const;388389/**390* Returns the locale's ISO-15924 abbreviation script code.391* @return An alias to the code392* @see uscript_getShortName393* @see uscript_getCode394* @stable ICU 2.8395*/396inline const char * getScript( ) const;397398/**399* Returns the locale's ISO-3166 country code.400* @return An alias to the code401* @stable ICU 2.0402*/403inline const char * getCountry( ) const;404405/**406* Returns the locale's variant code.407* @return An alias to the code408* @stable ICU 2.0409*/410inline const char * getVariant( ) const;411412/**413* Returns the programmatic name of the entire locale, with the language,414* country and variant separated by underbars. If a field is missing, up415* to two leading underbars will occur. Example: "en", "de_DE", "en_US_WIN",416* "de__POSIX", "fr__MAC", "__MAC", "_MT", "_FR_EURO"417* @return A pointer to "name".418* @stable ICU 2.0419*/420inline const char * getName() const;421422/**423* Returns the programmatic name of the entire locale as getName() would return,424* but without keywords.425* @return A pointer to "name".426* @see getName427* @stable ICU 2.8428*/429const char * getBaseName() const;430431432/**433* Gets the list of keywords for the specified locale.434*435* @param status the status code436* @return pointer to StringEnumeration class, or NULL if there are no keywords.437* Client must dispose of it by calling delete.438* @stable ICU 2.8439*/440StringEnumeration * createKeywords(UErrorCode &status) const;441442/**443* Gets the value for a keyword.444*445* @param keywordName name of the keyword for which we want the value. Case insensitive.446* @param buffer The buffer to receive the keyword value.447* @param bufferCapacity The capacity of receiving buffer448* @param status Returns any error information while performing this operation.449* @return the length of the keyword value450*451* @stable ICU 2.8452*/453int32_t getKeywordValue(const char* keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const;454455/**456* Sets or removes the value for a keyword.457*458* For removing all keywords, use getBaseName(),459* and construct a new Locale if it differs from getName().460*461* @param keywordName name of the keyword to be set. Case insensitive.462* @param keywordValue value of the keyword to be set. If 0-length or463* NULL, will result in the keyword being removed. No error is given if464* that keyword does not exist.465* @param status Returns any error information while performing this operation.466*467* @stable ICU 49468*/469void setKeywordValue(const char* keywordName, const char* keywordValue, UErrorCode &status);470471/**472* returns the locale's three-letter language code, as specified473* in ISO draft standard ISO-639-2.474* @return An alias to the code, or an empty string475* @stable ICU 2.0476*/477const char * getISO3Language() const;478479/**480* Fills in "name" with the locale's three-letter ISO-3166 country code.481* @return An alias to the code, or an empty string482* @stable ICU 2.0483*/484const char * getISO3Country() const;485486/**487* Returns the Windows LCID value corresponding to this locale.488* This value is stored in the resource data for the locale as a one-to-four-digit489* hexadecimal number. If the resource is missing, in the wrong format, or490* there is no Windows LCID value that corresponds to this locale, returns 0.491* @stable ICU 2.0492*/493uint32_t getLCID(void) const;494495/**496* Returns whether this locale's script is written right-to-left.497* If there is no script subtag, then the likely script is used, see uloc_addLikelySubtags().498* If no likely script is known, then FALSE is returned.499*500* A script is right-to-left according to the CLDR script metadata501* which corresponds to whether the script's letters have Bidi_Class=R or AL.502*503* Returns TRUE for "ar" and "en-Hebr", FALSE for "zh" and "fa-Cyrl".504*505* @return TRUE if the locale's script is written right-to-left506* @stable ICU 54507*/508UBool isRightToLeft() const;509510/**511* Fills in "dispLang" with the name of this locale's language in a format suitable for512* user display in the default locale. For example, if the locale's language code is513* "fr" and the default locale's language code is "en", this function would set514* dispLang to "French".515* @param dispLang Receives the language's display name.516* @return A reference to "dispLang".517* @stable ICU 2.0518*/519UnicodeString& getDisplayLanguage(UnicodeString& dispLang) const;520521/**522* Fills in "dispLang" with the name of this locale's language in a format suitable for523* user display in the locale specified by "displayLocale". For example, if the locale's524* language code is "en" and displayLocale's language code is "fr", this function would set525* dispLang to "Anglais".526* @param displayLocale Specifies the locale to be used to display the name. In other words,527* if the locale's language code is "en", passing Locale::getFrench() for528* displayLocale would result in "Anglais", while passing Locale::getGerman()529* for displayLocale would result in "Englisch".530* @param dispLang Receives the language's display name.531* @return A reference to "dispLang".532* @stable ICU 2.0533*/534UnicodeString& getDisplayLanguage( const Locale& displayLocale,535UnicodeString& dispLang) const;536537/**538* Fills in "dispScript" with the name of this locale's script in a format suitable539* for user display in the default locale. For example, if the locale's script code540* is "LATN" and the default locale's language code is "en", this function would set541* dispScript to "Latin".542* @param dispScript Receives the scripts's display name.543* @return A reference to "dispScript".544* @stable ICU 2.8545*/546UnicodeString& getDisplayScript( UnicodeString& dispScript) const;547548/**549* Fills in "dispScript" with the name of this locale's country in a format suitable550* for user display in the locale specified by "displayLocale". For example, if the locale's551* script code is "LATN" and displayLocale's language code is "en", this function would set552* dispScript to "Latin".553* @param displayLocale Specifies the locale to be used to display the name. In other554* words, if the locale's script code is "LATN", passing555* Locale::getFrench() for displayLocale would result in "", while556* passing Locale::getGerman() for displayLocale would result in557* "".558* @param dispScript Receives the scripts's display name.559* @return A reference to "dispScript".560* @stable ICU 2.8561*/562UnicodeString& getDisplayScript( const Locale& displayLocale,563UnicodeString& dispScript) const;564565/**566* Fills in "dispCountry" with the name of this locale's country in a format suitable567* for user display in the default locale. For example, if the locale's country code568* is "FR" and the default locale's language code is "en", this function would set569* dispCountry to "France".570* @param dispCountry Receives the country's display name.571* @return A reference to "dispCountry".572* @stable ICU 2.0573*/574UnicodeString& getDisplayCountry( UnicodeString& dispCountry) const;575576/**577* Fills in "dispCountry" with the name of this locale's country in a format suitable578* for user display in the locale specified by "displayLocale". For example, if the locale's579* country code is "US" and displayLocale's language code is "fr", this function would set580* dispCountry to "États-Unis".581* @param displayLocale Specifies the locale to be used to display the name. In other582* words, if the locale's country code is "US", passing583* Locale::getFrench() for displayLocale would result in "États-Unis", while584* passing Locale::getGerman() for displayLocale would result in585* "Vereinigte Staaten".586* @param dispCountry Receives the country's display name.587* @return A reference to "dispCountry".588* @stable ICU 2.0589*/590UnicodeString& getDisplayCountry( const Locale& displayLocale,591UnicodeString& dispCountry) const;592593/**594* Fills in "dispVar" with the name of this locale's variant code in a format suitable595* for user display in the default locale.596* @param dispVar Receives the variant's name.597* @return A reference to "dispVar".598* @stable ICU 2.0599*/600UnicodeString& getDisplayVariant( UnicodeString& dispVar) const;601602/**603* Fills in "dispVar" with the name of this locale's variant code in a format604* suitable for user display in the locale specified by "displayLocale".605* @param displayLocale Specifies the locale to be used to display the name.606* @param dispVar Receives the variant's display name.607* @return A reference to "dispVar".608* @stable ICU 2.0609*/610UnicodeString& getDisplayVariant( const Locale& displayLocale,611UnicodeString& dispVar) const;612613/**614* Fills in "name" with the name of this locale in a format suitable for user display615* in the default locale. This function uses getDisplayLanguage(), getDisplayCountry(),616* and getDisplayVariant() to do its work, and outputs the display name in the format617* "language (country[,variant])". For example, if the default locale is en_US, then618* fr_FR's display name would be "French (France)", and es_MX_Traditional's display name619* would be "Spanish (Mexico,Traditional)".620* @param name Receives the locale's display name.621* @return A reference to "name".622* @stable ICU 2.0623*/624UnicodeString& getDisplayName( UnicodeString& name) const;625626/**627* Fills in "name" with the name of this locale in a format suitable for user display628* in the locale specfied by "displayLocale". This function uses getDisplayLanguage(),629* getDisplayCountry(), and getDisplayVariant() to do its work, and outputs the display630* name in the format "language (country[,variant])". For example, if displayLocale is631* fr_FR, then en_US's display name would be "Anglais (États-Unis)", and no_NO_NY's632* display name would be "norvégien (Norvège,NY)".633* @param displayLocale Specifies the locale to be used to display the name.634* @param name Receives the locale's display name.635* @return A reference to "name".636* @stable ICU 2.0637*/638UnicodeString& getDisplayName( const Locale& displayLocale,639UnicodeString& name) const;640641/**642* Generates a hash code for the locale.643* @stable ICU 2.0644*/645int32_t hashCode(void) const;646647/**648* Sets the locale to bogus649* A bogus locale represents a non-existing locale associated650* with services that can be instantiated from non-locale data651* in addition to locale (for example, collation can be652* instantiated from a locale and from a rule set).653* @stable ICU 2.1654*/655void setToBogus();656657/**658* Gets the bogus state. Locale object can be bogus if it doesn't exist659* @return FALSE if it is a real locale, TRUE if it is a bogus locale660* @stable ICU 2.1661*/662UBool isBogus(void) const;663664/**665* Returns a list of all installed locales.666* @param count Receives the number of locales in the list.667* @return A pointer to an array of Locale objects. This array is the list668* of all locales with installed resource files. The called does NOT669* get ownership of this list, and must NOT delete it.670* @stable ICU 2.0671*/672static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);673674/**675* Gets a list of all available 2-letter country codes defined in ISO 3166. This is a676* pointer to an array of pointers to arrays of char. All of these pointers are677* owned by ICU-- do not delete them, and do not write through them. The array is678* terminated with a null pointer.679* @return a list of all available country codes680* @stable ICU 2.0681*/682static const char* const* U_EXPORT2 getISOCountries();683684/**685* Gets a list of all available language codes defined in ISO 639. This is a pointer686* to an array of pointers to arrays of char. All of these pointers are owned687* by ICU-- do not delete them, and do not write through them. The array is688* terminated with a null pointer.689* @return a list of all available language codes690* @stable ICU 2.0691*/692static const char* const* U_EXPORT2 getISOLanguages();693694/**695* ICU "poor man's RTTI", returns a UClassID for this class.696*697* @stable ICU 2.2698*/699static UClassID U_EXPORT2 getStaticClassID();700701/**702* ICU "poor man's RTTI", returns a UClassID for the actual class.703*704* @stable ICU 2.2705*/706virtual UClassID getDynamicClassID() const;707708protected: /* only protected for testing purposes. DO NOT USE. */709#ifndef U_HIDE_INTERNAL_API710/**711* Set this from a single POSIX style locale string.712* @internal713*/714void setFromPOSIXID(const char *posixID);715#endif /* U_HIDE_INTERNAL_API */716717private:718/**719* Initialize the locale object with a new name.720* Was deprecated - used in implementation - moved internal721*722* @param cLocaleID The new locale name.723* @param canonicalize whether to call uloc_canonicalize on cLocaleID724*/725Locale& init(const char* cLocaleID, UBool canonicalize);726727/*728* Internal constructor to allow construction of a locale object with729* NO side effects. (Default constructor tries to get730* the default locale.)731*/732enum ELocaleType {733eBOGUS734};735Locale(ELocaleType);736737/**738* Initialize the locale cache for commonly used locales739*/740static Locale *getLocaleCache(void);741742char language[ULOC_LANG_CAPACITY];743char script[ULOC_SCRIPT_CAPACITY];744char country[ULOC_COUNTRY_CAPACITY];745int32_t variantBegin;746char* fullName;747char fullNameBuffer[ULOC_FULLNAME_CAPACITY];748// name without keywords749char* baseName;750void initBaseName(UErrorCode& status);751752UBool fIsBogus;753754static const Locale &getLocale(int locid);755756/**757* A friend to allow the default locale to be set by either the C or C++ API.758* @internal759*/760friend Locale *locale_set_default_internal(const char *, UErrorCode& status);761762/**763* @internal764*/765friend void U_CALLCONV locale_available_init();766};767768inline UBool769Locale::operator!=(const Locale& other) const770{771return !operator==(other);772}773774inline const char *775Locale::getCountry() const776{777return country;778}779780inline const char *781Locale::getLanguage() const782{783return language;784}785786inline const char *787Locale::getScript() const788{789return script;790}791792inline const char *793Locale::getVariant() const794{795return &baseName[variantBegin];796}797798inline const char *799Locale::getName() const800{801return fullName;802}803804inline UBool805Locale::isBogus(void) const {806return fIsBogus;807}808809U_NAMESPACE_END810811#endif812813814