Now , I wrote like this.

message head
{
   requirement int command = 1;
   requeirment string mask = 2;
   ... and so on.
   optional bytes module = 10;
}

All these module PB objects SerializeToString() into head_instance's 
module column.

It is ok , between C++ and Python.



SuKai 写道:
> I want to define my protocol with PB.
>
> So, first I define the protocol head.
> message head
> {
>    requirement int command = 1;
>    requeirment string mask = 2;
>    ... and so on.
>    optional Module_A ma = 10;
>    optional Module_B mb = 11;
>    ... and so on.
> }
>
> message Module_A
> {
>    ...
> }
>
> message Module_B
> {
>    ...
> }
>
> All these modules are increasing.
>
> I want to construct this protocol with PB .
>
> Initial, I think fill these modules PB objects into head_instance's 
> colum(this is a string type).
>
> Kenton Varda 写道:
>> I don't quite understand your question.  It's safe to add new fields 
>> to a protocol buffer.
>>
>> If you want to store all the values as one unit -- for instance, so 
>> that old releases that don't know about new fields still know that 
>> the fields represent the same "column" -- you could always wrap them 
>> in another message like:
>>
>> message A {
>>   required UserUnion user = 1;
>> }
>>
>> message UserUnion {
>>   optional B b = 1;
>>   optional C c = 2;
>>   optional D d = 3;
>> }
>>
>> Code which just passes around UserUnion objects without looking 
>> inside will work even if
>> On Wed, Oct 21, 2009 at 6:19 PM, SuKai <sukai090...@gmail.com 
>> <mailto:sukai090...@gmail.com>> wrote:
>>
>>     I release this proto at R1:
>>
>>     message A {
>>     optional B user_b = 1;
>>     optional C user_c = 2;
>>     optional D user_d = 3;
>>     }
>>
>>     but if I find some fault with this proto or extend this proto at R2:
>>
>>     message A {
>>     optional B user_b = 1;
>>     optional C user_c = 2;
>>     optional E user_d = 3;
>>     optional F user_e = 4;
>>     }
>>
>>     So , I want use R1's proto instance to encode this message on R2'
>>     proto instance.
>>     Can I get the true value for the same colums (user_b & user_c) 
>> value?
>>
>>     Thanks.
>>
>>
>>     Kenton Varda 写道:
>>
>>         On Wed, Oct 21, 2009 at 6:04 PM, SuKai <sukai090...@gmail.com
>>         <mailto:sukai090...@gmail.com> <mailto:sukai090...@gmail.com
>>         <mailto:sukai090...@gmail.com>>> wrote:
>>
>>            Because A_instance.user stored with different type of PB.
>>
>>            Fill A_instance.user with B, C, or D , these are diff PB
>>         objects.
>>
>>
>>         Then you should have three different fields:
>>
>>         message A {
>>         optional B user_b = 1;
>>         optional C user_c = 2;
>>         optional D user_d = 3;
>>         }
>>
>>
>

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