aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/util/message_differencer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/util/message_differencer.h')
-rw-r--r--src/google/protobuf/util/message_differencer.h83
1 files changed, 45 insertions, 38 deletions
diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h
index bbcf8498..9419267e 100644
--- a/src/google/protobuf/util/message_differencer.h
+++ b/src/google/protobuf/util/message_differencer.h
@@ -51,6 +51,8 @@
#include <google/protobuf/unknown_field_set.h>
#include <google/protobuf/util/field_comparator.h>
+#include <google/protobuf/port_def.inc>
+
namespace google {
namespace protobuf {
@@ -60,7 +62,7 @@ class FieldDescriptor;
namespace io {
class ZeroCopyOutputStream;
class Printer;
-}
+} // namespace io
namespace util {
@@ -106,7 +108,7 @@ class FieldContext; // declared below MessageDifferencer
// guard it with a lock to use the same MessageDifferencer instance from
// multiple threads. Note that it's fine to call static comparison methods
// (like MessageDifferencer::Equals) concurrently.
-class LIBPROTOBUF_EXPORT MessageDifferencer {
+class PROTOBUF_EXPORT MessageDifferencer {
public:
// Determines whether the supplied messages are equal. Equality is defined as
// all fields within the two messages being set to the same value. Primitive
@@ -212,7 +214,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
// FieldDescriptors. The first will be the field of the embedded message
// itself and the second will be the actual field in the embedded message
// that was added/deleted/modified.
- class LIBPROTOBUF_EXPORT Reporter {
+ class PROTOBUF_EXPORT Reporter {
public:
Reporter();
virtual ~Reporter();
@@ -290,7 +292,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
// MapKeyComparator is used to determine if two elements have the same key
// when comparing elements of a repeated field as a map.
- class LIBPROTOBUF_EXPORT MapKeyComparator {
+ class PROTOBUF_EXPORT MapKeyComparator {
public:
MapKeyComparator();
virtual ~MapKeyComparator();
@@ -313,7 +315,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
// field IsIgnored is called on each added IgnoreCriteria until one returns
// true or all return false.
// IsIgnored is called for fields where at least one side has a value.
- class LIBPROTOBUF_EXPORT IgnoreCriteria {
+ class PROTOBUF_EXPORT IgnoreCriteria {
public:
IgnoreCriteria();
virtual ~IgnoreCriteria();
@@ -533,6 +535,12 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
report_moves_ = report_moves;
}
+ // Tells the differencer whether or not to report ignored values. This method
+ // must be called before Compare. The default for a new differencer is true.
+ void set_report_ignores(bool report_ignores) {
+ report_ignores_ = report_ignores;
+ }
+
// Sets the scope of the comparison (as defined in the Scope enumeration
// above) that is used by this differencer when determining which fields to
// compare between the messages.
@@ -573,7 +581,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
// Automatically creates a reporter that will output the differences
// found (if any) to the specified output string pointer. Note that this
// method must be called before Compare.
- void ReportDifferencesToString(string* output);
+ void ReportDifferencesToString(std::string* output);
// Tells the MessageDifferencer to report differences via the specified
// reporter. Note that this method must be called before Compare for
@@ -593,11 +601,11 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
// complete until after you destroy the reporter. For example, if you use a
// StreamReporter to write to a StringOutputStream, the target string may
// contain uninitialized data until the reporter is destroyed.
- class LIBPROTOBUF_EXPORT StreamReporter : public Reporter {
+ class PROTOBUF_EXPORT StreamReporter : public Reporter {
public:
explicit StreamReporter(io::ZeroCopyOutputStream* output);
explicit StreamReporter(io::Printer* printer); // delimiter '$'
- virtual ~StreamReporter();
+ ~StreamReporter() override;
// When set to true, the stream reporter will also output aggregates nodes
// (i.e. messages and groups) whose subfields have been modified. When
@@ -607,32 +615,28 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
}
// The following are implementations of the methods described above.
- virtual void ReportAdded(const Message& message1, const Message& message2,
- const std::vector<SpecificField>& field_path);
- virtual void ReportDeleted(const Message& message1,
- const Message& message2,
- const std::vector<SpecificField>& field_path);
+ void ReportAdded(const Message& message1, const Message& message2,
+ const std::vector<SpecificField>& field_path) override;
- virtual void ReportModified(const Message& message1,
- const Message& message2,
- const std::vector<SpecificField>& field_path);
+ void ReportDeleted(const Message& message1, const Message& message2,
+ const std::vector<SpecificField>& field_path) override;
- virtual void ReportMoved(const Message& message1,
- const Message& message2,
- const std::vector<SpecificField>& field_path);
+ void ReportModified(const Message& message1, const Message& message2,
+ const std::vector<SpecificField>& field_path) override;
- virtual void ReportMatched(const Message& message1,
- const Message& message2,
- const std::vector<SpecificField>& field_path);
+ void ReportMoved(const Message& message1, const Message& message2,
+ const std::vector<SpecificField>& field_path) override;
- virtual void ReportIgnored(const Message& message1,
- const Message& message2,
- const std::vector<SpecificField>& field_path);
+ void ReportMatched(const Message& message1, const Message& message2,
+ const std::vector<SpecificField>& field_path) override;
- virtual void ReportUnknownFieldIgnored(
+ void ReportIgnored(const Message& message1, const Message& message2,
+ const std::vector<SpecificField>& field_path) override;
+
+ void ReportUnknownFieldIgnored(
const Message& message1, const Message& message2,
- const std::vector<SpecificField>& field_path);
+ const std::vector<SpecificField>& field_path) override;
protected:
// Prints the specified path of fields to the buffer. message is used to
@@ -657,7 +661,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
virtual void PrintUnknownFieldValue(const UnknownField* unknown_field);
// Just print a string
- void Print(const string& str);
+ void Print(const std::string& str);
private:
io::Printer* printer_;
@@ -677,11 +681,12 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
class MultipleFieldsMapKeyComparator;
// A MapKeyComparator for use with map_entries.
- class LIBPROTOBUF_EXPORT MapEntryKeyComparator : public MapKeyComparator {
+ class PROTOBUF_EXPORT MapEntryKeyComparator : public MapKeyComparator {
public:
explicit MapEntryKeyComparator(MessageDifferencer* message_differencer);
- virtual bool IsMatch(const Message& message1, const Message& message2,
- const std::vector<SpecificField>& parent_fields) const;
+ bool IsMatch(
+ const Message& message1, const Message& message2,
+ const std::vector<SpecificField>& parent_fields) const override;
private:
MessageDifferencer* message_differencer_;
@@ -711,8 +716,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
// Compares all the unknown fields in two messages.
bool CompareUnknownFields(const Message& message1, const Message& message2,
- const google::protobuf::UnknownFieldSet&,
- const google::protobuf::UnknownFieldSet&,
+ const UnknownFieldSet&, const UnknownFieldSet&,
std::vector<SpecificField>* parent_fields);
// Compares the specified messages for the requested field lists. The field
@@ -859,8 +863,9 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
bool report_matches_;
bool report_moves_;
+ bool report_ignores_;
- string* output_string_;
+ std::string* output_string_;
std::unique_ptr<DynamicMessageFactory> dynamic_message_factory_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageDifferencer);
@@ -868,7 +873,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
// This class provides extra information to the FieldComparator::Compare
// function.
-class LIBPROTOBUF_EXPORT FieldContext {
+class PROTOBUF_EXPORT FieldContext {
public:
explicit FieldContext(
std::vector<MessageDifferencer::SpecificField>* parent_fields)
@@ -882,8 +887,10 @@ class LIBPROTOBUF_EXPORT FieldContext {
std::vector<MessageDifferencer::SpecificField>* parent_fields_;
};
-}
-}
-
+} // namespace util
+} // namespace protobuf
} // namespace google
+
+#include <google/protobuf/port_undef.inc>
+
#endif // GOOGLE_PROTOBUF_UTIL_MESSAGE_DIFFERENCER_H__