From 09c66e19bfab0b3d59d41d6551af6fa2f9995184 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 21 Jun 2015 15:08:48 +0200 Subject: [PATCH] lyrics fetcher: use override keyword where appropriate --- src/lyrics_fetcher.cpp | 8 +++--- src/lyrics_fetcher.h | 60 +++++++++++++++++++++--------------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/lyrics_fetcher.cpp b/src/lyrics_fetcher.cpp index baeeb11f..2457092c 100644 --- a/src/lyrics_fetcher.cpp +++ b/src/lyrics_fetcher.cpp @@ -102,7 +102,7 @@ std::vector LyricsFetcher::getContent(const char *regex_, const std return result; } -void LyricsFetcher::postProcess(std::string &data) +void LyricsFetcher::postProcess(std::string &data) const { stripHtmlTags(data); boost::trim(data); @@ -163,7 +163,7 @@ LyricsFetcher::Result LyricwikiFetcher::fetch(const std::string &artist, const s return result; } -bool LyricwikiFetcher::notLyrics(const std::string &data) +bool LyricwikiFetcher::notLyrics(const std::string &data) const { return data.find("action=edit") != std::string::npos; } @@ -215,7 +215,7 @@ bool GoogleLyricsFetcher::isURLOk(const std::string &url) /**********************************************************************/ -void Sing365Fetcher::postProcess(std::string &data) +void Sing365Fetcher::postProcess(std::string &data) const { // throw away ad data = boost::regex_replace(data, boost::regex(""), ""); @@ -224,7 +224,7 @@ void Sing365Fetcher::postProcess(std::string &data) /**********************************************************************/ -void MetrolyricsFetcher::postProcess(std::string &data) +void MetrolyricsFetcher::postProcess(std::string &data) const { // some of lyrics have both \n chars and
, html tags // are always present whereas \n chars are not, so we need to diff --git a/src/lyrics_fetcher.h b/src/lyrics_fetcher.h index d7683d88..faaa4d21 100644 --- a/src/lyrics_fetcher.h +++ b/src/lyrics_fetcher.h @@ -31,15 +31,15 @@ struct LyricsFetcher { typedef std::pair Result; - virtual const char *name() = 0; + virtual const char *name() const = 0; virtual Result fetch(const std::string &artist, const std::string &title); protected: - virtual const char *urlTemplate() = 0; - virtual const char *regex() = 0; + virtual const char *urlTemplate() const = 0; + virtual const char *regex() const = 0; - virtual bool notLyrics(const std::string &) { return false; } - virtual void postProcess(std::string &data); + virtual bool notLyrics(const std::string &) const { return false; } + virtual void postProcess(std::string &data) const; std::vector getContent(const char *regex, const std::string &data); @@ -48,14 +48,14 @@ protected: struct LyricwikiFetcher : public LyricsFetcher { - virtual const char *name() { return "lyricwiki.com"; } - virtual Result fetch(const std::string &artist, const std::string &title); + virtual const char *name() const OVERRIDE { return "lyricwiki.com"; } + virtual Result fetch(const std::string &artist, const std::string &title) OVERRIDE; protected: - virtual const char *urlTemplate() { return "http://lyrics.wikia.com/api.php?action=lyrics&fmt=xml&func=getSong&artist=%artist%&song=%title%"; } - virtual const char *regex() { return "(.*?)"; } + virtual const char *urlTemplate() const OVERRIDE { return "http://lyrics.wikia.com/api.php?action=lyrics&fmt=xml&func=getSong&artist=%artist%&song=%title%"; } + virtual const char *regex() const OVERRIDE { return "(.*?)"; } - virtual bool notLyrics(const std::string &data); + virtual bool notLyrics(const std::string &data) const OVERRIDE; }; /**********************************************************************/ @@ -65,8 +65,8 @@ struct GoogleLyricsFetcher : public LyricsFetcher virtual Result fetch(const std::string &artist, const std::string &title); protected: - virtual const char *urlTemplate() { return URL; } - virtual const char *siteKeyword() { return name(); } + virtual const char *urlTemplate() const { return URL; } + virtual const char *siteKeyword() const { return name(); } virtual bool isURLOk(const std::string &url); @@ -76,59 +76,59 @@ private: struct MetrolyricsFetcher : public GoogleLyricsFetcher { - virtual const char *name() { return "metrolyrics.com"; } + virtual const char *name() const OVERRIDE { return "metrolyrics.com"; } protected: - virtual const char *regex() { return "
(.*?)
"; } + virtual const char *regex() const OVERRIDE { return "
(.*?)
"; } - virtual bool isURLOk(const std::string &url); - virtual void postProcess(std::string &data); + virtual bool isURLOk(const std::string &url) OVERRIDE; + virtual void postProcess(std::string &data) const OVERRIDE; }; struct LyricsmaniaFetcher : public GoogleLyricsFetcher { - virtual const char *name() { return "lyricsmania.com"; } + virtual const char *name() const OVERRIDE { return "lyricsmania.com"; } protected: - virtual const char *regex() { return "
(.*?)
"; } + virtual const char *regex() const OVERRIDE { return "
(.*?)
"; } }; struct Sing365Fetcher : public GoogleLyricsFetcher { - virtual const char *name() { return "sing365.com"; } + virtual const char *name() const OVERRIDE { return "sing365.com"; } protected: - virtual const char *regex() { return "(.*?)"; } + virtual const char *regex() const OVERRIDE { return "(.*?)"; } - virtual void postProcess(std::string &data); + virtual void postProcess(std::string &data) const OVERRIDE; }; struct JustSomeLyricsFetcher : public GoogleLyricsFetcher { - virtual const char *name() { return "justsomelyrics.com"; } + virtual const char *name() const OVERRIDE { return "justsomelyrics.com"; } protected: - virtual const char *regex() { return "
(.*?)
"; } + virtual const char *regex() const OVERRIDE { return "
(.*?)
"; } }; struct AzLyricsFetcher : public GoogleLyricsFetcher { - virtual const char *name() { return "azlyrics.com"; } + virtual const char *name() const OVERRIDE { return "azlyrics.com"; } protected: - virtual const char *regex() { return "
.*?.*
(.*?)
"; } + virtual const char *regex() const OVERRIDE { return "
.*?.*
(.*?)
"; } }; struct InternetLyricsFetcher : public GoogleLyricsFetcher { - virtual const char *name() { return "the Internet"; } - virtual Result fetch(const std::string &artist, const std::string &title); + virtual const char *name() const OVERRIDE { return "the Internet"; } + virtual Result fetch(const std::string &artist, const std::string &title) OVERRIDE; protected: - virtual const char *siteKeyword() { return "lyrics"; } - virtual const char *regex() { return ""; } + virtual const char *siteKeyword() const OVERRIDE { return "lyrics"; } + virtual const char *regex() const OVERRIDE { return ""; } - virtual bool isURLOk(const std::string &url); + virtual bool isURLOk(const std::string &url) OVERRIDE; private: std::string URL;