Read all the bytes into a buffer, then parse the buffer once you have the
whole thing.

On Mon, Jan 12, 2009 at 4:11 PM, chongyc <chongy...@gmail.com> wrote:

>
> Thank you very much for your help.
>
> I want parsing string 's' by reading each a byte from s.
>
> What is alternative way that you can recommend to me.
>
>
>
> On Jan 12, 11:28 am, 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to