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

Method MessageMapFieldToJson

internal/json.cc:793–816  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

791 }
792
793 absl::Status MessageMapFieldToJson(
794 const google::protobuf::Message& message,
795 const google::protobuf::FieldDescriptor* absl_nonnull field,
796 google::protobuf::MessageLite* absl_nonnull result) {
797 const auto* reflection = message.GetReflection();
798 if (reflection->FieldSize(message, field) == 0) {
799 return absl::OkStatus();
800 }
801 const auto key_to_string =
802 GetMapFieldKeyToString(field->message_type()->map_key());
803 const auto* value_descriptor = field->message_type()->map_value();
804 CEL_ASSIGN_OR_RETURN(const auto value_to_value,
805 GetMapFieldValueToValue(value_descriptor));
806 auto begin = extensions::protobuf_internal::ConstMapBegin(*reflection,
807 message, *field);
808 const auto end = extensions::protobuf_internal::ConstMapEnd(
809 *reflection, message, *field);
810 for (; begin != end; ++begin) {
811 auto key = (*key_to_string)(begin.GetKey());
812 CEL_RETURN_IF_ERROR((this->*value_to_value)(
813 begin.GetValueRef(), value_descriptor, InsertField(result, key)));
814 }
815 return absl::OkStatus();
816 }
817
818 absl::Status MessageRepeatedFieldToJson(
819 const google::protobuf::Message& message,

Callers

nothing calls this directly

Calls 5

GetMapFieldKeyToStringFunction · 0.85
ConstMapBeginFunction · 0.85
ConstMapEndFunction · 0.85
GetKeyMethod · 0.80
GetReflectionMethod · 0.45

Tested by

no test coverage detected