Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the simplest way to compare two google::protobuf::Message objects with each other?

Tags:

People also ask

What does oneof mean in Protobuf?

Protocol Buffer (Protobuf) provides two simpler options for dealing with values that might be of more than one type. The Any type can represent any known Protobuf message type. And you can use the oneof keyword to specify that only one of a range of fields can be set in any message.

What are Google protocol buffers used for?

What are protocol buffers? Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler.

What is the advantage of Protobuf?

Some of the advantages of using protocol buffers include: Compact data storage. Fast parsing. Availability in many programming languages.

What are Protobuf messages?

Protocol Buffers (Protobuf) is a free and open-source cross-platform data format used to serialize structured data. It is useful in developing programs to communicate with each other over a network or for storing data.


I want to compare two arbitrary google::protobuf::Message objects.

I assume that objects are equal when

  • their descriptions contain fields with equal field numbers and corresponding field types.
  • their reflections have same set of fields (and the same number of repeated fields) and equal corresponding field values.

I know, that I can write such comparison function by myself, but may be there is already some simple or predefined solution?

Also, may be I'm missing some principal issue about incomparability of such objects - I would like to know if it's so.