| 1226 | } |
| 1227 | |
| 1228 | UnionType::UnionType(FieldVector fields, std::vector<int8_t> type_codes, Type::type id) |
| 1229 | : NestedType(id), |
| 1230 | type_codes_(std::move(type_codes)), |
| 1231 | child_ids_(kMaxTypeCode + 1, kInvalidChildId) { |
| 1232 | children_ = std::move(fields); |
| 1233 | DCHECK_OK(ValidateParameters(children_, type_codes_, mode())); |
| 1234 | for (int child_id = 0; child_id < static_cast<int>(type_codes_.size()); ++child_id) { |
| 1235 | const auto type_code = type_codes_[child_id]; |
| 1236 | child_ids_[type_code] = child_id; |
| 1237 | } |
| 1238 | } |
| 1239 | |
| 1240 | Status UnionType::ValidateParameters(const FieldVector& fields, |
| 1241 | const std::vector<int8_t>& type_codes, |