Sorry, you can't use MergeFromCodedStream() like that. The input needs to be a complete message, which will then be merged into the existing message object.
On Sun, Jan 11, 2009 at 7:28 PM, chongyc <chongy...@gmail.com> wrote: > > I write test code following below. > > > t2r::prot::Request msg0, msg2, msg3, msg4; > std::string s; > > // set all fields of msg. > ..... > ..... > > bool b; > b = msg0.SerializeToString(&s); // OK > msg0.PrintDebugString(); > > b = msg2.ParseFromString(s); // OK > b = msg2.IsInitialized(); // OK > msg0.PrintDebugString(); > > for(int i= 0; i < s.size(); ++i) > { > char c = s[i]; > > std::cout << "============== " << i << " > =====================" << > std::endl; > > google::protobuf::io::ArrayInputStream inp(&c, 1); > google::protobuf::io::CodedInputStream decoder(&inp); > b = msg3.MergeFromCodedStream(&decoder); // > FAILED > msg3.PrintDebugString(); > > std::cout << "********************************" << > std::endl; > > b = msg4.MergePartialFromCodedStream > (&decoder); // OK > msg4.PrintDebugString(); > b = msg4.IsInitialized(); // FAILED > } > > b = msg3.IsInitialized(); // FAILED > b = msg4.IsInitialized(); // FAILED > > > I want parsing string 's' by reading each a byte from s. > What is wrong. > Please help me. > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~----------~----~----~----~------~----~------~--~---