Suppose those strings are all defined as optional fields in the message. They may not be present in the serialization, so the decoder needs to read a tag to determine the field number and type before handling the value.
On Wed, Aug 11, 2010 at 8:37 AM, Prakash Rao <[email protected]>wrote: > Hi, > I was just looking at CodedInputStream class and there are APIs to > write primitives with or without tag (for example, writeString & > writeStringNoTag). I thought if we set unique tags for multiple > parameters then we would be able to retrieve these parameters using > tag numbers specified using CodedInputStream class. I don't see any > APIs to read values based on tags in CodedInputStream. Am I missing > something? For the time being I’m using pushLimit & popLimit APIs to > get different parameter values (based on serializedSize). > > For example, > int test(String s1, String s2, String s3) { > } > > CodedOutputStream out = CodedOutputStream.newIInstance("Some Output > Stream"); > out.writeString(1, s1); > out.writeString(2, s2); > out.writeString(3, s3); > out.flush(); > > Why these are not possible? > CodedInputStream in = CodedInputStream.newIInstance("Some Input > Stream"); > String s1 = in.readString(1); > String s2 = in.readString(2); > String s3 = in.readString(3); > > Regards, > Prakash > > > > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<protobuf%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/protobuf?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
