use ToLower() instead of calling std::transform explicitly all the time

This commit is contained in:
unK
2008-09-29 00:11:00 +02:00
parent dbe0480db5
commit 0a210a8896
6 changed files with 34 additions and 27 deletions

View File

@@ -18,7 +18,6 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <algorithm>
#include "helpers.h" #include "helpers.h"
#include "tag_editor.h" #include "tag_editor.h"
@@ -77,8 +76,8 @@ void UnlockStatusbar()
bool CaseInsensitiveSorting::operator()(string a, string b) bool CaseInsensitiveSorting::operator()(string a, string b)
{ {
transform(a.begin(), a.end(), a.begin(), tolower); ToLower(a);
transform(b.begin(), b.end(), b.begin(), tolower); ToLower(b);
return a < b; return a < b;
} }
@@ -86,8 +85,8 @@ bool CaseInsensitiveSorting::operator()(Song *sa, Song *sb)
{ {
string a = sa->GetName(); string a = sa->GetName();
string b = sb->GetName(); string b = sb->GetName();
transform(a.begin(), a.end(), a.begin(), tolower); ToLower(a);
transform(b.begin(), b.end(), b.begin(), tolower); ToLower(b);
return a < b; return a < b;
} }
@@ -97,8 +96,8 @@ bool CaseInsensitiveSorting::operator()(const Item &a, const Item &b)
{ {
string sa = a.type == itSong ? a.song->GetName() : a.name; string sa = a.type == itSong ? a.song->GetName() : a.name;
string sb = b.type == itSong ? b.song->GetName() : b.name; string sb = b.type == itSong ? b.song->GetName() : b.name;
transform(sa.begin(), sa.end(), sa.begin(), tolower); ToLower(sa);
transform(sb.begin(), sb.end(), sb.begin(), tolower); ToLower(sb);
return sa < sb; return sa < sb;
} }
else else

View File

@@ -71,7 +71,7 @@ void * GetArtistInfo(void *ptr)
delete strptr; delete strptr;
string filename = artist + ".txt"; string filename = artist + ".txt";
transform(filename.begin(), filename.end(), filename.begin(), tolower); ToLower(filename);
EscapeUnallowedChars(filename); EscapeUnallowedChars(filename);
const string fullpath = artists_folder + "/" + filename; const string fullpath = artists_folder + "/" + filename;

View File

@@ -18,6 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <algorithm>
#include "misc.h" #include "misc.h"
using std::stringstream; using std::stringstream;
@@ -27,6 +28,11 @@ int Abs(int num)
return (num < 0 ? -num : num); return (num < 0 ? -num : num);
} }
void ToLower(string &s)
{
transform(s.begin(), s.end(), s.begin(), tolower);
}
int StrToInt(string str) int StrToInt(string str)
{ {
return atoi(str.c_str()); return atoi(str.c_str());

View File

@@ -30,6 +30,8 @@ using std::string;
int Abs(int); int Abs(int);
void ToLower(string &);
int StrToInt(string); int StrToInt(string);
string IntoStr(int); string IntoStr(int);

View File

@@ -2945,13 +2945,13 @@ int main(int argc, char *argv[])
timer = time(NULL); timer = time(NULL);
if (findme.empty()) if (findme.empty())
continue; continue;
transform(findme.begin(), findme.end(), findme.begin(), tolower); ToLower(findme);
ShowMessage("Searching..."); ShowMessage("Searching...");
for (int i = (wCurrent == mSearcher ? search_engine_static_options-1 : 0); i < wCurrent->Size(); i++) for (int i = (wCurrent == mSearcher ? search_engine_static_options-1 : 0); i < wCurrent->Size(); i++)
{ {
string name = Window::OmitBBCodes(wCurrent->GetOption(i)); string name = Window::OmitBBCodes(wCurrent->GetOption(i));
transform(name.begin(), name.end(), name.begin(), tolower); ToLower(name);
if (name.find(findme) != string::npos && !wCurrent->IsStatic(i)) if (name.find(findme) != string::npos && !wCurrent->IsStatic(i))
{ {
vFoundPositions.push_back(i); vFoundPositions.push_back(i);

View File

@@ -90,27 +90,27 @@ void Search(Song &s)
{ {
string t; string t;
t = s.GetFile(); t = s.GetFile();
transform(t.begin(), t.end(), t.begin(), tolower); ToLower(t);
s.SetFile(t); s.SetFile(t);
t = s.GetTitle(); t = s.GetTitle();
transform(t.begin(), t.end(), t.begin(), tolower); ToLower(t);
s.SetTitle(t); s.SetTitle(t);
t = s.GetArtist(); t = s.GetArtist();
transform(t.begin(), t.end(), t.begin(), tolower); ToLower(t);
s.SetArtist(t); s.SetArtist(t);
t = s.GetAlbum(); t = s.GetAlbum();
transform(t.begin(), t.end(), t.begin(), tolower); ToLower(t);
s.SetAlbum(t); s.SetAlbum(t);
t = s.GetGenre(); t = s.GetGenre();
transform(t.begin(), t.end(), t.begin(), tolower); ToLower(t);
s.SetGenre(t); s.SetGenre(t);
t = s.GetComment(); t = s.GetComment();
transform(t.begin(), t.end(), t.begin(), tolower); ToLower(t);
s.SetComment(t); s.SetComment(t);
} }
@@ -122,27 +122,27 @@ void Search(Song &s)
{ {
string t; string t;
t = copy.GetName(); t = copy.GetName();
transform(t.begin(), t.end(), t.begin(), tolower); ToLower(t);
copy.SetFile(t); copy.SetFile(t);
t = copy.GetTitle(); t = copy.GetTitle();
transform(t.begin(), t.end(), t.begin(), tolower); ToLower(t);
copy.SetTitle(t); copy.SetTitle(t);
t = copy.GetArtist(); t = copy.GetArtist();
transform(t.begin(), t.end(), t.begin(), tolower); ToLower(t);
copy.SetArtist(t); copy.SetArtist(t);
t = copy.GetAlbum(); t = copy.GetAlbum();
transform(t.begin(), t.end(), t.begin(), tolower); ToLower(t);
copy.SetAlbum(t); copy.SetAlbum(t);
t = copy.GetGenre(); t = copy.GetGenre();
transform(t.begin(), t.end(), t.begin(), tolower); ToLower(t);
copy.SetGenre(t); copy.SetGenre(t);
t = copy.GetComment(); t = copy.GetComment();
transform(t.begin(), t.end(), t.begin(), tolower); ToLower(t);
copy.SetComment(t); copy.SetComment(t);
} }
else else