Bug 1438687 - Document mozilla::intl::Locale. r?jfkthame draft
authorZibi Braniecki <zbraniecki@mozilla.com>
Sun, 25 Mar 2018 15:01:01 +0200
changeset 772245 551c159e6284c0fa360cd2fe06abcc2de0245b53
parent 770820 68464218a41a5350ffa926e1b5d77fde75bc4e01
child 772246 a97eed4b7a966ffe65f9076200ab7bcc72df1195
push id103879
push userbmo:gandalf@aviary.pl
push dateSun, 25 Mar 2018 13:04:10 +0000
reviewersjfkthame
bugs1438687
milestone61.0a1
Bug 1438687 - Document mozilla::intl::Locale. r?jfkthame MozReview-Commit-ID: JBfR1B6FwmJ
intl/locale/MozLocale.h
--- 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) &&