How can protocol-buffers support serialization/deserialization of std containers?

Protocol buffers have employ a parser which takes a . Proto file and creates appropriate serialization routines. See this.

Protocol buffers have employ a parser which takes a . Proto file and creates appropriate serialization routines. See this.

Update: You can represent a vector of strings as: message MyCollection { repeated string str = 1; } in your proto file. And use: std::vector my_strings; // add strings to vector MyCollection proto; vector::iterator e = my_strings.end(); for (vector::iterator I = my_strings.begin(); I! = e; ++i) { *proto.

Add_str() = *i; } It should be easy to extend for another collection/collection of collections.

Google's tutorial has only presented how to serialze a simple structure. My requirement is about the std container. How to write proto files as what I have referred above?

– pinnacle Mar 26 '09 at 4:07 1 Updated with some code. – dirkgently Mar 26 '09 at 5:26.

The protobuf representation of your Foo would look something like this: message IntPair { required int32 first = 1; required int32 second = 2; }; message FooElem { required uint32 first = 1; repeated IntPair second = 2; }; message Foo { repeated FooElem data = 1; }; Note that Protocol Buffers doesn't provide a "seamless" (de)serialization to/from your own structures like Boost. Serialization does. You work with generated objects that come from running the protoc compiler on a file like the above.

These generated classes will not contain std::pair and std::vector members however, so you'll need to copy data too/from the generated objects if you want to keep working with your legacy Foo structure.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions