From 3b5810315734c815ff4c6385ebe8cf2d00bbb573 Mon Sep 17 00:00:00 2001 From: Pavel Kryukov Date: Wed, 5 Oct 2016 20:11:07 +0300 Subject: Add 'override' keyword if C++11 is enabled --- src/pugixml.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pugixml.hpp b/src/pugixml.hpp index 09bd692..898dab8 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -72,6 +72,15 @@ # endif #endif +// If no API for functions is defined, assume default +#ifndef PUGIXML_OVERRIDE +# if __cplusplus >= 201103 +# define PUGIXML_OVERRIDE override +# else +# define PUGIXML_OVERRIDE +# endif +#endif + // Character interface macros #ifdef PUGIXML_WCHAR_MODE # define PUGIXML_TEXT(t) L ## t @@ -273,7 +282,7 @@ namespace pugi // Construct writer from a FILE* object; void* is used to avoid header dependencies on stdio xml_writer_file(void* file); - virtual void write(const void* data, size_t size); + virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE; private: void* file; @@ -288,7 +297,7 @@ namespace pugi xml_writer_stream(std::basic_ostream >& stream); xml_writer_stream(std::basic_ostream >& stream); - virtual void write(const void* data, size_t size); + virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE; private: std::basic_ostream >* narrow_stream; @@ -1214,7 +1223,7 @@ namespace pugi explicit xpath_exception(const xpath_parse_result& result); // Get error message - virtual const char* what() const throw(); + virtual const char* what() const throw() PUGIXML_OVERRIDE; // Get parse result const xpath_parse_result& result() const; -- cgit v1.2.3 From c7c7349cb7935d8cfcdd241e6d401a89567e89eb Mon Sep 17 00:00:00 2001 From: Pavel Kryukov Date: Thu, 13 Oct 2016 01:36:12 +0300 Subject: Add PUGIXML_OVERRIDE to headers of tests --- tests/test.hpp | 2 +- tests/test_document.cpp | 2 +- tests/test_dom_traverse.cpp | 6 +++--- tests/test_write.cpp | 4 ++-- tests/writer_string.hpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test.hpp b/tests/test.hpp index e700826..f88c909 100644 --- a/tests/test.hpp +++ b/tests/test.hpp @@ -78,7 +78,7 @@ struct dummy_fixture {}; { \ test_runner_##name(): test_runner(#name) {} \ \ - virtual void run() \ + virtual void run() PUGIXML_OVERRIDE \ { \ test_runner_helper_##name helper; \ helper.run(); \ diff --git a/tests/test_document.cpp b/tests/test_document.cpp index 73a36f5..c7219e1 100644 --- a/tests/test_document.cpp +++ b/tests/test_document.cpp @@ -187,7 +187,7 @@ public: this->setg(begin, begin, end); } - typename std::basic_streambuf::int_type underflow() + typename std::basic_streambuf::int_type underflow() PUGIXML_OVERRIDE { return this->gptr() == this->egptr() ? std::basic_streambuf::traits_type::eof() : std::basic_streambuf::traits_type::to_int_type(*this->gptr()); } diff --git a/tests/test_dom_traverse.cpp b/tests/test_dom_traverse.cpp index 25774a5..f977e15 100644 --- a/tests/test_dom_traverse.cpp +++ b/tests/test_dom_traverse.cpp @@ -798,7 +798,7 @@ struct test_walker: xml_tree_walker #endif } - virtual bool begin(xml_node& node) + virtual bool begin(xml_node& node) PUGIXML_OVERRIDE { log += STR("|"); log += depthstr(); @@ -810,7 +810,7 @@ struct test_walker: xml_tree_walker return ++call_count != stop_count && xml_tree_walker::begin(node); } - virtual bool for_each(xml_node& node) + virtual bool for_each(xml_node& node) PUGIXML_OVERRIDE { log += STR("|"); log += depthstr(); @@ -822,7 +822,7 @@ struct test_walker: xml_tree_walker return ++call_count != stop_count && xml_tree_walker::end(node); } - virtual bool end(xml_node& node) + virtual bool end(xml_node& node) PUGIXML_OVERRIDE { log += STR("|"); log += depthstr(); diff --git a/tests/test_write.cpp b/tests/test_write.cpp index 341a4f0..bf45e31 100644 --- a/tests/test_write.cpp +++ b/tests/test_write.cpp @@ -213,7 +213,7 @@ struct test_writer: xml_writer { std::basic_string contents; - virtual void write(const void* data, size_t size) + virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE { CHECK(size % sizeof(pugi::char_t) == 0); contents.append(static_cast(data), size / sizeof(pugi::char_t)); @@ -604,7 +604,7 @@ TEST_XML_FLAGS(write_mixed, "premid