Allow more options for setting boolean flag values in SkFlags.

Now booleans can be set using
--boolean=true or --boolean true (as well as other options).

Review URL: https://codereview.chromium.org/12961003

git-svn-id: http://skia.googlecode.com/svn/trunk@8285 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/SkFlags.h b/tools/SkFlags.h
index a2d4c97..c510707 100644
--- a/tools/SkFlags.h
+++ b/tools/SkFlags.h
@@ -37,8 +37,13 @@
  *
  *  which will initially be set to false, and can be set to true by using the
  *  flag "--boolean" on the commandline. "--noboolean" will set FLAGS_boolean
- *  to false. (Single dashes are also permitted for this and other flags.) The
- *  helpString will be printed if the help flag (-h or -help) is used.
+ *  to false. FLAGS_boolean can also be set using "--boolean=true" or
+ *  "--boolean true" (where "true" can be replaced by "false", "TRUE", "FALSE",
+ *  "1" or "0").
+ *
+ *  Single dashes are also permitted for this and other flags.
+ *
+ *  The helpString will be printed if the help flag (-h or -help) is used.
  *
  *  Similarly, the line
  *
@@ -227,38 +232,19 @@
     }
 
     /**
-     *  Returns true if the string matches this flag. For a bool, also sets the
-     *  value, since a bool is specified as true or false by --name or --noname.
+     *  Returns true if the string matches this flag.
+     *  For a boolean flag, also sets the value, since a boolean flag can be set in a number of ways
+     *  without looking at the following string:
+     *      --name
+     *      --noname
+     *      --name=true
+     *      --name=false
+     *      --name=1
+     *      --name=0
+     *      --name=TRUE
+     *      --name=FALSE
      */
-    bool match(const char* string) {
-        if (SkStrStartsWith(string, '-') && strlen(string) > 1) {
-            string++;
-            // Allow one or two dashes
-            if (SkStrStartsWith(string, '-') && strlen(string) > 1) {
-                string++;
-            }
-            if (kBool_FlagType == fFlagType) {
-                // In this case, go ahead and set the value.
-                if (fName.equals(string) || fShortName.equals(string)) {
-                    *fBoolValue = true;
-                    return true;
-                }
-                if (SkStrStartsWith(string, "no") && strlen(string) > 2) {
-                    string += 2;
-                    if (fName.equals(string) || fShortName.equals(string)) {
-                        *fBoolValue = false;
-                        return true;
-                    }
-                    return false;
-                }
-            }
-            return fName.equals(string) || fShortName.equals(string);
-        } else {
-            // Has no dash
-            return false;
-        }
-        return false;
-    }
+    bool match(const char* string);
 
     FlagTypes getFlagType() const { return fFlagType; }
 
@@ -294,6 +280,14 @@
         }
     }
 
+    void setBool(bool value) {
+        if (kBool_FlagType == fFlagType) {
+            *fBoolValue = value;
+        } else {
+            SkASSERT(!"Can only call setBool on kBool_FlagType");
+        }
+    }
+
     SkFlagInfo* next() { return fNext; }
 
     const SkString& name() const { return fName; }