I have c# code which serialize an objects (using protobuf-net) and I am able to deserialize it in c++ using protocol buffer. The serialize data is the form as <header><MsgLen><Msg><header><MsgLen><Msg>. I extract it using code below
OOGLE_PROTOBUF_VERIFY_VERSION; string fpath = "animal.bin"; fstream input(fpath, ios::in | ios::binary);if (!input){ cerr << "failed to open " << fpath << endl; return false;}ZeroCopyInputStream *raw_in = new IstreamInputStream(&input);CodedInputStream *coded_in = new CodedInputStream(raw_in); google::protobuf::uint32 n; std::string tmpStr; animal::animalInfo animalList; coded_in->ReadVarint32(&n); cout << "# " << n << endl; //output: #10 coded_in->ReadRaw(&tmpStr,n); //tmpStr shows data like >>1..Rat..Ch animalList.ParseFromArray(&tmpStr,1); //Get serialized data to animalList While it does the job. I am wondering what is the recommended way for doing this in protocol buffer. Specially I will like not to have to directly read Varint32 etc from "<header><MsgLen><Msg>" to get 1 message @ a time. Also more importantly, how can I extract all the objects together ? Any advice here will be helpful. Thanks -- 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 protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf?hl=en. For more options, visit https://groups.google.com/groups/opt_out.