playlist editor: hold MPD::PlaylistS instead of std::stringS
This commit is contained in:
@@ -35,10 +35,8 @@ bool hasTheWord(const std::string &s)
|
||||
|
||||
}
|
||||
|
||||
int LocaleStringComparison::operator()(const std::string &a, const std::string &b) const
|
||||
int LocaleStringComparison::compare(const char *a, size_t a_len, const char *b, size_t b_len) const
|
||||
{
|
||||
const char *ac = a.c_str();
|
||||
const char *bc = b.c_str();
|
||||
size_t ac_off = 0, bc_off = 0;
|
||||
if (m_ignore_the)
|
||||
{
|
||||
@@ -48,7 +46,7 @@ int LocaleStringComparison::operator()(const std::string &a, const std::string &
|
||||
bc_off += 4;
|
||||
}
|
||||
return std::use_facet<std::collate<char>>(m_locale).compare(
|
||||
ac+ac_off, ac+a.length(), bc+bc_off, bc+b.length()
|
||||
a+ac_off, a+a_len, b+bc_off, b+b_len
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,15 @@ class LocaleStringComparison
|
||||
public:
|
||||
LocaleStringComparison(const std::locale &loc, bool ignore_the)
|
||||
: m_locale(loc), m_ignore_the(ignore_the) { }
|
||||
|
||||
int operator()(const std::string &a, const std::string &b) const;
|
||||
|
||||
int operator()(const char *a, const char *b) const {
|
||||
return compare(a, strlen(a), b, strlen(b));
|
||||
}
|
||||
int operator()(const std::string &a, const std::string &b) const {
|
||||
return compare(a.c_str(), a.length(), b.c_str(), b.length());
|
||||
}
|
||||
|
||||
int compare(const char *a, size_t a_len, const char *b, size_t b_len) const;
|
||||
};
|
||||
|
||||
class LocaleBasedSorting
|
||||
@@ -50,6 +57,10 @@ public:
|
||||
return m_cmp(a, b) < 0;
|
||||
}
|
||||
|
||||
bool operator()(const MPD::Playlist &a, const MPD::Playlist &b) const {
|
||||
return m_cmp(a.path(), b.path()) < 0;
|
||||
}
|
||||
|
||||
bool operator()(const MPD::Song &a, const MPD::Song &b) const {
|
||||
return m_cmp(a.getName(), b.getName()) < 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user