Google protocol buffers compare

dimba picture dimba · Jul 12, 2010 · Viewed 27.3k times · Source

I want to compare two Messages or (two sub parameters) of Google protocol buffers. I don't find an API to achieve it.

Any ideas?

Answer

Amiga picture Amiga · Sep 2, 2015

You can use the class google::protobuf::util::MessageDifferencer for this. I think it's only available since v3.0.2:

Introduced new utility functions/classes in the google/protobuf/util directory:

  • MessageDifferencer: compare two proto messages and report their differences.
#include <google/protobuf/util/message_differencer.h>

MessageDifferencer::Equals(msg1, msg2);