Have a look at protobuf reflection API here: https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.message You also need to know about descriptors to use reflection:
https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.descriptor On Fri, Jan 11, 2013 at 11:39 PM, Klaim J. Lamotte <mjkl...@gmail.com>wrote: > Hi, > > I'm using protobuf 2.5. > > Looking at the generated code of my messages and the documentation, I > don't see a function that > would be generated and would know how to check all fields, both required > and optional, see > if they are all set (check the has_ members). > > If such function already exists, could you point me to it please? I might > have missed something. > > To explain my context: > I have messages being basically "state" message of different objects, > which provide full or partial state of an object. > These messages are used in other messages that might send partial update > or full update/creation of an object. > Now, in some cases, I expect full updates, which means optional fields > MUST be set when I receive the message (typically when I receive a message > saying an object have been created on the server). > I want to add an assertion that the message is complete, but as said I > can't find a way to do this. > Using only required fields would be expensive and duplicate code (though > I'm consider doing that - I don't know if networking will be a bottleneck > yet). > The IsInitialized() function is obviously not enough in my case. > > Thanks for your time. > > Joel Lamotte > > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/protobuf/-/_k9eV1N1GKgJ. > 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. > -- 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.