Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize use override #661

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ jobs:
run: |
export CXX=${{matrix.compiler}}
make test cxxstd=c++11 defines=${{matrix.defines}} config=release -j2
make test cxxstd=c++98 defines=${{matrix.defines}} config=debug -j2
make test cxxstd=c++17 defines=${{matrix.defines}} config=debug -j2
make test defines=${{matrix.defines}} config=sanitize -j2
- name: make coverage
if: ${{!(matrix.os == 'ubuntu' && matrix.compiler == 'clang++')}} # linux/clang produces coverage info gcov can't parse
run: |
export CXX=${{matrix.compiler}}
make test defines=${{matrix.defines}} config=coverage -j2
make test cxxstd=c++11 defines=${{matrix.defines}} config=coverage -j2
bash <(curl -s https://codecov.io/bash) -f pugixml.cpp.gcov -X search -t ${{secrets.CODECOV_TOKEN}} -B ${{github.ref}}

unix-cmake:
Expand Down
17 changes: 3 additions & 14 deletions src/pugixml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,6 @@
# define PUGIXML_NOEXCEPT_IF_NOT_COMPACT PUGIXML_NOEXCEPT
#endif

// If C++ is 2011 or higher, add 'override' qualifiers
#ifndef PUGIXML_OVERRIDE
# if __cplusplus >= 201103
# define PUGIXML_OVERRIDE override
# elif defined(_MSC_VER) && _MSC_VER >= 1700
# define PUGIXML_OVERRIDE override
# else
# define PUGIXML_OVERRIDE
# endif
#endif

// If C++ is 2011 or higher, use 'nullptr'
#ifndef PUGIXML_NULL
# if __cplusplus >= 201103
Expand Down Expand Up @@ -360,7 +349,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) PUGIXML_OVERRIDE;
virtual void write(const void* data, size_t size) override;

private:
void* file;
Expand All @@ -375,7 +364,7 @@ namespace pugi
xml_writer_stream(std::basic_ostream<char>& stream);
xml_writer_stream(std::basic_ostream<wchar_t>& stream);

virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE;
virtual void write(const void* data, size_t size) override;

private:
std::basic_ostream<char>* narrow_stream;
Expand Down Expand Up @@ -1383,7 +1372,7 @@ namespace pugi
explicit xpath_exception(const xpath_parse_result& result);

// Get error message
virtual const char* what() const PUGIXML_NOEXCEPT PUGIXML_OVERRIDE;
virtual const char* what() const PUGIXML_NOEXCEPT override;

// Get parse result
const xpath_parse_result& result() const;
Expand Down
2 changes: 1 addition & 1 deletion tests/test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct dummy_fixture {};
{ \
test_runner_##name(): test_runner(#name) {} \
\
virtual void run() PUGIXML_OVERRIDE \
virtual void run() override \
{ \
test_runner_helper_##name helper; \
helper.run(); \
Expand Down
14 changes: 7 additions & 7 deletions tests/test_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ template <typename T> class seek_fail_buffer: public std::basic_streambuf<T>
{
}

typename std::basic_streambuf<T>::pos_type seekoff(typename std::basic_streambuf<T>::off_type, std::ios_base::seekdir, std::ios_base::openmode) PUGIXML_OVERRIDE
typename std::basic_streambuf<T>::pos_type seekoff(typename std::basic_streambuf<T>::off_type, std::ios_base::seekdir, std::ios_base::openmode) override
{
seeks++;

Expand Down Expand Up @@ -345,14 +345,14 @@ template <typename T> class tell_fail_buffer: public std::basic_streambuf<T>
{
}

typename std::basic_streambuf<T>::pos_type seekoff(typename std::basic_streambuf<T>::off_type, std::ios_base::seekdir dir, std::ios_base::openmode) PUGIXML_OVERRIDE
typename std::basic_streambuf<T>::pos_type seekoff(typename std::basic_streambuf<T>::off_type, std::ios_base::seekdir dir, std::ios_base::openmode) override
{
seeks++;

return seeks > 1 && dir == std::ios_base::cur ? -1 : 0;
}

typename std::basic_streambuf<T>::pos_type seekpos(typename std::basic_streambuf<T>::pos_type, std::ios_base::openmode) PUGIXML_OVERRIDE
typename std::basic_streambuf<T>::pos_type seekpos(typename std::basic_streambuf<T>::pos_type, std::ios_base::openmode) override
{
return 0;
}
Expand Down Expand Up @@ -380,7 +380,7 @@ TEST(document_load_stream_wide_seekable_fail_tell)
template <typename T> class read_fail_buffer: public std::basic_streambuf<T>
{
public:
typename std::basic_streambuf<T>::int_type underflow() PUGIXML_OVERRIDE
typename std::basic_streambuf<T>::int_type underflow() override
{
throw std::runtime_error("underflow failed");

Expand Down Expand Up @@ -417,7 +417,7 @@ template <typename T> class read_fail_seekable_buffer: public std::basic_streamb
{
}

typename std::basic_streambuf<T>::int_type underflow() PUGIXML_OVERRIDE
typename std::basic_streambuf<T>::int_type underflow() override
{
throw std::runtime_error("underflow failed");

Expand All @@ -426,7 +426,7 @@ template <typename T> class read_fail_seekable_buffer: public std::basic_streamb
#endif
}

typename std::basic_streambuf<T>::pos_type seekoff(typename std::basic_streambuf<T>::off_type off, std::ios_base::seekdir dir, std::ios_base::openmode) PUGIXML_OVERRIDE
typename std::basic_streambuf<T>::pos_type seekoff(typename std::basic_streambuf<T>::off_type off, std::ios_base::seekdir dir, std::ios_base::openmode) override
{
switch (dir)
{
Expand All @@ -438,7 +438,7 @@ template <typename T> class read_fail_seekable_buffer: public std::basic_streamb
return offset;
}

typename std::basic_streambuf<T>::pos_type seekpos(typename std::basic_streambuf<T>::pos_type pos, std::ios_base::openmode) PUGIXML_OVERRIDE
typename std::basic_streambuf<T>::pos_type seekpos(typename std::basic_streambuf<T>::pos_type pos, std::ios_base::openmode) override
{
offset = pos;
return pos;
Expand Down
6 changes: 3 additions & 3 deletions tests/test_dom_traverse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ struct test_walker: xml_tree_walker
#endif
}

virtual bool begin(xml_node& node) PUGIXML_OVERRIDE
bool begin(xml_node& node) override
{
log += STR("|");
log += depthstr();
Expand All @@ -908,7 +908,7 @@ struct test_walker: xml_tree_walker
return ++call_count != stop_count && xml_tree_walker::begin(node);
}

virtual bool for_each(xml_node& node) PUGIXML_OVERRIDE
bool for_each(xml_node& node) override
{
log += STR("|");
log += depthstr();
Expand All @@ -920,7 +920,7 @@ struct test_walker: xml_tree_walker
return ++call_count != stop_count && xml_tree_walker::end(node);
}

virtual bool end(xml_node& node) PUGIXML_OVERRIDE
bool end(xml_node& node) override
{
log += STR("|");
log += depthstr();
Expand Down
4 changes: 2 additions & 2 deletions tests/test_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ struct test_writer: xml_writer
{
std::basic_string<char_t> contents;

virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE
void write(const void* data, size_t size) override
{
CHECK(size % sizeof(char_t) == 0);
contents.append(static_cast<const char_t*>(data), size / sizeof(char_t));
Expand Down Expand Up @@ -687,7 +687,7 @@ TEST(write_flush_coverage)
#ifndef PUGIXML_NO_EXCEPTIONS
struct throwing_writer: xml_writer
{
virtual void write(const void*, size_t) PUGIXML_OVERRIDE
void write(const void*, size_t) override
{
throw std::runtime_error("write failed");
}
Expand Down
2 changes: 1 addition & 1 deletion tests/writer_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct xml_writer_string: public pugi::xml_writer
{
std::string contents;

virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE;
virtual void write(const void* data, size_t size) override;

std::string as_narrow() const;
std::basic_string<wchar_t> as_wide() const;
Expand Down
Loading