I have certain protobuf messages with the same structure. For example:
//filename foo.proto
message Foo
{
message Bar
{
optional int32 foo_bar_field1 = 1;
repeated uint32 foo_bar_field2 = 2;
}
}
message Baz
{
message Bar
{
optional int32 field = 1;
}
}
message BetterFoo
{
optional Foo.Bar field = 1;
}
message BetterBaz
{
optional Baz.Bar field = 1;
}
*BetterFoo* and *BetterBaz* both have internal *Baz* message with different
fields. Instead of completely writing almost the same code for both
messages I'd like to have the following:
//filename wanted_foo.proto
message Foo
{
message Bar
{
optional int32 foo_bar_field1 = 1;
repeated uint32 foo_bar_field2 = 2;
}
}
message Baz
{
message Bar
{
optional int32 field = 1;
}
}
message Better(Foo);
message Better(Baz);
Message *Better*(X) is kind of a macro/template which should be expanded
before compiling the code.
Since sub message *Bar* is different in *Foo* and *Baz* I cannot create a
common message and use it inside each one.
I don't know of any precompiler for protobuf or any other solution to
achieve this.
Is it worthwhile creating such a precompiler which it's output is passed to
protobuf compiler?
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.