Creates merged UnknownAttributeSet. Scans over the args collection, merges any UnknownSets found in it together with initial_set (if initial_set is not null). Returns pointer to merged set or nullptr, if there were no sets to merge.
| 105 | // it together with initial_set (if initial_set is not null). |
| 106 | // Returns pointer to merged set or nullptr, if there were no sets to merge. |
| 107 | absl::optional<UnknownValue> AttributeUtility::MergeUnknowns( |
| 108 | absl::Span<const cel::Value> args) const { |
| 109 | // Empty unknown value may be used as a sentinel in some tests so need to |
| 110 | // distinguish unset (nullopt) and empty(engaged empty value). |
| 111 | absl::optional<UnknownSet> result_set; |
| 112 | |
| 113 | for (const auto& value : args) { |
| 114 | if (!value->Is<cel::UnknownValue>()) continue; |
| 115 | if (!result_set.has_value()) { |
| 116 | result_set.emplace(); |
| 117 | } |
| 118 | const auto& current_set = value.GetUnknown(); |
| 119 | |
| 120 | cel::base_internal::UnknownSetAccess::Add( |
| 121 | *result_set, UnknownSet(current_set.attribute_set(), |
| 122 | current_set.function_result_set())); |
| 123 | } |
| 124 | |
| 125 | if (!result_set.has_value()) { |
| 126 | return absl::nullopt; |
| 127 | } |
| 128 | |
| 129 | return UnknownValue(cel::Unknown(result_set->unknown_attributes(), |
| 130 | result_set->unknown_function_results())); |
| 131 | } |
| 132 | |
| 133 | UnknownValue AttributeUtility::MergeUnknownValues( |
| 134 | const UnknownValue& left, const UnknownValue& right) const { |