The proto file defined like this:
message HqMessage {
uint32 busi_no = 1;
google.protobuf.Any detail = 2;
}
message B0T4F1 {
uint32 MarketType = 501;
}
//---------------------------------------------------------------------
*STEP1, *use protobuf's reflection, I had set the message of BOT4F1 to the
'detail':
.......
const google::protobuf::Descriptor* _detail_des =
_des_pool->FindMessageTypeByName("B0T4F1");
const google::protobuf::Message* _detail_prototype_message =
m_dynamic_factory.GetPrototype(_detail_des);
google::protobuf::Message* _detail_msg =
_detail_prototype_message->New();
const google::protobuf::Reflection* _detail_msg_ref =
_detail_prototype_message->GetReflection();
const google::protobuf::FieldDescriptor* _detail_fd =
_detail_des->FindFieldByNumber(501);
uint32 mkt_type =100;
_fd = _des->FindFieldByNumber(2);
_msg_ref ->*SetAllocatedMessage(*_msg, _detail_msg, _fd);
.......
*STEP2,*serialize the message to a buffer, then parse the HqMessage from
the buffer.
*STEP3**, firest, *I get the message of Any, then serialize the any message
to buffer again. Finally,get the message object of B0T4F1 through the new
buffer.
How can i parse the buffer to the message of B0T4F1 without serialize
’detail' message again. Could I get the ‘B0T4F1' message from 'HqMessage '
directly? How can i do this?
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" 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/protobuf/255992c9-313f-4d48-97d9-24722bf7437dn%40googlegroups.com.