auto proto_des = 
google::protobuf::DescriptorPool::generated_pool()->FindMessageTypeByName(typeName);
auto proto_type = 
google::protobuf::MessageFactory::generated_factory()->GetPrototype(descriptor);
auto protobuf_message = type->New();
protobuf_message->ParseFromArray(buf, len);

when we know "typeName", 
we can get protobuf_message from an knowned length buf.

if we dont know "typeName", but we know this length of buf is of couse a 
protobuf message!!!
can we unserialize this buf to an protobuf message instance??

just like c struct:
struct T
{
int v;
};
T a;
a.v = 5;
char buf[128] = {0};
memcpy(buf, &a, sizeof(T));

T b;
memcpy(&b, buf, sizeof(T));
/////
we can get b.v = 5;

can protobuf just act like 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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to