Change which method to be a property and return an enum type.

Old code using which() will still work since the enum type has a
__call__ method.
This commit is contained in:
Jason Paryani
2014-02-13 19:24:06 -08:00
parent 6ccc208757
commit 3d8dc6daa9
4 changed files with 112 additions and 53 deletions

View File

@@ -6,17 +6,6 @@ T fixMaybe(::kj::Maybe<T> val) {
KJ_IF_MAYBE(new_val, val) {
return *new_val;
} else {
throw std::invalid_argument("member was null");
throw std::invalid_argument("Member was null.");
}
}
template<typename T>
const char * getEnumString(T & val) {
auto maybe_val = val.which();
KJ_IF_MAYBE(new_val, maybe_val) {
return new_val->getProto().getName().cStr();;
} else {
return "";
}
}