aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/util
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xfxyjwf@gmail.com>2018-06-25 13:52:55 -0700
committerGravatar GitHub <noreply@github.com>2018-06-25 13:52:55 -0700
commit0b0890b36d01bf7b372cb237998ee793f5cdc433 (patch)
tree20f4e0b1ad1f74f794f2cb45110841f2b26af23b /src/google/protobuf/util
parentd9ccd0c0e6bbda9bf4476088eeb46b02d7dcd327 (diff)
parent6f88e12f9dee4a658913b475e7680952c6ff3cac (diff)
Merge pull request #4608 from khuzemap/master
Add "override" keyword for overridden virtual functions
Diffstat (limited to 'src/google/protobuf/util')
-rw-r--r--src/google/protobuf/util/field_comparator.h6
-rw-r--r--src/google/protobuf/util/internal/default_value_objectwriter.h28
-rw-r--r--src/google/protobuf/util/internal/error_listener.h12
-rw-r--r--src/google/protobuf/util/internal/json_objectwriter.h34
-rw-r--r--src/google/protobuf/util/internal/object_location_tracker.h4
-rw-r--r--src/google/protobuf/util/internal/proto_writer.h8
-rw-r--r--src/google/protobuf/util/internal/protostream_objectsource.h4
-rw-r--r--src/google/protobuf/util/internal/protostream_objectwriter.h16
-rw-r--r--src/google/protobuf/util/internal/type_info.cc10
-rw-r--r--src/google/protobuf/util/json_util.cc9
-rw-r--r--src/google/protobuf/util/json_util.h2
-rw-r--r--src/google/protobuf/util/message_differencer.cc2
-rw-r--r--src/google/protobuf/util/message_differencer.h21
-rw-r--r--src/google/protobuf/util/type_resolver_util.cc4
14 files changed, 82 insertions, 78 deletions
diff --git a/src/google/protobuf/util/field_comparator.h b/src/google/protobuf/util/field_comparator.h
index 27ef4c77..63e89fb7 100644
--- a/src/google/protobuf/util/field_comparator.h
+++ b/src/google/protobuf/util/field_comparator.h
@@ -110,14 +110,14 @@ class LIBPROTOBUF_EXPORT DefaultFieldComparator : public FieldComparator {
// Creates new comparator with float comparison set to EXACT.
DefaultFieldComparator();
- virtual ~DefaultFieldComparator();
+ ~DefaultFieldComparator() override;
- virtual ComparisonResult Compare(
+ ComparisonResult Compare(
const google::protobuf::Message& message_1,
const google::protobuf::Message& message_2,
const google::protobuf::FieldDescriptor* field,
int index_1, int index_2,
- const google::protobuf::util::FieldContext* field_context);
+ const google::protobuf::util::FieldContext* field_context) override;
void set_float_comparison(FloatComparison float_comparison) {
float_comparison_ = float_comparison;
diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.h b/src/google/protobuf/util/internal/default_value_objectwriter.h
index 6e71f9c8..7d245c9c 100644
--- a/src/google/protobuf/util/internal/default_value_objectwriter.h
+++ b/src/google/protobuf/util/internal/default_value_objectwriter.h
@@ -83,37 +83,37 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
virtual ~DefaultValueObjectWriter();
// ObjectWriter methods.
- virtual DefaultValueObjectWriter* StartObject(StringPiece name);
+ virtual DefaultValueObjectWriter* StartObject(StringPiece name) override;
- virtual DefaultValueObjectWriter* EndObject();
+ virtual DefaultValueObjectWriter* EndObject() override;
- virtual DefaultValueObjectWriter* StartList(StringPiece name);
+ virtual DefaultValueObjectWriter* StartList(StringPiece name) override;
- virtual DefaultValueObjectWriter* EndList();
+ virtual DefaultValueObjectWriter* EndList() override;
- virtual DefaultValueObjectWriter* RenderBool(StringPiece name, bool value);
+ virtual DefaultValueObjectWriter* RenderBool(StringPiece name, bool value) override;
- virtual DefaultValueObjectWriter* RenderInt32(StringPiece name, int32 value);
+ virtual DefaultValueObjectWriter* RenderInt32(StringPiece name, int32 value) override;
virtual DefaultValueObjectWriter* RenderUint32(StringPiece name,
- uint32 value);
+ uint32 value) override;
- virtual DefaultValueObjectWriter* RenderInt64(StringPiece name, int64 value);
+ virtual DefaultValueObjectWriter* RenderInt64(StringPiece name, int64 value) override;
virtual DefaultValueObjectWriter* RenderUint64(StringPiece name,
- uint64 value);
+ uint64 value) override;
virtual DefaultValueObjectWriter* RenderDouble(StringPiece name,
- double value);
+ double value) override;
- virtual DefaultValueObjectWriter* RenderFloat(StringPiece name, float value);
+ virtual DefaultValueObjectWriter* RenderFloat(StringPiece name, float value) override;
virtual DefaultValueObjectWriter* RenderString(StringPiece name,
- StringPiece value);
+ StringPiece value) override;
virtual DefaultValueObjectWriter* RenderBytes(StringPiece name,
- StringPiece value);
+ StringPiece value) override;
- virtual DefaultValueObjectWriter* RenderNull(StringPiece name);
+ virtual DefaultValueObjectWriter* RenderNull(StringPiece name) override;
// Register the callback for scrubbing of fields. Owership of
// field_scrub_callback pointer is also transferred to this class
diff --git a/src/google/protobuf/util/internal/error_listener.h b/src/google/protobuf/util/internal/error_listener.h
index a19bd3f7..e3baa224 100644
--- a/src/google/protobuf/util/internal/error_listener.h
+++ b/src/google/protobuf/util/internal/error_listener.h
@@ -76,16 +76,16 @@ class LIBPROTOBUF_EXPORT ErrorListener {
class LIBPROTOBUF_EXPORT NoopErrorListener : public ErrorListener {
public:
NoopErrorListener() {}
- virtual ~NoopErrorListener() {}
+ virtual ~NoopErrorListener() override {}
virtual void InvalidName(const LocationTrackerInterface& loc,
- StringPiece invalid_name, StringPiece message) {}
+ StringPiece invalid_name, StringPiece message) override {}
- virtual void InvalidValue(const LocationTrackerInterface& loc,
- StringPiece type_name, StringPiece value) {}
+ virtual void InvalidValue(const LocationTrackerInterface &loc, StringPiece type_name,
+ StringPiece value) override {}
- virtual void MissingField(const LocationTrackerInterface& loc,
- StringPiece missing_name) {}
+ virtual void MissingField(const LocationTrackerInterface &loc,
+ StringPiece missing_name) override {}
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(NoopErrorListener);
diff --git a/src/google/protobuf/util/internal/json_objectwriter.h b/src/google/protobuf/util/internal/json_objectwriter.h
index 81644dab..4c25b465 100644
--- a/src/google/protobuf/util/internal/json_objectwriter.h
+++ b/src/google/protobuf/util/internal/json_objectwriter.h
@@ -94,20 +94,20 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
virtual ~JsonObjectWriter();
// ObjectWriter methods.
- virtual JsonObjectWriter* StartObject(StringPiece name);
- virtual JsonObjectWriter* EndObject();
- virtual JsonObjectWriter* StartList(StringPiece name);
- virtual JsonObjectWriter* EndList();
- virtual JsonObjectWriter* RenderBool(StringPiece name, bool value);
- virtual JsonObjectWriter* RenderInt32(StringPiece name, int32 value);
- virtual JsonObjectWriter* RenderUint32(StringPiece name, uint32 value);
- virtual JsonObjectWriter* RenderInt64(StringPiece name, int64 value);
- virtual JsonObjectWriter* RenderUint64(StringPiece name, uint64 value);
- virtual JsonObjectWriter* RenderDouble(StringPiece name, double value);
- virtual JsonObjectWriter* RenderFloat(StringPiece name, float value);
- virtual JsonObjectWriter* RenderString(StringPiece name, StringPiece value);
- virtual JsonObjectWriter* RenderBytes(StringPiece name, StringPiece value);
- virtual JsonObjectWriter* RenderNull(StringPiece name);
+ virtual JsonObjectWriter* StartObject(StringPiece name) override;
+ virtual JsonObjectWriter* EndObject() override;
+ virtual JsonObjectWriter* StartList(StringPiece name) override;
+ virtual JsonObjectWriter* EndList() override;
+ virtual JsonObjectWriter* RenderBool(StringPiece name, bool value) override;
+ virtual JsonObjectWriter* RenderInt32(StringPiece name, int32 value) override;
+ virtual JsonObjectWriter* RenderUint32(StringPiece name, uint32 value) override;
+ virtual JsonObjectWriter* RenderInt64(StringPiece name, int64 value) override;
+ virtual JsonObjectWriter* RenderUint64(StringPiece name, uint64 value) override;
+ virtual JsonObjectWriter* RenderDouble(StringPiece name, double value) override;
+ virtual JsonObjectWriter* RenderFloat(StringPiece name, float value) override;
+ virtual JsonObjectWriter* RenderString(StringPiece name, StringPiece value) override;
+ virtual JsonObjectWriter* RenderBytes(StringPiece name, StringPiece value) override;
+ virtual JsonObjectWriter* RenderNull(StringPiece name) override;
virtual JsonObjectWriter* RenderNullAsEmpty(StringPiece name);
void set_use_websafe_base64_for_bytes(bool value) {
@@ -143,17 +143,17 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(Element);
};
- virtual Element* element() { return element_.get(); }
+ Element* element() override { return element_.get(); }
private:
class LIBPROTOBUF_EXPORT ByteSinkWrapper : public strings::ByteSink {
public:
explicit ByteSinkWrapper(google::protobuf::io::CodedOutputStream* stream)
: stream_(stream) {}
- virtual ~ByteSinkWrapper() {}
+ ~ByteSinkWrapper() override {}
// ByteSink methods.
- virtual void Append(const char* bytes, size_t n) {
+ void Append(const char* bytes, size_t n) override {
stream_->WriteRaw(bytes, n);
}
diff --git a/src/google/protobuf/util/internal/object_location_tracker.h b/src/google/protobuf/util/internal/object_location_tracker.h
index 8586cecc..f9b90bc4 100644
--- a/src/google/protobuf/util/internal/object_location_tracker.h
+++ b/src/google/protobuf/util/internal/object_location_tracker.h
@@ -47,10 +47,10 @@ class ObjectLocationTracker : public LocationTrackerInterface {
// Creates an empty location tracker.
ObjectLocationTracker() {}
- virtual ~ObjectLocationTracker() {}
+ ~ObjectLocationTracker() override {}
// Returns empty because nothing is tracked.
- virtual string ToString() const { return ""; }
+ string ToString() const override { return ""; }
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectLocationTracker);
diff --git a/src/google/protobuf/util/internal/proto_writer.h b/src/google/protobuf/util/internal/proto_writer.h
index f2b4f42f..5bdafcc9 100644
--- a/src/google/protobuf/util/internal/proto_writer.h
+++ b/src/google/protobuf/util/internal/proto_writer.h
@@ -78,7 +78,7 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
// Constructor. Does not take ownership of any parameter passed in.
ProtoWriter(TypeResolver* type_resolver, const google::protobuf::Type& type,
strings::ByteSink* output, ErrorListener* listener);
- virtual ~ProtoWriter();
+ virtual ~ProtoWriter() override;
// ObjectWriter methods.
ProtoWriter* StartObject(StringPiece name) override;
@@ -163,7 +163,7 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
ProtoElement(ProtoElement* parent, const google::protobuf::Field* field,
const google::protobuf::Type& type, bool is_list);
- virtual ~ProtoElement() {}
+ virtual ~ProtoElement() override {}
// Called just before the destructor for clean up:
// - reports any missing required fields
@@ -183,9 +183,9 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {
void RegisterField(const google::protobuf::Field* field);
// To report location on error messages.
- virtual string ToString() const;
+ virtual string ToString() const override;
- virtual ProtoElement* parent() const {
+ virtual ProtoElement* parent() const override {
return static_cast<ProtoElement*>(BaseElement::parent());
}
diff --git a/src/google/protobuf/util/internal/protostream_objectsource.h b/src/google/protobuf/util/internal/protostream_objectsource.h
index b56efdf4..acd081d9 100644
--- a/src/google/protobuf/util/internal/protostream_objectsource.h
+++ b/src/google/protobuf/util/internal/protostream_objectsource.h
@@ -78,9 +78,9 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource {
TypeResolver* type_resolver,
const google::protobuf::Type& type);
- virtual ~ProtoStreamObjectSource();
+ virtual ~ProtoStreamObjectSource() override;
- virtual util::Status NamedWriteTo(StringPiece name, ObjectWriter* ow) const;
+ virtual util::Status NamedWriteTo(StringPiece name, ObjectWriter* ow) const override;
// Sets whether or not to use lowerCamelCase casing for enum values. If set to
// false, enum values are output without any case conversions.
diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.h b/src/google/protobuf/util/internal/protostream_objectwriter.h
index c33a4639..d9bb432e 100644
--- a/src/google/protobuf/util/internal/protostream_objectwriter.h
+++ b/src/google/protobuf/util/internal/protostream_objectwriter.h
@@ -112,18 +112,18 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
strings::ByteSink* output, ErrorListener* listener,
const ProtoStreamObjectWriter::Options& options =
ProtoStreamObjectWriter::Options::Defaults());
- virtual ~ProtoStreamObjectWriter();
+ virtual ~ProtoStreamObjectWriter() override;
// ObjectWriter methods.
- virtual ProtoStreamObjectWriter* StartObject(StringPiece name);
- virtual ProtoStreamObjectWriter* EndObject();
- virtual ProtoStreamObjectWriter* StartList(StringPiece name);
- virtual ProtoStreamObjectWriter* EndList();
+ virtual ProtoStreamObjectWriter* StartObject(StringPiece name) override;
+ virtual ProtoStreamObjectWriter* EndObject() override;
+ virtual ProtoStreamObjectWriter* StartList(StringPiece name) override;
+ virtual ProtoStreamObjectWriter* EndList() override;
// Renders a DataPiece 'value' into a field whose wire type is determined
// from the given field 'name'.
virtual ProtoStreamObjectWriter* RenderDataPiece(StringPiece name,
- const DataPiece& value);
+ const DataPiece& value) override;
protected:
// Function that renders a well known type with modified behavior.
@@ -263,7 +263,7 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
// Constructor for a field of a message.
Item(Item* parent, ItemType item_type, bool is_placeholder, bool is_list);
- virtual ~Item() {}
+ virtual ~Item() override {}
// These functions return true if the element type is corresponding to the
// type in function name.
@@ -272,7 +272,7 @@ class LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {
AnyWriter* any() const { return any_.get(); }
- virtual Item* parent() const {
+ virtual Item* parent() const override {
return static_cast<Item*>(BaseElement::parent());
}
diff --git a/src/google/protobuf/util/internal/type_info.cc b/src/google/protobuf/util/internal/type_info.cc
index 3847b179..e32e71d0 100644
--- a/src/google/protobuf/util/internal/type_info.cc
+++ b/src/google/protobuf/util/internal/type_info.cc
@@ -59,7 +59,7 @@ class TypeInfoForTypeResolver : public TypeInfo {
}
virtual util::StatusOr<const google::protobuf::Type*> ResolveTypeUrl(
- StringPiece type_url) const {
+ StringPiece type_url) const override {
std::map<StringPiece, StatusOrType>::iterator it =
cached_types_.find(type_url);
if (it != cached_types_.end()) {
@@ -79,13 +79,13 @@ class TypeInfoForTypeResolver : public TypeInfo {
}
virtual const google::protobuf::Type* GetTypeByTypeUrl(
- StringPiece type_url) const {
+ StringPiece type_url) const override {
StatusOrType result = ResolveTypeUrl(type_url);
return result.ok() ? result.ValueOrDie() : NULL;
}
virtual const google::protobuf::Enum* GetEnumByTypeUrl(
- StringPiece type_url) const {
+ StringPiece type_url) const override {
std::map<StringPiece, StatusOrEnum>::iterator it =
cached_enums_.find(type_url);
if (it != cached_enums_.end()) {
@@ -105,8 +105,10 @@ class TypeInfoForTypeResolver : public TypeInfo {
return result.ok() ? result.ValueOrDie() : NULL;
}
+
virtual const google::protobuf::Field* FindField(
- const google::protobuf::Type* type, StringPiece camel_case_name) const {
+ const google::protobuf::Type* type,
+ StringPiece camel_case_name) const override {
std::map<const google::protobuf::Type*, CamelCaseNameTable>::const_iterator
it = indexed_types_.find(type);
const CamelCaseNameTable& camel_case_name_table =
diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc
index 9ad073d8..7a7f299f 100644
--- a/src/google/protobuf/util/json_util.cc
+++ b/src/google/protobuf/util/json_util.cc
@@ -119,20 +119,21 @@ util::Status BinaryToJsonString(TypeResolver* resolver,
namespace {
class StatusErrorListener : public converter::ErrorListener {
public:
+
StatusErrorListener() {}
- virtual ~StatusErrorListener() {}
+ virtual ~StatusErrorListener() override {}
util::Status GetStatus() { return status_; }
virtual void InvalidName(const converter::LocationTrackerInterface& loc,
- StringPiece unknown_name, StringPiece message) {
+ StringPiece unknown_name, StringPiece message) override {
status_ = util::Status(util::error::INVALID_ARGUMENT,
loc.ToString() + ": invalid name " +
string(unknown_name) + ": " + string(message));
}
virtual void InvalidValue(const converter::LocationTrackerInterface& loc,
- StringPiece type_name, StringPiece value) {
+ StringPiece type_name, StringPiece value) override {
status_ =
util::Status(util::error::INVALID_ARGUMENT,
loc.ToString() + ": invalid value " + string(value) +
@@ -140,7 +141,7 @@ class StatusErrorListener : public converter::ErrorListener {
}
virtual void MissingField(const converter::LocationTrackerInterface& loc,
- StringPiece missing_name) {
+ StringPiece missing_name) override {
status_ = util::Status(
util::error::INVALID_ARGUMENT,
loc.ToString() + ": missing field " + string(missing_name));
diff --git a/src/google/protobuf/util/json_util.h b/src/google/protobuf/util/json_util.h
index b1c69813..e7868307 100644
--- a/src/google/protobuf/util/json_util.h
+++ b/src/google/protobuf/util/json_util.h
@@ -182,7 +182,7 @@ class LIBPROTOBUF_EXPORT ZeroCopyStreamByteSink : public strings::ByteSink {
: stream_(stream), buffer_(NULL), buffer_size_(0) {}
~ZeroCopyStreamByteSink();
- virtual void Append(const char* bytes, size_t len);
+ virtual void Append(const char* bytes, size_t len) override;
private:
io::ZeroCopyOutputStream* stream_;
diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc
index 9842f64c..7d3976f8 100644
--- a/src/google/protobuf/util/message_differencer.cc
+++ b/src/google/protobuf/util/message_differencer.cc
@@ -90,7 +90,7 @@ class MessageDifferencer::MultipleFieldsMapKeyComparator
virtual bool IsMatch(
const Message& message1,
const Message& message2,
- const std::vector<SpecificField>& parent_fields) const {
+ const std::vector<SpecificField>& parent_fields) const override {
for (int i = 0; i < key_field_paths_.size(); ++i) {
if (!IsMatchInternal(message1, message2, parent_fields,
key_field_paths_[i], 0)) {
diff --git a/src/google/protobuf/util/message_differencer.h b/src/google/protobuf/util/message_differencer.h
index bbcf8498..b3e65515 100644
--- a/src/google/protobuf/util/message_differencer.h
+++ b/src/google/protobuf/util/message_differencer.h
@@ -597,7 +597,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
public:
explicit StreamReporter(io::ZeroCopyOutputStream* output);
explicit StreamReporter(io::Printer* printer); // delimiter '$'
- virtual ~StreamReporter();
+ virtual ~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 +607,33 @@ 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);
+ const std::vector<SpecificField>& field_path) override;
virtual void ReportDeleted(const Message& message1,
const Message& message2,
- const std::vector<SpecificField>& field_path);
+ const std::vector<SpecificField>& field_path) override;
virtual void ReportModified(const Message& message1,
const Message& message2,
- const std::vector<SpecificField>& field_path);
+ const std::vector<SpecificField>& field_path) override;
virtual void ReportMoved(const Message& message1,
const Message& message2,
- const std::vector<SpecificField>& field_path);
+ const std::vector<SpecificField>& field_path) override;
virtual void ReportMatched(const Message& message1,
const Message& message2,
- const std::vector<SpecificField>& field_path);
+ const std::vector<SpecificField>& field_path) override;
virtual void ReportIgnored(const Message& message1,
const Message& message2,
- const std::vector<SpecificField>& field_path);
+ const std::vector<SpecificField>& field_path) override;
- virtual void ReportUnknownFieldIgnored(
+ 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
@@ -681,7 +682,7 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
public:
explicit MapEntryKeyComparator(MessageDifferencer* message_differencer);
virtual bool IsMatch(const Message& message1, const Message& message2,
- const std::vector<SpecificField>& parent_fields) const;
+ const std::vector<SpecificField>& parent_fields) const override;
private:
MessageDifferencer* message_differencer_;
diff --git a/src/google/protobuf/util/type_resolver_util.cc b/src/google/protobuf/util/type_resolver_util.cc
index a69ed58c..aa48ef60 100644
--- a/src/google/protobuf/util/type_resolver_util.cc
+++ b/src/google/protobuf/util/type_resolver_util.cc
@@ -60,7 +60,7 @@ class DescriptorPoolTypeResolver : public TypeResolver {
const DescriptorPool* pool)
: url_prefix_(url_prefix), pool_(pool) {}
- Status ResolveMessageType(const string& type_url, Type* type) {
+ Status ResolveMessageType(const string& type_url, Type* type) override {
string type_name;
Status status = ParseTypeUrl(type_url, &type_name);
if (!status.ok()) {
@@ -75,7 +75,7 @@ class DescriptorPoolTypeResolver : public TypeResolver {
return Status();
}
- Status ResolveEnumType(const string& type_url, Enum* enum_type) {
+ Status ResolveEnumType(const string& type_url, Enum* enum_type) override {
string type_name;
Status status = ParseTypeUrl(type_url, &type_name);
if (!status.ok()) {