| 97 | |
| 98 | template <typename Property> |
| 99 | void operator()(const Property& prop, size_t i) { |
| 100 | if (!obj_) return; |
| 101 | |
| 102 | auto first_colon = members_[i].find_first_of(':'); |
| 103 | if (first_colon == std::string_view::npos) return Fail(); |
| 104 | |
| 105 | auto name = members_[i].substr(0, first_colon); |
| 106 | if (name != prop.name()) return Fail(); |
| 107 | |
| 108 | auto value_repr = members_[i].substr(first_colon + 1); |
| 109 | typename Property::Type value; |
| 110 | try { |
| 111 | std::stringstream ss{std::string{value_repr}}; |
| 112 | ss >> value; |
| 113 | if (!ss.eof()) return Fail(); |
| 114 | } catch (...) { |
| 115 | return Fail(); |
| 116 | } |
| 117 | prop.set(&*obj_, std::move(value)); |
| 118 | } |
| 119 | |
| 120 | std::optional<Class> obj_ = Class{}; |
| 121 | std::vector<std::string_view> members_; |