Hi,

I am using reflection to phrase a message.
handling repeated messages and cpp type fields works. But message type 
fields fails due to Reflection::GetMessage
This is the related code snippet:

void f(const ::google::protobuf::Message &msg)
{
const google::protobuf::Reflection *reflection = msg.GetReflection();

std::vector<const ::google::protobuf::FieldDescriptor *> allFileds;
reflection->ListFields(msg, &allFileds);
for (auto &field : allFileds)
{
if (true == field->is_repeated())
{
                         // reflection->GetRepeatedMessage   --> works just 
fine and returns the message object
                }
else
{
if (::google::protobuf::FieldDescriptor::CppType::CPPTYPE_MESSAGE == 
field->cpp_type())
{
// This is the problem, the returned object is not a valid one
const ::google::protobuf::Message &msg_type = reflection->GetMessage(msg, 
field);
}
else
{
}

                }
}


the protobuf looks like this:

SomeRepeatedMessage {
        uint32 f1 = 1;
        uint32 f2 = 2;
}
SomeRepeatedMessage2 {
        uint32 f1 = 1;
        uint32 f2 = 2;
}

message SomeRequest {
        uint32 f1 = 1;
        repeated SomeRepeatedMessage f2 = 2;
SomeRepeatedMessage f3 = 3;
}


When the method runs on SomeRequest all is OK, until f3 where the 
GetMessage fails

Thanks for the help

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/031aa90d-6dae-4f7e-83d8-990235e233fa%40googlegroups.com.

Reply via email to