is_equal.h 981 B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include <util/generic/fwd.h>
  3. namespace google {
  4. namespace protobuf {
  5. class Message;
  6. class FieldDescriptor;
  7. }
  8. }
  9. namespace NProtoBuf {
  10. using ::google::protobuf::FieldDescriptor;
  11. using ::google::protobuf::Message;
  12. }
  13. namespace NProtoBuf {
  14. // Reflection-based equality check for arbitrary protobuf messages
  15. // Strict comparison: optional field without value is NOT equal to
  16. // a field with explicitly set default value.
  17. bool IsEqual(const Message& m1, const Message& m2);
  18. bool IsEqual(const Message& m1, const Message& m2, TString* differentPath);
  19. bool IsEqualField(const Message& m1, const Message& m2, const FieldDescriptor& field);
  20. // Non-strict version: optional field without explicit value is compared
  21. // using its default value.
  22. bool IsEqualDefault(const Message& m1, const Message& m2);
  23. bool IsEqualFieldDefault(const Message& m1, const Message& m2, const FieldDescriptor& field);
  24. }