diff options
| author | Devtools Arcadia <[email protected]> | 2022-02-07 18:08:42 +0300 |
|---|---|---|
| committer | Devtools Arcadia <[email protected]> | 2022-02-07 18:08:42 +0300 |
| commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
| tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/protobuf/util/is_equal.h | |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/protobuf/util/is_equal.h')
| -rw-r--r-- | library/cpp/protobuf/util/is_equal.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/library/cpp/protobuf/util/is_equal.h b/library/cpp/protobuf/util/is_equal.h new file mode 100644 index 00000000000..13c0aae63d9 --- /dev/null +++ b/library/cpp/protobuf/util/is_equal.h @@ -0,0 +1,33 @@ +#pragma once + +#include <util/generic/fwd.h> + +namespace google { + namespace protobuf { + class Message; + class FieldDescriptor; + } +} + +namespace NProtoBuf { + using ::google::protobuf::FieldDescriptor; + using ::google::protobuf::Message; +} + +namespace NProtoBuf { + // Reflection-based equality check for arbitrary protobuf messages + + // Strict comparison: optional field without value is NOT equal to + // a field with explicitly set default value. + bool IsEqual(const Message& m1, const Message& m2); + bool IsEqual(const Message& m1, const Message& m2, TString* differentPath); + + bool IsEqualField(const Message& m1, const Message& m2, const FieldDescriptor& field); + + // Non-strict version: optional field without explicit value is compared + // using its default value. + bool IsEqualDefault(const Message& m1, const Message& m2); + + bool IsEqualFieldDefault(const Message& m1, const Message& m2, const FieldDescriptor& field); + +} |
