string: fix lowercase function
This commit is contained in:
@@ -2065,8 +2065,7 @@ void AddRandomItems::Run()
|
||||
if (answer != 's')
|
||||
{
|
||||
tag_type = charToTagType(answer);
|
||||
tag_type_str = tagTypeToString(tag_type);
|
||||
lowercase(tag_type_str);
|
||||
tag_type_str = lowercase(tagTypeToString(tag_type));
|
||||
}
|
||||
else
|
||||
tag_type_str = "song";
|
||||
@@ -2137,7 +2136,7 @@ void ToggleLibraryTagType::Run()
|
||||
std::string item_type = tagTypeToString(Config.media_lib_primary_tag);
|
||||
myLibrary->Tags->setTitle(Config.titles_visibility ? item_type + "s" : "");
|
||||
myLibrary->Tags->reset();
|
||||
lowercase(item_type);
|
||||
item_type = lowercase(item_type);
|
||||
if (myLibrary->Columns() == 2)
|
||||
{
|
||||
myLibrary->Songs->clear();
|
||||
|
||||
@@ -609,8 +609,7 @@ bool hasSupportedExtension(const std::string &file)
|
||||
if (last_dot > file.length())
|
||||
return false;
|
||||
|
||||
std::string ext = file.substr(last_dot+1);
|
||||
lowercase(ext);
|
||||
std::string ext = lowercase(file.substr(last_dot+1));
|
||||
return SupportedExtensions.find(ext) != SupportedExtensions.end();
|
||||
}
|
||||
|
||||
|
||||
@@ -124,8 +124,7 @@ void Lastfm::Load()
|
||||
std::string artist = itsArgs.find("artist")->second;
|
||||
locale_to_utf(artist);
|
||||
|
||||
std::string file = artist + ".txt";
|
||||
lowercase(file);
|
||||
std::string file = lowercase(artist + ".txt");
|
||||
removeInvalidCharsFromFilename(file);
|
||||
|
||||
itsFilename = itsFolder + "/" + file;
|
||||
|
||||
@@ -214,8 +214,7 @@ void MediaLibrary::SwitchTo()
|
||||
NextColumn();
|
||||
if (Config.titles_visibility)
|
||||
{
|
||||
std::string item_type = tagTypeToString(Config.media_lib_primary_tag);
|
||||
lowercase(item_type);
|
||||
std::string item_type = lowercase(tagTypeToString(Config.media_lib_primary_tag));
|
||||
Albums->setTitle("Albums (sorted by " + item_type + ")");
|
||||
}
|
||||
else
|
||||
@@ -766,8 +765,7 @@ void MediaLibrary::LocateSong(const MPD::Song &s)
|
||||
}
|
||||
if (primary_tag.empty())
|
||||
{
|
||||
std::string item_type = tagTypeToString(Config.media_lib_primary_tag);
|
||||
lowercase(item_type);
|
||||
std::string item_type = lowercase(tagTypeToString(Config.media_lib_primary_tag));
|
||||
ShowMessage("Can't use this function because the song has no %s tag set", item_type.c_str());
|
||||
return;
|
||||
}
|
||||
@@ -855,8 +853,7 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
|
||||
if ((!Tags->empty() && w == Tags)
|
||||
|| (w == Albums && Albums->current().value().Date == AllTracksMarker))
|
||||
{
|
||||
std::string tag_type = tagTypeToString(Config.media_lib_primary_tag);
|
||||
lowercase(tag_type);
|
||||
std::string tag_type = lowercase(tagTypeToString(Config.media_lib_primary_tag));
|
||||
ShowMessage("Songs with %s = \"%s\" added", tag_type.c_str(), Tags->current().value().c_str());
|
||||
}
|
||||
else if (w == Albums)
|
||||
|
||||
@@ -234,11 +234,13 @@ template <typename C> bool basic_buffer<C>::setFormatting(
|
||||
if (s.empty())
|
||||
return false;
|
||||
bool result = false;
|
||||
std::basic_string<C> base = m_string;
|
||||
if (!case_sensitive)
|
||||
std::basic_string<C> base;
|
||||
if (case_sensitive)
|
||||
base = m_string;
|
||||
else
|
||||
{
|
||||
lowercase(s);
|
||||
lowercase(base);
|
||||
base = lowercase(m_string);
|
||||
s = lowercase(s);
|
||||
}
|
||||
FormatPos fp;
|
||||
for (size_t i = base.find(s); i != std::basic_string<C>::npos; i = base.find(s, i))
|
||||
@@ -268,11 +270,13 @@ template <typename C> void basic_buffer<C>::removeFormatting(
|
||||
{
|
||||
if (pattern.empty())
|
||||
return;
|
||||
std::basic_string<C> base = m_string;
|
||||
if (!case_sensitive)
|
||||
std::basic_string<C> base;
|
||||
if (case_sensitive)
|
||||
base = m_string;
|
||||
else
|
||||
{
|
||||
lowercase(pattern);
|
||||
lowercase(base);
|
||||
base = lowercase(base);
|
||||
pattern = lowercase(pattern);
|
||||
}
|
||||
FormatPos fp;
|
||||
for (size_t i = base.find(pattern); i != std::basic_string<C>::npos; i = base.find(pattern, i))
|
||||
|
||||
@@ -1130,10 +1130,7 @@ void LowerAllLetters(MPD::MutableSong &s)
|
||||
{
|
||||
unsigned i = 0;
|
||||
for (std::string tag; !(tag = (s.*m->Get)(i)).empty(); ++i)
|
||||
{
|
||||
lowercase(tag);
|
||||
(s.*m->Set)(tag, i);
|
||||
}
|
||||
(s.*m->Set)(ToString(lowercase(ToWString(tag))), i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -189,8 +189,7 @@ bool TinyTagEditor::getTags()
|
||||
itsEdited.setComment(f.tag()->comment().to8Bit(1));
|
||||
|
||||
std::string ext = itsEdited.getURI();
|
||||
ext = ext.substr(ext.rfind(".")+1);
|
||||
lowercase(ext);
|
||||
ext = lowercase(ext.substr(ext.rfind(".")+1));
|
||||
|
||||
if (!isInitialized)
|
||||
Init();
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#define _UTILITY_STRING
|
||||
|
||||
#include <cstdarg>
|
||||
#include <locale>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "gcc.h"
|
||||
@@ -52,6 +53,16 @@ template <size_t N> struct print<N, std::wstring> {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename CharT>
|
||||
std::basic_string<CharT> lowercase(std::basic_string<CharT> s)
|
||||
{
|
||||
std::locale loc;
|
||||
const std::ctype<CharT> &ct = std::use_facet< std::ctype<CharT> >(loc);
|
||||
for (auto it = s.begin(); it != s.end(); ++it)
|
||||
*it = ct.tolower(*it);
|
||||
return s;
|
||||
}
|
||||
|
||||
int stringToInt(const std::string &s);
|
||||
long stringToLongInt(const std::string &s);
|
||||
bool isInteger(const char *s, bool accept_signed);
|
||||
@@ -62,9 +73,6 @@ std::wstring ToWString(const std::string &s);
|
||||
std::vector<std::string> split(const std::string &s, const std::string &delimiter);
|
||||
void replace(std::string &s, const std::string &from, const std::string &to);
|
||||
|
||||
void lowercase(std::string &s);
|
||||
void lowercase(std::wstring &s);
|
||||
|
||||
void trim(std::string &s);
|
||||
|
||||
std::string getBasename(const std::string &path);
|
||||
|
||||
Reference in New Issue
Block a user