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

Function ValueAsUInt32

common/values/parsed_map_field_value.cc:225–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225absl::optional<uint32_t> ValueAsUInt32(const Value& value) {
226 if (auto int_value = value.AsInt();
227 int_value && int_value->NativeValue() >= 0 &&
228 int_value->NativeValue() <= std::numeric_limits<uint32_t>::max()) {
229 return static_cast<uint32_t>(int_value->NativeValue());
230 } else if (auto uint_value = value.AsUint();
231 uint_value && uint_value->NativeValue() <=
232 std::numeric_limits<uint32_t>::max()) {
233 return static_cast<uint32_t>(uint_value->NativeValue());
234 } else if (auto double_value = value.AsDouble();
235 double_value &&
236 static_cast<double>(static_cast<uint32_t>(
237 double_value->NativeValue())) == double_value->NativeValue()) {
238 return static_cast<uint32_t>(double_value->NativeValue());
239 }
240 return absl::nullopt;
241}
242
243absl::optional<uint64_t> ValueAsUInt64(const Value& value) {
244 if (auto int_value = value.AsInt();

Callers 1

ValueToProtoMapKeyFunction · 0.85

Calls 4

AsIntMethod · 0.45
NativeValueMethod · 0.45
AsUintMethod · 0.45
AsDoubleMethod · 0.45

Tested by

no test coverage detected