It's very likely that your problem can be better solved using extensions. http://code.google.com/apis/protocolbuffers/docs/proto.html#extensions
For example, you could do: message Field { required string name = 1; optional int32 int32_value = 2; optional int64 int64_value = 3; optional double double_value = 4; optional string string_value = 5; // ... extensions 100 to max; // For types not listed above. } // Elsewhere message Bar { ... } extend Field { optional Bar bar_value_ext = 123; } For every type that you want Field to be able to contain, you need to define an extension like bar_value_ext. On Wed, Apr 8, 2009 at 5:24 AM, <ra...@raisoftware.ro> wrote: > > Hello, > > I have been searching ProtoBufs documentation for hours and I could > not find a simple feature: how to write a generic type, which is > determined at runtime, similar to "object". As far as I can see all > values need to have specific types. Suppose I want to serialize an > object: > > message Object > > { > > message Field > > { > > required string name = 1; > > required string value = 2; > > } > > optional string objectType = 1; > > repeated Field fields = 2; > > } > > How can I make Field.value be of any type (="object")? > > Thrift doesnt have it, Cisco Etch and Hessian have it. ProtoBuffs > toolchain looks the best support, but this is showstopper problem for > us. > > I appreciate your answer. > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---