Bug 1438687 - Document mozilla::intl::Locale. r?jfkthame
MozReview-Commit-ID: JBfR1B6FwmJ
--- a/intl/locale/MozLocale.h
+++ b/intl/locale/MozLocale.h
@@ -56,32 +56,78 @@ class Locale {
: Locale(nsDependentCString(aLocale))
{ };
const nsACString& GetLanguage() const;
const nsACString& GetScript() const;
const nsACString& GetRegion() const;
const nsTArray<nsCString>& GetVariants() const;
+ /**
+ * Returns a `true` if the locale is valid, or `false` if it is not.
+ */
bool IsValid() const {
return mIsValid;
}
+ /**
+ * Returns a canonicalized language tag string of the locale.
+ */
const nsCString AsString() const;
+ /**
+ * Compares two locales optionally treating one or both of
+ * the locales a a range.
+ *
+ * In case one of the locales is treated as a range, its
+ * empty fields are considered to match all possible
+ * values of the same field on the other locale.
+ *
+ * Example:
+ *
+ * Locale("en").Matches(Locale("en-US"), false, false) // false
+ * Locale("en").Matches(Locale("en-US"), true, false) // true
+ *
+ * The latter returns true because the region field on the "en"
+ * locale is being treated as a range and matches any region field
+ * value including "US" of the other locale.
+ */
bool Matches(const Locale& aOther, bool aThisRange, bool aOtherRange) const;
+
+ /**
+ * This operation uses CLDR data to build a more specific version
+ * of a generic locale.
+ *
+ * Example:
+ *
+ * Locale("en").AddLikelySubtags().AsString(); // "en-Latn-US"
+ */
bool AddLikelySubtags();
+
+ /**
+ * Clears the variants field of the Locale object.
+ */
void ClearVariants();
+
+ /**
+ * Clears the region field of the Locale object.
+ */
void ClearRegion();
- // Mark the object as invalid, meaning we shouldn't use it any more.
+ /**
+ * Marks the locale as invalid which in turns makes
+ * it to be skipped by most LocaleService operations.
+ */
void Invalidate() {
mIsValid = false;
}
+ /**
+ * Compares two locales expecting all fields to match each other.
+ */
bool operator== (const Locale& aOther) {
// Note: invalid Locale objects are never treated as equal to anything
// (even other invalid ones).
return IsValid() &&
aOther.IsValid() &&
mLanguage.Equals(aOther.mLanguage) &&
mScript.Equals(aOther.mScript) &&
mRegion.Equals(aOther.mRegion) &&