aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-03-27 12:43:44 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-27 17:24:35 +0000
commit88f9c1eff96a12cfa42db5c238ed42623762d90c (patch)
treed6018ab068e5356f686399b0625dd27a2c4087f5 /tools
parent3798c86f6885f0b47fb2e659a43b48a4468a97ef (diff)
ok: alias 565 -> sw:ct=565
This is mostly a demo, and to make sure it's easy. If I'm thinking right, other non-ct options should Just Work. Change-Id: I295db0fa04921ccdd766e1870e367594ca802462 Reviewed-on: https://skia-review.googlesource.com/10190 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/ok.cpp6
-rw-r--r--tools/ok.h5
-rw-r--r--tools/ok_dsts.cpp5
3 files changed, 12 insertions, 4 deletions
diff --git a/tools/ok.cpp b/tools/ok.cpp
index b6d25b840c..a922f87a16 100644
--- a/tools/ok.cpp
+++ b/tools/ok.cpp
@@ -364,7 +364,7 @@ Options::Options(std::string str) {
std::string k,v, *curr = &k;
for (auto c : str) {
switch(c) {
- case ',': this->kv[k] = v;
+ case ',': (*this)[k] = v;
curr = &(k = "");
break;
case '=': curr = &(v = "");
@@ -372,9 +372,11 @@ Options::Options(std::string str) {
default: *curr += c;
}
}
- this->kv[k] = v;
+ (*this)[k] = v;
}
+std::string& Options::operator[](std::string k) { return this->kv[k]; }
+
std::string Options::operator()(std::string k, std::string fallback) const {
for (auto it = kv.find(k); it != kv.end(); ) {
return it->second;
diff --git a/tools/ok.h b/tools/ok.h
index e2a6a344ee..02bd939fc9 100644
--- a/tools/ok.h
+++ b/tools/ok.h
@@ -41,8 +41,9 @@ struct Dst {
class Options {
std::map<std::string, std::string> kv;
public:
- explicit Options(std::string str = "");
- std::string operator()(std::string k, std::string fallback = "") const;
+ explicit Options(std::string = "");
+ std::string& operator[](std::string k);
+ std::string operator()(std::string k, std::string fallback = "") const;
};
// Create globals to register your new type of Stream or Dst.
diff --git a/tools/ok_dsts.cpp b/tools/ok_dsts.cpp
index cc47ac4fbe..034ca4564d 100644
--- a/tools/ok_dsts.cpp
+++ b/tools/ok_dsts.cpp
@@ -33,3 +33,8 @@ struct SWDst : Dst {
}
};
static Register sw{"sw", SWDst::Create};
+
+static Register _565{"565", [](Options options) {
+ options["ct"] = "565";
+ return SWDst::Create(options);
+}};