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