Hi All,
I'd like to extend protocol buffers by something like this:
message DateFormat {
optional int32 year = 1 [default = 1970; min = 1970; max = 2010];
optional int32 month = 2 [min = 1; max = 12];
optional int32 day = 3 [min = 1; max = 31];
repeated OtherMsg foobar = 4 [max_size= 10];
}
And in the generated code:
DateFormat msg;
...
// returns true if all members are between max and min
bool success = msg.sanityCheck();
// calculate the maximum size of the serialized stream:
int max_bytestream_size = msg.MaxByteStreamSizeIfSerializedToString();
I'm just wondering what could be the easiest way to do this? I'm not too familiar with the deep details of protobufs.
My first approach was to write a small parser in python which generates helper classes. But it's not very nice, maybe there is nicer solution available.
Thx for hints,
Csaba