summaryrefslogtreecommitdiff
path: root/src/utility/comparators.h
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2012-09-05 18:02:37 +0200
committerAndrzej Rybczak <electricityispower@gmail.com>2012-09-05 18:02:37 +0200
commit7c6467a9e7ce67495274c7dcf989e2c08500b843 (patch)
tree04ffe270cdf2dd967429607b977ab60a87e05b2e /src/utility/comparators.h
parent95e2cfe6e168ccc33693a7408877b9b1f1e59ec0 (diff)
keys: implement parsing key configuration file
Diffstat (limited to 'src/utility/comparators.h')
-rw-r--r--src/utility/comparators.h41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/utility/comparators.h b/src/utility/comparators.h
index fa5b73b4..87ddad80 100644
--- a/src/utility/comparators.h
+++ b/src/utility/comparators.h
@@ -26,17 +26,24 @@
class CaseInsensitiveStringComparison
{
- bool hasTheWord(const std::string &s)
- {
- return (s.length() > 3)
- && (s[0] == 't' || s[0] == 'T')
- && (s[1] == 'h' || s[1] == 'H')
- && (s[2] == 'e' || s[2] == 'E')
- && (s[3] == ' ');
- }
+ bool m_ignore_the;
+
+ bool hasTheWord(const char *s) const;
public:
- int operator()(const std::string &a, const std::string &b);
+ CaseInsensitiveStringComparison(bool ignore_the) : m_ignore_the(ignore_the) { }
+
+ int operator()(const char *a, const char *b) const;
+
+ int operator()(const char *a, const std::string &b) const {
+ return (*this)(a, b.c_str());
+ }
+ int operator()(const std::string &a, const char *b) const {
+ return (*this)(a.c_str(), b);
+ }
+ int operator()(const std::string &a, const std::string &b) const {
+ return (*this)(a.c_str(), b.c_str());
+ }
};
class CaseInsensitiveSorting
@@ -44,22 +51,22 @@ class CaseInsensitiveSorting
CaseInsensitiveStringComparison cmp;
public:
- bool operator()(const std::string &a, const std::string &b)
- {
+ CaseInsensitiveSorting();
+
+ bool operator()(const std::string &a, const std::string &b) const {
return cmp(a, b) < 0;
}
- bool operator()(const MPD::Song &a, const MPD::Song &b)
- {
+ bool operator()(const MPD::Song &a, const MPD::Song &b) const {
return cmp(a.getName(), b.getName()) < 0;
}
- template <typename A, typename B> bool operator()(const std::pair<A, B> &a, const std::pair<A, B> &b)
- {
+ template <typename A, typename B>
+ bool operator()(const std::pair<A, B> &a, const std::pair<A, B> &b) const {
return cmp(a.first, b.first) < 0;
}
- bool operator()(const MPD::Item &a, const MPD::Item &b);
+ bool operator()(const MPD::Item &a, const MPD::Item &b) const;
};
-#endif // _UTILITY_COMPARATORS \ No newline at end of file
+#endif // _UTILITY_COMPARATORS