Add ShouldSkip variant that can read a --match flag directly.
Just seemed like we were going through lots of hoops for this common case.
BUG=
R=scroggo@google.com
Author: mtklein@google.com
Review URL: https://chromiumcodereview.appspot.com/23708009
git-svn-id: http://skia.googlecode.com/svn/trunk@11034 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/flags/SkCommandLineFlags.cpp b/tools/flags/SkCommandLineFlags.cpp
index 084f48a..656a00a 100644
--- a/tools/flags/SkCommandLineFlags.cpp
+++ b/tools/flags/SkCommandLineFlags.cpp
@@ -304,7 +304,10 @@
}
}
-bool SkCommandLineFlags::ShouldSkip(const SkTDArray<const char*>& strings, const char* name) {
+namespace {
+
+template <typename Strings>
+bool ShouldSkipImpl(const Strings& strings, const char* name) {
int count = strings.count();
size_t testLen = strlen(name);
bool anyExclude = count == 0;
@@ -334,3 +337,12 @@
}
return !anyExclude;
}
+
+} // namespace
+
+bool SkCommandLineFlags::ShouldSkip(const SkTDArray<const char*>& strings, const char* name) {
+ return ShouldSkipImpl(strings, name);
+}
+bool SkCommandLineFlags::ShouldSkip(const StringArray& strings, const char* name) {
+ return ShouldSkipImpl(strings, name);
+}
diff --git a/tools/flags/SkCommandLineFlags.h b/tools/flags/SkCommandLineFlags.h
index b0199f6..c324a1f 100644
--- a/tools/flags/SkCommandLineFlags.h
+++ b/tools/flags/SkCommandLineFlags.h
@@ -108,15 +108,6 @@
*/
static void Parse(int argc, char** argv);
- /* Takes a list of the form [~][^]match[$]
- ~ causes a matching test to always be skipped
- ^ requires the start of the test to match
- $ requires the end of the test to match
- ^ and $ requires an exact match
- If a test does not match any list entry, it is skipped unless some list entry starts with ~
- */
- static bool ShouldSkip(const SkTDArray<const char*>& strings, const char* name);
-
/**
* Custom class for holding the arguments for a string flag.
* Publicly only has accessors so the strings cannot be modified.
@@ -150,6 +141,16 @@
friend class SkFlagInfo;
};
+ /* Takes a list of the form [~][^]match[$]
+ ~ causes a matching test to always be skipped
+ ^ requires the start of the test to match
+ $ requires the end of the test to match
+ ^ and $ requires an exact match
+ If a test does not match any list entry, it is skipped unless some list entry starts with ~
+ */
+ static bool ShouldSkip(const SkTDArray<const char*>& strings, const char* name);
+ static bool ShouldSkip(const StringArray& strings, const char* name);
+
private:
static SkFlagInfo* gHead;
static SkString gUsage;