diff options
Diffstat (limited to 'src/google/protobuf/util/field_comparator.h')
-rw-r--r-- | src/google/protobuf/util/field_comparator.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/google/protobuf/util/field_comparator.h b/src/google/protobuf/util/field_comparator.h index 715560ed..27ef4c77 100644 --- a/src/google/protobuf/util/field_comparator.h +++ b/src/google/protobuf/util/field_comparator.h @@ -30,13 +30,12 @@ // Defines classes for field comparison. -// Author: ksroka@google.com (Krzysztof Sroka) - #ifndef GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__ #define GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__ #include <map> #include <string> +#include <vector> #include <google/protobuf/stubs/common.h> @@ -50,6 +49,7 @@ class FieldDescriptor; namespace util { class FieldContext; +class MessageDifferencer; // Base class specifying the interface for comparing protocol buffer fields. // Regular users should consider using or subclassing DefaultFieldComparator @@ -155,6 +155,15 @@ class LIBPROTOBUF_EXPORT DefaultFieldComparator : public FieldComparator { // REQUIRES: float_comparison_ == APPROXIMATE void SetDefaultFractionAndMargin(double fraction, double margin); + protected: + // Compare using the provided message_differencer. For example, a subclass can + // use this method to compare some field in a certain way using the same + // message_differencer instance and the field context. + bool Compare(MessageDifferencer* differencer, + const google::protobuf::Message& message1, + const google::protobuf::Message& message2, + const google::protobuf::util::FieldContext* field_context); + private: // Defines the tolerance for floating point comparison (fraction and margin). struct Tolerance { @@ -169,7 +178,7 @@ class LIBPROTOBUF_EXPORT DefaultFieldComparator : public FieldComparator { }; // Defines the map to store the tolerances for floating point comparison. - typedef map<const FieldDescriptor*, Tolerance> ToleranceMap; + typedef std::map<const FieldDescriptor*, Tolerance> ToleranceMap; // The following methods get executed when CompareFields is called for the // basic types (instead of submessages). They return true on success. One @@ -239,7 +248,7 @@ class LIBPROTOBUF_EXPORT DefaultFieldComparator : public FieldComparator { // True iff default_tolerance_ has been explicitly set. // - // If false, then the default tolerance for flaots and doubles is that which + // If false, then the default tolerance for floats and doubles is that which // is used by MathUtil::AlmostEquals(). bool has_default_tolerance_; |