MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / MaxList

Function MaxList

extensions/math_ext.cc:144–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144absl::StatusOr<Value> MaxList(
145 const ListValue& values,
146 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
147 google::protobuf::MessageFactory* absl_nonnull message_factory,
148 google::protobuf::Arena* absl_nonnull arena) {
149 CEL_ASSIGN_OR_RETURN(auto iterator, values.NewIterator());
150 if (!iterator->HasNext()) {
151 return ErrorValue(
152 absl::InvalidArgumentError("math.@max argument must not be empty"));
153 }
154 Value value;
155 CEL_RETURN_IF_ERROR(
156 iterator->Next(descriptor_pool, message_factory, arena, &value));
157 absl::StatusOr<CelNumber> current = ValueToNumber(value, kMathMax);
158 if (!current.ok()) {
159 return ErrorValue{current.status()};
160 }
161 CelNumber min = *current;
162 while (iterator->HasNext()) {
163 CEL_RETURN_IF_ERROR(
164 iterator->Next(descriptor_pool, message_factory, arena, &value));
165 absl::StatusOr<CelNumber> other = ValueToNumber(value, kMathMax);
166 if (!other.ok()) {
167 return ErrorValue{other.status()};
168 }
169 min = MaxNumber(min, *other);
170 }
171 return NumberToValue(min);
172}
173
174template <typename T, typename U>
175absl::Status RegisterCrossNumericMin(FunctionRegistry& registry) {

Callers

nothing calls this directly

Calls 7

ErrorValueFunction · 0.85
ValueToNumberFunction · 0.85
MaxNumberFunction · 0.85
NumberToValueFunction · 0.85
HasNextMethod · 0.45
NextMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected