Hi,
Suppose I have such message structure:
package msg_RepAndOpt;
message RepAndOpt{
repeated string name = 1;
optional string surname = 2;
...
// there are lots of others.}
And I have two components that have copies of this message:
// component1:RepAndOpt A;
A.add_name("Name");
A.set_surname("Surname");
// component2:RepAndOpt B;
In my case components modify those messages via transaction mechanism. It
means that if one component changes some field it also sends it to another
component to propagate those changes. Component-receiver is doing merge:
// Component2 modifies B and sends it to component1.// Component1 perfoms merge:
A.MergeFrom(B);
Now, say, component2 wants to erase field "name". If it will send clear B
message (default construction) than:
- MergeFrom() will not modify A;
- CopyFrom() will erase also other fields.
Another way will be to fill B with the contents of A, clear name field and
component1 will use CopyFrom(). But this is not acceptable because system
is really high-loaded and there could be lots of other fields. So, desired
solution to clean name field is:
1. Component2 create B message.
2. Explicitly stores information that it want to erase only name field.
3. Component1 perform A.MergeFrom(B).
4. Result: A::name is cleared but other fields are left untouched.
As far as I tested this applies to repeated and optional fields. Is there
any ready-to-use solution or I should modify protobuf implementation?
--
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.