On Mon, Aug 24, 2009 at 4:17 PM, Jay Thomas<jaydianetho...@gmail.com> wrote:
>
> This code ideally has to operate with C# code on the other side of the
> socket that uses the DeserializeWithLengthPrefix() method call.  The
> message originates in C++ environment on a linux box and terminates in
> C# environment on a windows PC.

I'm not familiar with the implementation of
DeserializeWithLengthPrefix(). The same idea should work, but you'll
have to go into the protobuf-net source to see what it uses to write
the length with. If it's not a Varint32 then just adjust it to
whatever it needs to be.

> Why doesn't C++ support the same methods as C#?

They're different projects. protobuf-net has a different maintainer
than the protobuf project.

> The only document that I've seen that has list of
> methods available is the message.h header file, installed into my
> Linux usr directory.

This is the documentation for the generated C++ code, which really
just deals with the fields that are generated by the protoc compliler:

http://code.google.com/apis/protocolbuffers/docs/reference/cpp-generated.html

This is the documentation for the C++ library as a whole:

http://code.google.com/apis/protocolbuffers/docs/reference/cpp/index.html

This is the documentation for the C++ version of Message:

http://code.google.com/apis/protocolbuffers/docs/reference/cpp/google.protobuf.message.html

This is the documentation for the coded_stream stuff I was talking about:

http://code.google.com/apis/protocolbuffers/docs/reference/cpp/google.protobuf.io.coded_stream.html#CodedInputStream.Limit.details

--Pete

>
>
> On Aug 24, 4:05 pm, Peter Keen <peter.k...@gmail.com> wrote:
>> You sort of have to roll your own. In my project I'm doing something like 
>> this:
>>
>> coded_output->WriteVarint32(message->ByteSize());
>> message->SerializeToCodedStream(coded_output);
>>
>> And then on the reading side:
>>
>> uint32_t size;
>> if (! coded_input->ReadVarint32(&size)) {
>>   return NULL; // just an example. probably don't want to do this;
>>
>> }
>>
>> Message * m = new Message;
>> CodedInputStream::Limit limit = coded_input->PushLimit(size);
>> message->ParseFromCodedStream(coded_input);
>> coded_input->PopLimit(limit);
>>
>> The biggest thing that helped me along was finding the Limit docs. I
>> couldn't figure out how to parse from a ZeroCopyInputStream without
>> consuming the entire stream, and then I ran across that and everything
>> became much more clear.
>>
>> --Pete
>>
>> On Mon, Aug 24, 2009 at 3:54 PM, Jay Thomas<jaydianetho...@gmail.com> wrote:
>>
>> > Hello
>>
>> > I am looking for a way to serialize/deserialize with length prefix
>> > under c++.  The serialized bytes will sent to a TCP socket.  I am
>> > aware that C# has a method SerializeWithLengthPrefix() and
>> > DeserializeWithLengthPrefix().  Are there any such analogous methods
>> > for C++? Please point out any documentation that I may have missed
>> > here.
>>
>> > Thanks for any assistance.
>>
>> > Jay
> >
>

--~--~---------~--~----~------------~-------~--~----~
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