/*
******************************************************************************
*
-* Copyright (C) 1996-2012, International Business Machines
+* Copyright (C) 1996-2015, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
* \brief C++ API: Locale ID object.
*/
+U_NAMESPACE_BEGIN
+
+// Forward Declarations
+void U_CALLCONV locale_available_init(); /**< @internal */
+
/**
* A <code>Locale</code> object represents a specific geographical, political,
* or cultural region. An operation that requires a <code>Locale</code> to perform
* @stable ICU 2.0
* @see ResourceBundle
*/
-U_NAMESPACE_BEGIN
class U_COMMON_API Locale : public UObject {
public:
/** Useful constant for the Root locale. @stable ICU 4.4 */
inline const char * getName() const;
/**
- * Returns the programmatic name of the entire locale as getName would return,
+ * Returns the programmatic name of the entire locale as getName() would return,
* but without keywords.
* @return A pointer to "name".
* @see getName
*/
int32_t getKeywordValue(const char* keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const;
-#ifndef U_HIDE_DRAFT_API
/**
- * Sets the value for a keyword.
+ * Sets or removes the value for a keyword.
+ *
+ * For removing all keywords, use getBaseName(),
+ * and construct a new Locale if it differs from getName().
*
* @param keywordName name of the keyword to be set. Case insensitive.
* @param keywordValue value of the keyword to be set. If 0-length or
* that keyword does not exist.
* @param status Returns any error information while performing this operation.
*
- * @draft ICU 49
+ * @stable ICU 49
*/
void setKeywordValue(const char* keywordName, const char* keywordValue, UErrorCode &status);
-#endif /* U_HIDE_DRAFT_API */
/**
* returns the locale's three-letter language code, as specified
*/
uint32_t getLCID(void) const;
+#ifndef U_HIDE_DRAFT_API
+ /**
+ * Returns whether this locale's script is written right-to-left.
+ * If there is no script subtag, then the likely script is used, see uloc_addLikelySubtags().
+ * If no likely script is known, then FALSE is returned.
+ *
+ * A script is right-to-left according to the CLDR script metadata
+ * which corresponds to whether the script's letters have Bidi_Class=R or AL.
+ *
+ * Returns TRUE for "ar" and "en-Hebr", FALSE for "zh" and "fa-Cyrl".
+ *
+ * @return TRUE if the locale's script is written right-to-left
+ * @draft ICU 54
+ */
+ UBool isRightToLeft() const;
+#endif /* U_HIDE_DRAFT_API */
+
/**
* Fills in "dispLang" with the name of this locale's language in a format suitable for
* user display in the default locale. For example, if the locale's language code is
char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
// name without keywords
char* baseName;
- char baseNameBuffer[ULOC_FULLNAME_CAPACITY];
+ void initBaseName(UErrorCode& status);
UBool fIsBogus;
* A friend to allow the default locale to be set by either the C or C++ API.
* @internal
*/
- friend void locale_set_default_internal(const char *);
+ friend Locale *locale_set_default_internal(const char *, UErrorCode& status);
+
+ /**
+ * @internal
+ */
+ friend void U_CALLCONV locale_available_init();
};
inline UBool
inline const char *
Locale::getVariant() const
{
- getBaseName(); // lazy init
return &baseName[variantBegin];
}