| 34 | } |
| 35 | |
| 36 | bool Enum::fromJson(Json::Value Json) { |
| 37 | try { |
| 38 | if (Json.isNull() || Json.empty() || !Json["Name"].isString() || |
| 39 | !Json["Enumerators"].isArray()) |
| 40 | throw Json::LogicError("Abnormal Json Value"); |
| 41 | Name = Json["Name"].asString(); |
| 42 | for (auto EnumeratorJson : Json["Enumerators"]) |
| 43 | Enumerators.emplace_back(EnumeratorJson); |
| 44 | } catch (Json::LogicError &E) { |
| 45 | llvm::outs() << "[E] " << E.what() << "\n"; |
| 46 | return false; |
| 47 | } |
| 48 | return true; |
| 49 | } |
| 50 | |
| 51 | std::string Enum::getName() const { return Name; } |
| 52 | |