Index: third_party/protobuf/src/google/protobuf/util/message_differencer.h |
diff --git a/third_party/protobuf/src/google/protobuf/util/message_differencer.h b/third_party/protobuf/src/google/protobuf/util/message_differencer.h |
index 3ea74e673dd70d031160975dafe5202d1e64ad00..d99223cbd86a178b3b4869cd9af2857a7de92376 100644 |
--- a/third_party/protobuf/src/google/protobuf/util/message_differencer.h |
+++ b/third_party/protobuf/src/google/protobuf/util/message_differencer.h |
@@ -221,19 +221,19 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
// Reports that a field has been added into Message2. |
virtual void ReportAdded( |
const Message& message1, const Message& message2, |
- const vector<SpecificField>& field_path) = 0; |
+ const std::vector<SpecificField>& field_path) = 0; |
// Reports that a field has been deleted from Message1. |
virtual void ReportDeleted( |
const Message& message1, |
const Message& message2, |
- const vector<SpecificField>& field_path) = 0; |
+ const std::vector<SpecificField>& field_path) = 0; |
// Reports that the value of a field has been modified. |
virtual void ReportModified( |
const Message& message1, |
const Message& message2, |
- const vector<SpecificField>& field_path) = 0; |
+ const std::vector<SpecificField>& field_path) = 0; |
// Reports that a repeated field has been moved to another location. This |
// only applies when using TreatAsSet or TreatAsMap() -- see below. Also |
@@ -243,7 +243,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
virtual void ReportMoved( |
const Message& message1, |
const Message& message2, |
- const vector<SpecificField>& field_path) { } |
+ const std::vector<SpecificField>& field_path) { } |
// Reports that two fields match. Useful for doing side-by-side diffs. |
// This function is mutually exclusive with ReportModified and ReportMoved. |
@@ -252,7 +252,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
virtual void ReportMatched( |
const Message& message1, |
const Message& message2, |
- const vector<SpecificField>& field_path) { } |
+ const std::vector<SpecificField>& field_path) { } |
// Reports that two fields would have been compared, but the |
// comparison has been skipped because the field was marked as |
@@ -276,14 +276,14 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
virtual void ReportIgnored( |
const Message& message1, |
const Message& message2, |
- const vector<SpecificField>& field_path) { } |
+ const std::vector<SpecificField>& field_path) { } |
- // Report that an unkown field is ignored. (see comment above). |
+ // Report that an unknown field is ignored. (see comment above). |
// Note this is a different function since the last SpecificField in field |
// path has a null field. This could break existing Reporter. |
virtual void ReportUnknownFieldIgnored( |
const Message& message1, const Message& message2, |
- const vector<SpecificField>& field_path) {} |
+ const std::vector<SpecificField>& field_path) {} |
private: |
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Reporter); |
@@ -296,9 +296,10 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
MapKeyComparator(); |
virtual ~MapKeyComparator(); |
- virtual bool IsMatch(const Message& message1, |
- const Message& message2, |
- const vector<SpecificField>& parent_fields) const { |
+ virtual bool IsMatch( |
+ const Message& message1, |
+ const Message& message2, |
+ const std::vector<SpecificField>& parent_fields) const { |
GOOGLE_CHECK(false) << "IsMatch() is not implemented."; |
return false; |
} |
@@ -323,7 +324,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
const Message& message1, |
const Message& message2, |
const FieldDescriptor* field, |
- const vector<SpecificField>& parent_fields) = 0; |
+ const std::vector<SpecificField>& parent_fields) = 0; |
// Returns true if the unknown field should be ignored. |
// Note: This will be called for unknown fields as well in which case |
@@ -331,7 +332,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
virtual bool IsUnknownFieldIgnored( |
const Message& message1, const Message& message2, |
const SpecificField& field, |
- const vector<SpecificField>& parent_fields) { |
+ const std::vector<SpecificField>& parent_fields) { |
return false; |
} |
}; |
@@ -440,7 +441,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
// size of each element. |
void TreatAsMapWithMultipleFieldsAsKey( |
const FieldDescriptor* field, |
- const vector<const FieldDescriptor*>& key_fields); |
+ const std::vector<const FieldDescriptor*>& key_fields); |
// Same as TreatAsMapWithMultipleFieldsAsKey, except that each of the field |
// do not necessarily need to be a direct subfield. Each element in |
// key_field_paths indicate a path from the message being compared, listing |
@@ -456,7 +457,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
// !key_field_path[i]->is_repeated() |
void TreatAsMapWithMultipleFieldPathsAsKey( |
const FieldDescriptor* field, |
- const vector<vector<const FieldDescriptor*> >& key_field_paths); |
+ const std::vector<std::vector<const FieldDescriptor*> >& key_field_paths); |
// Uses a custom MapKeyComparator to determine if two elements have the same |
// key when comparing a repeated field as a map. |
@@ -549,9 +550,10 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
// Same as above, except comparing only the list of fields specified by the |
// two vectors of FieldDescriptors. |
- bool CompareWithFields(const Message& message1, const Message& message2, |
- const vector<const FieldDescriptor*>& message1_fields, |
- const vector<const FieldDescriptor*>& message2_fields); |
+ bool CompareWithFields( |
+ const Message& message1, const Message& message2, |
+ const std::vector<const FieldDescriptor*>& message1_fields, |
+ const std::vector<const FieldDescriptor*>& message2_fields); |
// Automatically creates a reporter that will output the differences |
// found (if any) to the specified output string pointer. Note that this |
@@ -570,6 +572,12 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
// any differences found in human-readable form to the supplied |
// ZeroCopyOutputStream or Printer. If a printer is used, the delimiter |
// *must* be '$'. |
+ // |
+ // WARNING: this reporter does not necessarily flush its output until it is |
+ // destroyed. As a result, it is not safe to assume the output is valid or |
+ // 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 { |
public: |
explicit StreamReporter(io::ZeroCopyOutputStream* output); |
@@ -585,35 +593,35 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
// The following are implementations of the methods described above. |
virtual void ReportAdded(const Message& message1, const Message& message2, |
- const vector<SpecificField>& field_path); |
+ const std::vector<SpecificField>& field_path); |
virtual void ReportDeleted(const Message& message1, |
const Message& message2, |
- const vector<SpecificField>& field_path); |
+ const std::vector<SpecificField>& field_path); |
virtual void ReportModified(const Message& message1, |
const Message& message2, |
- const vector<SpecificField>& field_path); |
+ const std::vector<SpecificField>& field_path); |
virtual void ReportMoved(const Message& message1, |
const Message& message2, |
- const vector<SpecificField>& field_path); |
+ const std::vector<SpecificField>& field_path); |
virtual void ReportMatched(const Message& message1, |
const Message& message2, |
- const vector<SpecificField>& field_path); |
+ const std::vector<SpecificField>& field_path); |
virtual void ReportIgnored(const Message& message1, |
const Message& message2, |
- const vector<SpecificField>& field_path); |
+ const std::vector<SpecificField>& field_path); |
virtual void ReportUnknownFieldIgnored( |
const Message& message1, const Message& message2, |
- const vector<SpecificField>& field_path); |
+ const std::vector<SpecificField>& field_path); |
protected: |
// Prints the specified path of fields to the buffer. |
- virtual void PrintPath(const vector<SpecificField>& field_path, |
+ virtual void PrintPath(const std::vector<SpecificField>& field_path, |
bool left_side); |
// Prints the value of fields to the buffer. left_side is true if the |
@@ -622,7 +630,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
// unknown_field_index1 or unknown_field_index2 when an unknown field |
// is encountered in field_path. |
virtual void PrintValue(const Message& message, |
- const vector<SpecificField>& field_path, |
+ const std::vector<SpecificField>& field_path, |
bool left_side); |
// Prints the specified path of unknown fields to the buffer. |
@@ -653,11 +661,11 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
// All fields present in both lists will always be included in the combined |
// list. Fields only present in one of the lists will only appear in the |
// combined list if the corresponding fields_scope option is set to FULL. |
- void CombineFields(const vector<const FieldDescriptor*>& fields1, |
+ void CombineFields(const std::vector<const FieldDescriptor*>& fields1, |
Scope fields1_scope, |
- const vector<const FieldDescriptor*>& fields2, |
+ const std::vector<const FieldDescriptor*>& fields2, |
Scope fields2_scope, |
- vector<const FieldDescriptor*>* combined_fields); |
+ std::vector<const FieldDescriptor*>* combined_fields); |
// Internal version of the Compare method which performs the actual |
// comparison. The parent_fields vector is a vector containing field |
@@ -665,34 +673,34 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
// (i.e. if the current message is an embedded message, the parent_fields |
// vector will contain the field that has this embedded message). |
bool Compare(const Message& message1, const Message& message2, |
- vector<SpecificField>* parent_fields); |
+ std::vector<SpecificField>* parent_fields); |
// Compares all the unknown fields in two messages. |
bool CompareUnknownFields(const Message& message1, const Message& message2, |
const google::protobuf::UnknownFieldSet&, |
const google::protobuf::UnknownFieldSet&, |
- vector<SpecificField>* parent_fields); |
+ std::vector<SpecificField>* parent_fields); |
// Compares the specified messages for the requested field lists. The field |
// lists are modified depending on comparison settings, and then passed to |
// CompareWithFieldsInternal. |
bool CompareRequestedFieldsUsingSettings( |
const Message& message1, const Message& message2, |
- const vector<const FieldDescriptor*>& message1_fields, |
- const vector<const FieldDescriptor*>& message2_fields, |
- vector<SpecificField>* parent_fields); |
+ const std::vector<const FieldDescriptor*>& message1_fields, |
+ const std::vector<const FieldDescriptor*>& message2_fields, |
+ std::vector<SpecificField>* parent_fields); |
// Compares the specified messages with the specified field lists. |
bool CompareWithFieldsInternal( |
const Message& message1, const Message& message2, |
- const vector<const FieldDescriptor*>& message1_fields, |
- const vector<const FieldDescriptor*>& message2_fields, |
- vector<SpecificField>* parent_fields); |
+ const std::vector<const FieldDescriptor*>& message1_fields, |
+ const std::vector<const FieldDescriptor*>& message2_fields, |
+ std::vector<SpecificField>* parent_fields); |
// Compares the repeated fields, and report the error. |
bool CompareRepeatedField(const Message& message1, const Message& message2, |
const FieldDescriptor* field, |
- vector<SpecificField>* parent_fields); |
+ std::vector<SpecificField>* parent_fields); |
// Shorthand for CompareFieldValueUsingParentFields with NULL parent_fields. |
bool CompareFieldValue(const Message& message1, |
@@ -710,12 +718,13 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
// list of parent messages if it needs to recursively compare the given field. |
// To avoid confusing users you should not set it to NULL unless you modified |
// Reporter to handle the change of parent_fields correctly. |
- bool CompareFieldValueUsingParentFields(const Message& message1, |
- const Message& message2, |
- const FieldDescriptor* field, |
- int index1, |
- int index2, |
- vector<SpecificField>* parent_fields); |
+ bool CompareFieldValueUsingParentFields( |
+ const Message& message1, |
+ const Message& message2, |
+ const FieldDescriptor* field, |
+ int index1, |
+ int index2, |
+ std::vector<SpecificField>* parent_fields); |
// Compares the specified field on the two messages, returning comparison |
// result, as returned by appropriate FieldComparator. |
@@ -730,7 +739,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
bool IsMatch(const FieldDescriptor* repeated_field, |
const MapKeyComparator* key_comparator, |
const Message* message1, const Message* message2, |
- const vector<SpecificField>& parent_fields, |
+ const std::vector<SpecificField>& parent_fields, |
int index1, int index2); |
// Returns true when this repeated field has been configured to be treated |
@@ -748,13 +757,13 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
const Message& message1, |
const Message& message2, |
const FieldDescriptor* field, |
- const vector<SpecificField>& parent_fields); |
+ const std::vector<SpecificField>& parent_fields); |
// Returns true if this unknown field is to be ignored when this |
// MessageDifferencer compares messages. |
bool IsUnknownFieldIgnored(const Message& message1, const Message& message2, |
const SpecificField& field, |
- const vector<SpecificField>& parent_fields); |
+ const std::vector<SpecificField>& parent_fields); |
// Returns MapKeyComparator* when this field has been configured to |
// be treated as a map. If not, returns NULL. |
@@ -767,28 +776,29 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
// This method returns false if the match failed. However, it doesn't mean |
// that the comparison succeeds when this method returns true (you need to |
// double-check in this case). |
- bool MatchRepeatedFieldIndices(const Message& message1, |
- const Message& message2, |
- const FieldDescriptor* repeated_field, |
- const vector<SpecificField>& parent_fields, |
- vector<int>* match_list1, |
- vector<int>* match_list2); |
+ bool MatchRepeatedFieldIndices( |
+ const Message& message1, |
+ const Message& message2, |
+ const FieldDescriptor* repeated_field, |
+ const std::vector<SpecificField>& parent_fields, |
+ std::vector<int>* match_list1, |
+ std::vector<int>* match_list2); |
// If "any" is of type google.protobuf.Any, extract its payload using |
// DynamicMessageFactory and store in "data". |
bool UnpackAny(const Message& any, google::protobuf::scoped_ptr<Message>* data); |
// Checks if index is equal to new_index in all the specific fields. |
- static bool CheckPathChanged(const vector<SpecificField>& parent_fields); |
+ static bool CheckPathChanged(const std::vector<SpecificField>& parent_fields); |
// Defines a map between field descriptors and their MapKeyComparators. |
// Used for repeated fields when they are configured as TreatAsMap. |
- typedef map<const FieldDescriptor*, |
+ typedef std::map<const FieldDescriptor*, |
const MapKeyComparator*> FieldKeyComparatorMap; |
// Defines a set to store field descriptors. Used for repeated fields when |
// they are configured as TreatAsSet. |
- typedef set<const FieldDescriptor*> FieldSet; |
+ typedef std::set<const FieldDescriptor*> FieldSet; |
Reporter* reporter_; |
DefaultFieldComparator default_field_comparator_; |
@@ -805,13 +815,12 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
// When TreatAsMap or TreatAsMapWithMultipleFieldsAsKey is called, we don't |
// store the supplied FieldDescriptors directly. Instead, a new |
// MapKeyComparator is created for comparison purpose. |
- vector<MapKeyComparator*> owned_key_comparators_; |
+ std::vector<MapKeyComparator*> owned_key_comparators_; |
FieldKeyComparatorMap map_field_key_comparator_; |
- vector<IgnoreCriteria*> ignore_criteria_; |
+ std::vector<IgnoreCriteria*> ignore_criteria_; |
FieldSet ignored_fields_; |
- bool compare_unknown_fields_; |
bool report_matches_; |
string* output_string_; |
@@ -825,15 +834,15 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { |
class LIBPROTOBUF_EXPORT FieldContext { |
public: |
explicit FieldContext( |
- vector<MessageDifferencer::SpecificField>* parent_fields) |
+ std::vector<MessageDifferencer::SpecificField>* parent_fields) |
: parent_fields_(parent_fields) {} |
- vector<MessageDifferencer::SpecificField>* parent_fields() const { |
+ std::vector<MessageDifferencer::SpecificField>* parent_fields() const { |
return parent_fields_; |
} |
private: |
- vector<MessageDifferencer::SpecificField>* parent_fields_; |
+ std::vector<MessageDifferencer::SpecificField>* parent_fields_; |
}; |
} |