remove using declarations

This commit is contained in:
Andrzej Rybczak
2009-07-05 12:19:22 +02:00
parent 4e77530f31
commit df051bf674
16 changed files with 409 additions and 444 deletions

View File

@@ -38,7 +38,6 @@
using namespace Global; using namespace Global;
using namespace MPD; using namespace MPD;
using std::string;
Browser *myBrowser = new Browser; Browser *myBrowser = new Browser;
@@ -87,7 +86,7 @@ void Browser::SwitchTo()
std::string Browser::Title() std::string Browser::Title()
{ {
string result = "Browse: "; std::string result = "Browse: ";
result += TO_STRING(Scroller(itsBrowsedDir, COLS-result.length()-VolumeState.length(), itsScrollBeginning)); result += TO_STRING(Scroller(itsBrowsedDir, COLS-result.length()-VolumeState.length(), itsScrollBeginning));
return result; return result;
} }
@@ -369,13 +368,13 @@ void Browser::ApplyFilter(const std::string &s)
w->ApplyFilter(s, itsBrowsedDir == "/" ? 0 : 1, REG_ICASE | Config.regex_type); w->ApplyFilter(s, itsBrowsedDir == "/" ? 0 : 1, REG_ICASE | Config.regex_type);
} }
bool Browser::hasSupportedExtension(const string &file) bool Browser::hasSupportedExtension(const std::string &file)
{ {
size_t last_dot = file.rfind("."); size_t last_dot = file.rfind(".");
if (last_dot > file.length()) if (last_dot > file.length())
return false; return false;
string ext = file.substr(last_dot+1); std::string ext = file.substr(last_dot+1);
ToLower(ext); ToLower(ext);
for (int i = 0; SupportedExtensions[i]; ++i) for (int i = 0; SupportedExtensions[i]; ++i)
if (strcmp(ext.c_str(), SupportedExtensions[i]) == 0) if (strcmp(ext.c_str(), SupportedExtensions[i]) == 0)
@@ -394,7 +393,7 @@ void Browser::GetLocalDirectory(ItemList &v, const std::string &directory, bool
dirent *file; dirent *file;
struct stat file_stat; struct stat file_stat;
string full_path; std::string full_path;
// omit . and .. // omit . and ..
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
@@ -453,7 +452,7 @@ void Browser::LocateSong(const MPD::Song &s)
SwitchTo(); SwitchTo();
string option = s.toString(Config.song_status_format); std::string option = s.toString(Config.song_status_format);
locale_to_utf(option); locale_to_utf(option);
if (itsBrowsedDir != s.GetDirectory()) if (itsBrowsedDir != s.GetDirectory())
GetDirectory(s.GetDirectory()); GetDirectory(s.GetDirectory());
@@ -467,7 +466,7 @@ void Browser::LocateSong(const MPD::Song &s)
} }
} }
void Browser::GetDirectory(string dir, string subdir) void Browser::GetDirectory(std::string dir, std::string subdir)
{ {
if (dir.empty()) if (dir.empty())
dir = "/"; dir = "/";
@@ -491,7 +490,7 @@ void Browser::GetDirectory(string dir, string subdir)
Item parent; Item parent;
size_t slash = dir.rfind("/"); size_t slash = dir.rfind("/");
parent.song = reinterpret_cast<Song *>(1); // in that way we assume that's really parent dir parent.song = reinterpret_cast<Song *>(1); // in that way we assume that's really parent dir
parent.name = slash != string::npos ? dir.substr(0, slash) : "/"; parent.name = slash != std::string::npos ? dir.substr(0, slash) : "/";
parent.type = itDirectory; parent.type = itDirectory;
utf_to_locale(parent.name); utf_to_locale(parent.name);
w->AddOption(parent); w->AddOption(parent);
@@ -547,7 +546,7 @@ void Browser::ClearDirectory(const std::string &path) const
dirent *file; dirent *file;
struct stat file_stat; struct stat file_stat;
string full_path; std::string full_path;
// omit . and .. // omit . and ..
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)

View File

@@ -23,12 +23,9 @@
#include "helpers.h" #include "helpers.h"
#include "playlist.h" #include "playlist.h"
using MPD::Song; std::string Display::Columns(std::string st)
using std::string;
string Display::Columns(string st)
{ {
string result; std::string result;
size_t where = 0; size_t where = 0;
for (int width = StrToInt(GetLineValue(st, '(', ')', 1)); width; width = StrToInt(GetLineValue(st, '(', ')', 1))) for (int width = StrToInt(GetLineValue(st, '(', ')', 1)); width; width = StrToInt(GetLineValue(st, '(', ')', 1)))
@@ -95,7 +92,7 @@ void Display::SongsInColumns(const MPD::Song &s, void *s_template, Menu<MPD::Son
if (!s.Localized()) if (!s.Localized())
const_cast<MPD::Song *>(&s)->Localize(); const_cast<MPD::Song *>(&s)->Localize();
string st = s_template ? *static_cast<string *>(s_template) : ""; std::string st = s_template ? *static_cast<std::string *>(s_template) : "";
size_t where = 0; size_t where = 0;
Color color = clDefault; Color color = clDefault;
@@ -113,51 +110,51 @@ void Display::SongsInColumns(const MPD::Song &s, void *s_template, Menu<MPD::Son
color = IntoColor(GetLineValue(st, '[', ']', 1)); color = IntoColor(GetLineValue(st, '[', ']', 1));
char type = GetLineValue(st, '{', '}', 1)[0]; char type = GetLineValue(st, '{', '}', 1)[0];
Song::GetFunction get = 0; MPD::Song::GetFunction get = 0;
switch (type) switch (type)
{ {
case 'l': case 'l':
get = &Song::GetLength; get = &MPD::Song::GetLength;
break; break;
case 'F': case 'F':
get = &Song::GetFile; get = &MPD::Song::GetFile;
break; break;
case 'f': case 'f':
get = &Song::GetName; get = &MPD::Song::GetName;
break; break;
case 'a': case 'a':
get = &Song::GetArtist; get = &MPD::Song::GetArtist;
break; break;
case 'b': case 'b':
get = &Song::GetAlbum; get = &MPD::Song::GetAlbum;
break; break;
case 'y': case 'y':
get = &Song::GetYear; get = &MPD::Song::GetYear;
break; break;
case 'n': case 'n':
get = &Song::GetTrack; get = &MPD::Song::GetTrack;
break; break;
case 'g': case 'g':
get = &Song::GetGenre; get = &MPD::Song::GetGenre;
break; break;
case 'c': case 'c':
get = &Song::GetComposer; get = &MPD::Song::GetComposer;
break; break;
case 'p': case 'p':
get = &Song::GetPerformer; get = &MPD::Song::GetPerformer;
break; break;
case 'd': case 'd':
get = &Song::GetDisc; get = &MPD::Song::GetDisc;
break; break;
case 'C': case 'C':
get = &Song::GetComment; get = &MPD::Song::GetComment;
break; break;
case 't': case 't':
if (!s.GetTitle().empty()) if (!s.GetTitle().empty())
get = &Song::GetTitle; get = &MPD::Song::GetTitle;
else else
get = &Song::GetName; get = &MPD::Song::GetName;
break; break;
default: default:
break; break;
@@ -165,7 +162,7 @@ void Display::SongsInColumns(const MPD::Song &s, void *s_template, Menu<MPD::Son
if (color != clDefault) if (color != clDefault)
*menu << color; *menu << color;
whline(menu->Raw(), 32, menu->GetWidth()-where); whline(menu->Raw(), 32, menu->GetWidth()-where);
string tag = (s.*get)(); std::string tag = (s.*get)();
if (!tag.empty()) if (!tag.empty())
*menu << tag; *menu << tag;
else else
@@ -181,19 +178,19 @@ void Display::Songs(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)
if (!s.Localized()) if (!s.Localized())
const_cast<MPD::Song *>(&s)->Localize(); const_cast<MPD::Song *>(&s)->Localize();
const string &song_template = data ? *static_cast<string *>(data) : ""; const std::string &song_template = data ? *static_cast<std::string *>(data) : "";
basic_buffer<my_char_t> buf; basic_buffer<my_char_t> buf;
bool right = 0; bool right = 0;
string::const_iterator goto_pos, prev_pos; std::string::const_iterator goto_pos, prev_pos;
for (string::const_iterator it = song_template.begin(); it != song_template.end(); ++it) for (std::string::const_iterator it = song_template.begin(); it != song_template.end(); ++it)
{ {
CHECK_LINKED_TAGS:; CHECK_LINKED_TAGS:;
if (*it == '{') if (*it == '{')
{ {
prev_pos = it; prev_pos = it;
Song::GetFunction get = 0; MPD::Song::GetFunction get = 0;
for (; *it != '}'; ++it) for (; *it != '}'; ++it)
{ {
if (*it == '%') if (*it == '%')
@@ -201,48 +198,48 @@ void Display::Songs(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)
switch (*++it) switch (*++it)
{ {
case 'l': case 'l':
get = &Song::GetLength; get = &MPD::Song::GetLength;
break; break;
case 'F': case 'F':
get = &Song::GetFile; get = &MPD::Song::GetFile;
break; break;
case 'f': case 'f':
get = &Song::GetName; get = &MPD::Song::GetName;
break; break;
case 'a': case 'a':
get = &Song::GetArtist; get = &MPD::Song::GetArtist;
break; break;
case 'b': case 'b':
get = &Song::GetAlbum; get = &MPD::Song::GetAlbum;
break; break;
case 'y': case 'y':
get = &Song::GetYear; get = &MPD::Song::GetYear;
break; break;
case 'n': case 'n':
get = &Song::GetTrack; get = &MPD::Song::GetTrack;
break; break;
case 'g': case 'g':
get = &Song::GetGenre; get = &MPD::Song::GetGenre;
break; break;
case 'c': case 'c':
get = &Song::GetComposer; get = &MPD::Song::GetComposer;
break; break;
case 'p': case 'p':
get = &Song::GetPerformer; get = &MPD::Song::GetPerformer;
break; break;
case 'd': case 'd':
get = &Song::GetDisc; get = &MPD::Song::GetDisc;
break; break;
case 'C': case 'C':
get = &Song::GetComment; get = &MPD::Song::GetComment;
break; break;
case 't': case 't':
get = &Song::GetTitle; get = &MPD::Song::GetTitle;
break; break;
default: default:
break; break;
} }
if (get == &Song::GetLength) if (get == &MPD::Song::GetLength)
{ {
if (!s.GetTotalLength()) if (!s.GetTotalLength())
break; break;
@@ -403,7 +400,7 @@ void Display::Songs(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)
void Display::Tags(const MPD::Song &s, void *data, Menu<MPD::Song> *menu) void Display::Tags(const MPD::Song &s, void *data, Menu<MPD::Song> *menu)
{ {
switch (static_cast<Menu<string> *>(data)->Choice()) switch (static_cast<Menu<std::string> *>(data)->Choice())
{ {
case 0: case 0:
*menu << ShowTag(s.GetTitle()); *menu << ShowTag(s.GetTitle());
@@ -474,14 +471,14 @@ void Display::Items(const MPD::Item &item, void *, Menu<MPD::Item> *menu)
} }
} }
void Display::SearchEngine(const std::pair<Buffer *, Song *> &pair, void *, Menu< std::pair<Buffer *, Song *> > *menu) void Display::SearchEngine(const std::pair<Buffer *, MPD::Song *> &pair, void *, Menu< std::pair<Buffer *, MPD::Song *> > *menu)
{ {
if (pair.second) if (pair.second)
{ {
if (!Config.columns_in_search_engine) if (!Config.columns_in_search_engine)
Display::Songs(*pair.second, &Config.song_list_format, reinterpret_cast<Menu<Song> *>(menu)); Display::Songs(*pair.second, &Config.song_list_format, reinterpret_cast<Menu<MPD::Song> *>(menu));
else else
Display::SongsInColumns(*pair.second, &Config.song_columns_list_format, reinterpret_cast<Menu<Song> *>(menu)); Display::SongsInColumns(*pair.second, &Config.song_columns_list_format, reinterpret_cast<Menu<MPD::Song> *>(menu));
} }
else else

View File

@@ -30,8 +30,6 @@
#include "tag_editor.h" #include "tag_editor.h"
using namespace MPD; using namespace MPD;
using Global::wFooter;
using std::string;
bool ConnectToMPD() bool ConnectToMPD()
{ {
@@ -45,9 +43,6 @@ bool ConnectToMPD()
void ParseArgv(int argc, char **argv) void ParseArgv(int argc, char **argv)
{ {
using std::cout;
using std::endl;
bool quit = 0; bool quit = 0;
for (int i = 1; i < argc; ++i) for (int i = 1; i < argc; ++i)
@@ -68,7 +63,7 @@ void ParseArgv(int argc, char **argv)
} }
else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0)
{ {
cout << "ncmpcpp version: " << VERSION << endl std::cout << "ncmpcpp version: " << VERSION << std::endl
<< "built with support for:" << "built with support for:"
# ifdef HAVE_CURL_CURL_H # ifdef HAVE_CURL_CURL_H
<< " curl" << " curl"
@@ -79,12 +74,12 @@ void ParseArgv(int argc, char **argv)
# ifdef _UTF8 # ifdef _UTF8
<< " unicode" << " unicode"
# endif # endif
<< endl; << std::endl;
exit(0); exit(0);
} }
else if (strcmp(argv[i], "-?") == 0 || strcmp(argv[i], "--help") == 0) else if (strcmp(argv[i], "-?") == 0 || strcmp(argv[i], "--help") == 0)
{ {
cout std::cout
<< "Usage: ncmpcpp [OPTION]...\n" << "Usage: ncmpcpp [OPTION]...\n"
<< " -h connect to server at host [localhost]\n" << " -h connect to server at host [localhost]\n"
<< " -p connect to server at port [6600]\n" << " -p connect to server at port [6600]\n"
@@ -152,7 +147,7 @@ void ParseArgv(int argc, char **argv)
Mpd.UpdateStatus(); Mpd.UpdateStatus();
if (!Mpd.GetErrorMessage().empty()) if (!Mpd.GetErrorMessage().empty())
{ {
cout << "Error: " << Mpd.GetErrorMessage() << endl; std::cout << "Error: " << Mpd.GetErrorMessage() << std::endl;
exit(0); exit(0);
} }
if (i != argc) if (i != argc)
@@ -161,12 +156,12 @@ void ParseArgv(int argc, char **argv)
} }
else else
{ {
cout << "ncmpcpp: invalid option: " << argv[i] << endl; std::cout << "ncmpcpp: invalid option: " << argv[i] << std::endl;
exit(0); exit(0);
} }
if (!Mpd.GetErrorMessage().empty()) if (!Mpd.GetErrorMessage().empty())
{ {
cout << "Error: " << Mpd.GetErrorMessage() << endl; std::cout << "Error: " << Mpd.GetErrorMessage() << std::endl;
exit(0); exit(0);
} }
} }
@@ -174,7 +169,7 @@ void ParseArgv(int argc, char **argv)
exit(0); exit(0);
} }
bool CaseInsensitiveSorting::operator()(string a, string b) bool CaseInsensitiveSorting::operator()(std::string a, std::string b)
{ {
ToLower(a); ToLower(a);
ToLower(b); ToLower(b);
@@ -188,8 +183,8 @@ bool CaseInsensitiveSorting::operator()(string a, string b)
bool CaseInsensitiveSorting::operator()(Song *sa, Song *sb) bool CaseInsensitiveSorting::operator()(Song *sa, Song *sb)
{ {
string a = sa->GetName(); std::string a = sa->GetName();
string b = sb->GetName(); std::string b = sb->GetName();
ToLower(a); ToLower(a);
ToLower(b); ToLower(b);
if (Config.ignore_leading_the) if (Config.ignore_leading_the)
@@ -240,7 +235,7 @@ void UpdateSongList(Menu<Song> *menu)
} }
#ifdef HAVE_TAGLIB_H #ifdef HAVE_TAGLIB_H
string FindSharedDir(Menu<Song> *menu) std::string FindSharedDir(Menu<Song> *menu)
{ {
SongList list; SongList list;
for (size_t i = 0; i < menu->Size(); ++i) for (size_t i = 0; i < menu->Size(); ++i)
@@ -248,9 +243,9 @@ string FindSharedDir(Menu<Song> *menu)
return FindSharedDir(list); return FindSharedDir(list);
} }
string FindSharedDir(const SongList &v) std::string FindSharedDir(const SongList &v)
{ {
string result; std::string result;
if (!v.empty()) if (!v.empty())
{ {
result = v.front()->GetFile(); result = v.front()->GetFile();
@@ -262,30 +257,30 @@ string FindSharedDir(const SongList &v)
result = result.substr(0, i); result = result.substr(0, i);
} }
size_t slash = result.rfind("/"); size_t slash = result.rfind("/");
result = slash != string::npos ? result.substr(0, slash) : "/"; result = slash != std::string::npos ? result.substr(0, slash) : "/";
} }
return result; return result;
} }
#endif // HAVE_TAGLIB_H #endif // HAVE_TAGLIB_H
string FindSharedDir(const string &one, const string &two) std::string FindSharedDir(const std::string &one, const std::string &two)
{ {
if (one == two) if (one == two)
return one; return one;
string result; std::string result;
size_t i = 1; size_t i = 1;
while (one.substr(0, i) == two.substr(0, i)) while (one.substr(0, i) == two.substr(0, i))
i++; i++;
result = one.substr(0, i); result = one.substr(0, i);
i = result.rfind("/"); i = result.rfind("/");
return i != string::npos ? result.substr(0, i) : "/"; return i != std::string::npos ? result.substr(0, i) : "/";
} }
string GetLineValue(string &line, char a, char b, bool once) std::string GetLineValue(std::string &line, char a, char b, bool once)
{ {
int pos[2] = { -1, -1 }; int pos[2] = { -1, -1 };
size_t i; size_t i;
for (i = line.find(a); i != string::npos && pos[1] < 0; i = line.find(b, i)) for (i = line.find(a); i != std::string::npos && pos[1] < 0; i = line.find(b, i))
{ {
if (i && line[i-1] == '\\') if (i && line[i-1] == '\\')
{ {
@@ -297,26 +292,26 @@ string GetLineValue(string &line, char a, char b, bool once)
pos[pos[0] >= 0] = i++; pos[pos[0] >= 0] = i++;
} }
pos[0]++; pos[0]++;
string result = pos[0] >= 0 && pos[1] >= 0 ? line.substr(pos[0], pos[1]-pos[0]) : ""; std::string result = pos[0] >= 0 && pos[1] >= 0 ? line.substr(pos[0], pos[1]-pos[0]) : "";
for (i = result.find("\\\""); i != string::npos; i = result.find("\\\"")) for (i = result.find("\\\""); i != std::string::npos; i = result.find("\\\""))
result.replace(i, 2, "\""); result.replace(i, 2, "\"");
return result; return result;
} }
void RemoveTheWord(string &s) void RemoveTheWord(std::string &s)
{ {
size_t the_pos = s.find("the "); size_t the_pos = s.find("the ");
if (the_pos == 0 && the_pos != string::npos) if (the_pos == 0 && the_pos != std::string::npos)
s = s.substr(4); s = s.substr(4);
} }
std::string ExtractTopDirectory(const std::string &s) std::string ExtractTopDirectory(const std::string &s)
{ {
size_t slash = s.rfind("/"); size_t slash = s.rfind("/");
return slash != string::npos ? s.substr(++slash) : s; return slash != std::string::npos ? s.substr(++slash) : s;
} }
Buffer ShowTag(const string &tag) Buffer ShowTag(const std::string &tag)
{ {
Buffer result; Buffer result;
if (tag.empty()) if (tag.empty())
@@ -326,7 +321,7 @@ Buffer ShowTag(const string &tag)
return result; return result;
} }
std::basic_string<my_char_t> Scroller(const string &str, size_t width, size_t &pos) std::basic_string<my_char_t> Scroller(const std::string &str, size_t width, size_t &pos)
{ {
std::basic_string<my_char_t> s = TO_WSTRING(str); std::basic_string<my_char_t> s = TO_WSTRING(str);
if (!Config.header_text_scrolling) if (!Config.header_text_scrolling)

View File

@@ -42,8 +42,6 @@
#include "tag_editor.h" #include "tag_editor.h"
using namespace Global; using namespace Global;
using std::string;
using std::vector;
#ifdef HAVE_CURL_CURL_H #ifdef HAVE_CURL_CURL_H
const std::string Info::Folder = home_path + HOME_FOLDER"artists"; const std::string Info::Folder = home_path + HOME_FOLDER"artists";
@@ -167,7 +165,7 @@ void Info::GetArtist()
{ {
locale_to_utf(itsArtist); locale_to_utf(itsArtist);
string file = itsArtist + ".txt"; std::string file = itsArtist + ".txt";
ToLower(file); ToLower(file);
EscapeUnallowedChars(file); EscapeUnallowedChars(file);
@@ -183,7 +181,7 @@ void Info::GetArtist()
if (input.is_open()) if (input.is_open())
{ {
bool first = 1; bool first = 1;
string line; std::string line;
while (getline(input, line)) while (getline(input, line))
{ {
if (!first) if (!first)
@@ -218,11 +216,11 @@ void *Info::PrepareArtist(void *screen_void_ptr)
Info *screen = static_cast<Info *>(screen_void_ptr); Info *screen = static_cast<Info *>(screen_void_ptr);
char *c_artist = curl_easy_escape(0, screen->itsArtist.c_str(), screen->itsArtist.length()); char *c_artist = curl_easy_escape(0, screen->itsArtist.c_str(), screen->itsArtist.length());
string url = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist="; std::string url = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=";
url += c_artist; url += c_artist;
url += "&api_key=d94e5b6e26469a2d1ffae8ef20131b79"; url += "&api_key=d94e5b6e26469a2d1ffae8ef20131b79";
string result; std::string result;
CURLcode code; CURLcode code;
pthread_mutex_lock(&CurlLock); pthread_mutex_lock(&CurlLock);
@@ -250,7 +248,7 @@ void *Info::PrepareArtist(void *screen_void_ptr)
a = result.find("status=\"failed\""); a = result.find("status=\"failed\"");
if (a != string::npos) if (a != std::string::npos)
{ {
EscapeHtml(result); EscapeHtml(result);
*screen->w << "Last.fm returned an error message: " << result; *screen->w << "Last.fm returned an error message: " << result;
@@ -258,8 +256,8 @@ void *Info::PrepareArtist(void *screen_void_ptr)
pthread_exit(0); pthread_exit(0);
} }
vector<string> similar; std::vector<std::string> similar;
for (size_t i = result.find("<name>"); i != string::npos; i = result.find("<name>")) for (size_t i = result.find("<name>"); i != std::string::npos; i = result.find("<name>"))
{ {
result[i] = '.'; result[i] = '.';
size_t j = result.find("</name>"); size_t j = result.find("</name>");
@@ -268,8 +266,8 @@ void *Info::PrepareArtist(void *screen_void_ptr)
similar.push_back(result.substr(i, j-i)); similar.push_back(result.substr(i, j-i));
EscapeHtml(similar.back()); EscapeHtml(similar.back());
} }
vector<string> urls; std::vector<std::string> urls;
for (size_t i = result.find("<url>"); i != string::npos; i = result.find("<url>")) for (size_t i = result.find("<url>"); i != std::string::npos; i = result.find("<url>"))
{ {
result[i] = '.'; result[i] = '.';
size_t j = result.find("</url>"); size_t j = result.find("</url>");
@@ -336,7 +334,7 @@ void *Info::PrepareArtist(void *screen_void_ptr)
void Info::PrepareSong(MPD::Song &s) void Info::PrepareSong(MPD::Song &s)
{ {
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
string path_to_file; std::string path_to_file;
if (s.IsFromDB()) if (s.IsFromDB())
path_to_file += Config.mpd_music_dir; path_to_file += Config.mpd_music_dir;
path_to_file += s.GetFile(); path_to_file += s.GetFile();
@@ -370,7 +368,7 @@ void Info::PrepareSong(MPD::Song &s)
*w << fmtBold << "\nComment: " << fmtBoldEnd << ShowTag(s.GetComment()); *w << fmtBold << "\nComment: " << fmtBoldEnd << ShowTag(s.GetComment());
} }
basic_buffer<my_char_t> Info::ShowTag(const string &tag) basic_buffer<my_char_t> Info::ShowTag(const std::string &tag)
{ {
# ifdef _UTF8 # ifdef _UTF8
WBuffer result; WBuffer result;

View File

@@ -49,8 +49,6 @@
#endif // WIN32 #endif // WIN32
using namespace Global; using namespace Global;
using std::vector;
using std::string;
const std::string Lyrics::Folder = home_path + LYRICS_FOLDER; const std::string Lyrics::Folder = home_path + LYRICS_FOLDER;
@@ -145,7 +143,7 @@ void Lyrics::SwitchTo()
# endif // HAVE_PTHREAD_H # endif // HAVE_PTHREAD_H
# endif // HAVE_CURL_CURL_H # endif // HAVE_CURL_CURL_H
{ {
string file = locale_to_utf_cpy(itsSong.GetArtist()) + " - " + locale_to_utf_cpy(itsSong.GetTitle()) + ".txt"; std::string file = locale_to_utf_cpy(itsSong.GetArtist()) + " - " + locale_to_utf_cpy(itsSong.GetTitle()) + ".txt";
EscapeUnallowedChars(file); EscapeUnallowedChars(file);
itsFilenamePath = Folder + "/" + file; itsFilenamePath = Folder + "/" + file;
@@ -159,7 +157,7 @@ void Lyrics::SwitchTo()
if (input.is_open()) if (input.is_open())
{ {
bool first = 1; bool first = 1;
string line; std::string line;
while (getline(input, line)) while (getline(input, line))
{ {
if (!first) if (!first)
@@ -191,7 +189,7 @@ void Lyrics::SwitchTo()
std::string Lyrics::Title() std::string Lyrics::Title()
{ {
string result = "Lyrics: "; std::string result = "Lyrics: ";
result += TO_STRING(Scroller(itsSong.toString("%a - %t"), COLS-result.length()-VolumeState.length(), itsScrollBegin)); result += TO_STRING(Scroller(itsSong.toString("%a - %t"), COLS-result.length()-VolumeState.length(), itsScrollBegin));
return result; return result;
} }
@@ -208,14 +206,14 @@ void *Lyrics::Get(void *screen_void_ptr)
Lyrics *screen = static_cast<Lyrics *>(screen_void_ptr); Lyrics *screen = static_cast<Lyrics *>(screen_void_ptr);
const Plugin *my_lyrics = ChoosePlugin(Config.lyrics_db); const Plugin *my_lyrics = ChoosePlugin(Config.lyrics_db);
string result; std::string result;
string artist = locale_to_utf_cpy(screen->itsSong.GetArtist()); std::string artist = locale_to_utf_cpy(screen->itsSong.GetArtist());
string title = locale_to_utf_cpy(screen->itsSong.GetTitle()); std::string title = locale_to_utf_cpy(screen->itsSong.GetTitle());
char *c_artist = curl_easy_escape(0, artist.c_str(), artist.length()); char *c_artist = curl_easy_escape(0, artist.c_str(), artist.length());
char *c_title = curl_easy_escape(0, title.c_str(), title.length()); char *c_title = curl_easy_escape(0, title.c_str(), title.length());
string url = my_lyrics->url; std::string url = my_lyrics->url;
url.replace(url.find("%artist%"), 8, c_artist); url.replace(url.find("%artist%"), 8, c_artist);
url.replace(url.find("%title%"), 7, c_title); url.replace(url.find("%title%"), 7, c_title);
@@ -253,9 +251,9 @@ void *Lyrics::Get(void *screen_void_ptr)
pthread_exit(0); pthread_exit(0);
} }
for (size_t i = result.find("&lt;"); i != string::npos; i = result.find("&lt;")) for (size_t i = result.find("&lt;"); i != std::string::npos; i = result.find("&lt;"))
result.replace(i, 4, "<"); result.replace(i, 4, "<");
for (size_t i = result.find("&gt;"); i != string::npos; i = result.find("&gt;")) for (size_t i = result.find("&gt;"); i != std::string::npos; i = result.find("&gt;"))
result.replace(i, 4, ">"); result.replace(i, 4, ">");
EscapeHtml(result); EscapeHtml(result);
@@ -320,16 +318,16 @@ const char *Lyrics::GetPluginName(int offset)
return PluginsList[offset]; return PluginsList[offset];
} }
bool Lyrics::LyricWiki_NotFound(const string &s) bool Lyrics::LyricWiki_NotFound(const std::string &s)
{ {
return s == "Not found"; return s == "Not found";
} }
bool Lyrics::LyricsPlugin_NotFound(const string &s) bool Lyrics::LyricsPlugin_NotFound(const std::string &s)
{ {
if (s.empty()) if (s.empty())
return true; return true;
for (string::const_iterator it = s.begin(); it != s.end(); ++it) for (std::string::const_iterator it = s.begin(); it != s.end(); ++it)
if (isprint(*it)) if (isprint(*it))
return false; return false;
return true; return true;

View File

@@ -31,7 +31,6 @@
using namespace MPD; using namespace MPD;
using namespace Global; using namespace Global;
using std::string;
MediaLibrary *myLibrary = new MediaLibrary; MediaLibrary *myLibrary = new MediaLibrary;
@@ -51,7 +50,7 @@ void MediaLibrary::Init()
itsRightColWidth = COLS-COLS/3*2-1; itsRightColWidth = COLS-COLS/3*2-1;
itsRightColStartX = itsLeftColWidth+itsMiddleColWidth+2; itsRightColStartX = itsLeftColWidth+itsMiddleColWidth+2;
Artists = new Menu<string>(0, MainStartY, itsLeftColWidth, MainHeight, IntoStr(Config.media_lib_primary_tag) + "s", Config.main_color, brNone); Artists = new Menu<std::string>(0, MainStartY, itsLeftColWidth, MainHeight, IntoStr(Config.media_lib_primary_tag) + "s", Config.main_color, brNone);
Artists->HighlightColor(Config.active_column_color); Artists->HighlightColor(Config.active_column_color);
Artists->SetTimeout(ncmpcpp_window_timeout); Artists->SetTimeout(ncmpcpp_window_timeout);
Artists->CyclicScrolling(Config.use_cyclic_scrolling); Artists->CyclicScrolling(Config.use_cyclic_scrolling);
@@ -134,7 +133,7 @@ void MediaLibrary::SwitchTo()
{ {
if (w == Artists) if (w == Artists)
NextColumn(); NextColumn();
string item_type = IntoStr(Config.media_lib_primary_tag); std::string item_type = IntoStr(Config.media_lib_primary_tag);
ToLower(item_type); ToLower(item_type);
Albums->SetTitle("Albums (sorted by " + item_type + ")"); Albums->SetTitle("Albums (sorted by " + item_type + ")");
} }
@@ -482,7 +481,7 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
if (it != list.begin()) if (it != list.begin())
{ {
string tag_type = IntoStr(Config.media_lib_primary_tag); std::string tag_type = IntoStr(Config.media_lib_primary_tag);
ToLower(tag_type); ToLower(tag_type);
ShowMessage("Adding songs of %s \"%s\"", tag_type.c_str(), Artists->Current().c_str()); ShowMessage("Adding songs of %s \"%s\"", tag_type.c_str(), Artists->Current().c_str());
Song *s = &myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size()); Song *s = &myPlaylist->Main()->at(myPlaylist->Main()->Size()-list.size());

View File

@@ -26,8 +26,6 @@
using namespace MPD; using namespace MPD;
using std::string;
MPD::Connection Mpd; MPD::Connection Mpd;
const char *MPD::Message::PartOfSongsAdded = "Only part of requested songs' list added to playlist!"; const char *MPD::Message::PartOfSongsAdded = "Only part of requested songs' list added to playlist!";
@@ -101,10 +99,10 @@ float Connection::Version() const
return itsConnection ? itsConnection->version[1] + itsConnection->version[2]*0.1 : 0; return itsConnection ? itsConnection->version[1] + itsConnection->version[2]*0.1 : 0;
} }
void Connection::SetHostname(const string &host) void Connection::SetHostname(const std::string &host)
{ {
size_t at = host.find("@"); size_t at = host.find("@");
if (at != string::npos) if (at != std::string::npos)
{ {
itsPassword = host.substr(0, at); itsPassword = host.substr(0, at);
itsHost = host.substr(at+1); itsHost = host.substr(at+1);
@@ -194,7 +192,7 @@ void Connection::UpdateStatus()
} }
} }
void Connection::UpdateDirectory(const string &path) void Connection::UpdateDirectory(const std::string &path)
{ {
if (isConnected) if (isConnected)
{ {
@@ -211,7 +209,7 @@ void Connection::UpdateDirectory(const string &path)
} }
} }
void Connection::Execute(const string &command) const void Connection::Execute(const std::string &command) const
{ {
if (isConnected) if (isConnected)
{ {
@@ -337,7 +335,7 @@ void Connection::ClearPlaylist() const
} }
} }
void Connection::ClearPlaylist(const string &playlist) const void Connection::ClearPlaylist(const std::string &playlist) const
{ {
if (isConnected) if (isConnected)
{ {
@@ -347,13 +345,13 @@ void Connection::ClearPlaylist(const string &playlist) const
} }
} }
void Connection::AddToPlaylist(const string &path, const Song &s) const void Connection::AddToPlaylist(const std::string &path, const Song &s) const
{ {
if (!s.Empty()) if (!s.Empty())
AddToPlaylist(path, s.GetFile()); AddToPlaylist(path, s.GetFile());
} }
void Connection::AddToPlaylist(const string &path, const string &file) const void Connection::AddToPlaylist(const std::string &path, const std::string &file) const
{ {
if (isConnected) if (isConnected)
{ {
@@ -363,7 +361,7 @@ void Connection::AddToPlaylist(const string &path, const string &file) const
} }
} }
void Connection::Move(const string &path, int from, int to) const void Connection::Move(const std::string &path, int from, int to) const
{ {
if (isConnected) if (isConnected)
{ {
@@ -373,7 +371,7 @@ void Connection::Move(const string &path, int from, int to) const
} }
} }
void Connection::Rename(const string &from, const string &to) const void Connection::Rename(const std::string &from, const std::string &to) const
{ {
if (isConnected) if (isConnected)
{ {
@@ -408,7 +406,7 @@ void Connection::GetPlaylistChanges(long long id, SongList &v) const
} }
} }
Song Connection::GetSong(const string &path) const Song Connection::GetSong(const std::string &path) const
{ {
if (isConnected) if (isConnected)
{ {
@@ -452,7 +450,7 @@ Song Connection::GetCurrentSong() const
return Song(); return Song();
} }
void Connection::GetPlaylistContent(const string &path, SongList &v) const void Connection::GetPlaylistContent(const std::string &path, SongList &v) const
{ {
if (isConnected) if (isConnected)
{ {
@@ -538,7 +536,7 @@ void Connection::SetCrossfade(int crossfade) const
} }
} }
int Connection::AddSong(const string &path) int Connection::AddSong(const std::string &path)
{ {
int id = -1; int id = -1;
if (isConnected) if (isConnected)
@@ -619,7 +617,7 @@ void Connection::DeleteID(int id) const
} }
} }
void Connection::Delete(const string &playlist, int pos) const void Connection::Delete(const std::string &playlist, int pos) const
{ {
if (isConnected) if (isConnected)
{ {
@@ -652,7 +650,7 @@ void Connection::CommitCommandsList()
} }
} }
void Connection::DeletePlaylist(const string &name) const void Connection::DeletePlaylist(const std::string &name) const
{ {
if (isConnected) if (isConnected)
{ {
@@ -662,7 +660,7 @@ void Connection::DeletePlaylist(const string &name) const
} }
} }
bool Connection::SavePlaylist(const string &name) const bool Connection::SavePlaylist(const std::string &name) const
{ {
if (isConnected) if (isConnected)
{ {
@@ -705,7 +703,7 @@ void Connection::GetList(TagList &v, mpd_TagItems type) const
} }
} }
void Connection::GetAlbums(const string &artist, TagList &v) const void Connection::GetAlbums(const std::string &artist, TagList &v) const
{ {
if (isConnected) if (isConnected)
{ {
@@ -736,7 +734,7 @@ void Connection::StartFieldSearch(mpd_TagItems item)
} }
} }
void Connection::AddSearch(mpd_TagItems item, const string &str) const void Connection::AddSearch(mpd_TagItems item, const std::string &str) const
{ {
// mpd version < 0.14.* doesn't support empty search constraints // mpd version < 0.14.* doesn't support empty search constraints
if (Version() < 14 && str.empty()) if (Version() < 14 && str.empty())
@@ -781,7 +779,7 @@ void Connection::CommitSearch(TagList &v) const
} }
} }
void Connection::GetDirectory(const string &path, ItemList &v) const void Connection::GetDirectory(const std::string &path, ItemList &v) const
{ {
if (isConnected) if (isConnected)
{ {
@@ -813,7 +811,7 @@ void Connection::GetDirectory(const string &path, ItemList &v) const
} }
} }
void Connection::GetDirectoryRecursive(const string &path, SongList &v) const void Connection::GetDirectoryRecursive(const std::string &path, SongList &v) const
{ {
if (isConnected) if (isConnected)
{ {
@@ -833,7 +831,7 @@ void Connection::GetDirectoryRecursive(const string &path, SongList &v) const
} }
} }
void Connection::GetSongs(const string &path, SongList &v) const void Connection::GetSongs(const std::string &path, SongList &v) const
{ {
if (isConnected) if (isConnected)
{ {
@@ -853,7 +851,7 @@ void Connection::GetSongs(const string &path, SongList &v) const
} }
} }
void Connection::GetDirectories(const string &path, TagList &v) const void Connection::GetDirectories(const std::string &path, TagList &v) const
{ {
if (isConnected) if (isConnected)
{ {

View File

@@ -66,9 +66,6 @@
using namespace Global; using namespace Global;
using namespace MPD; using namespace MPD;
using std::string;
using std::vector;
BasicScreen *Global::myScreen; BasicScreen *Global::myScreen;
BasicScreen *Global::myOldScreen; BasicScreen *Global::myOldScreen;
@@ -156,7 +153,7 @@ int main(int argc, char *argv[])
bool main_exit = 0; bool main_exit = 0;
bool title_allowed = !Config.display_screens_numbers_on_start; bool title_allowed = !Config.display_screens_numbers_on_start;
string screen_title; std::string screen_title;
timeval now, past; timeval now, past;
// local variables end // local variables end
@@ -471,10 +468,10 @@ int main(int argc, char *argv[])
Playlist::BlockUpdate = 1; Playlist::BlockUpdate = 1;
if (myPlaylist->Main()->hasSelected()) if (myPlaylist->Main()->hasSelected())
{ {
vector<size_t> list; std::vector<size_t> list;
myPlaylist->Main()->GetSelected(list); myPlaylist->Main()->GetSelected(list);
Mpd.StartCommandsList(); Mpd.StartCommandsList();
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); ++it) for (std::vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); ++it)
{ {
Mpd.DeleteID((*myPlaylist->Main())[*it].GetID()); Mpd.DeleteID((*myPlaylist->Main())[*it].GetID());
myPlaylist->Main()->DeleteOption(*it); myPlaylist->Main()->DeleteOption(*it);
@@ -514,7 +511,7 @@ int main(int argc, char *argv[])
) )
{ {
LockStatusbar(); LockStatusbar();
string name = myScreen == myBrowser ? myBrowser->Main()->Current().name : myPlaylistEditor->Playlists->Current(); std::string name = myScreen == myBrowser ? myBrowser->Main()->Current().name : myPlaylistEditor->Playlists->Current();
Statusbar() << "Delete playlist \"" << name << "\" ? [y/n] "; Statusbar() << "Delete playlist \"" << name << "\" ? [y/n] ";
curs_set(1); curs_set(1);
int in = 0; int in = 0;
@@ -559,7 +556,7 @@ int main(int argc, char *argv[])
continue; continue;
LockStatusbar(); LockStatusbar();
string name = item.type == itSong ? item.song->GetName() : item.name; std::string name = item.type == itSong ? item.song->GetName() : item.name;
Statusbar() << "Delete " << (item.type == itSong ? "file" : "directory") << " \"" << name << "\" ? [y/n] "; Statusbar() << "Delete " << (item.type == itSong ? "file" : "directory") << " \"" << name << "\" ? [y/n] ";
curs_set(1); curs_set(1);
int in = 0; int in = 0;
@@ -571,7 +568,7 @@ int main(int argc, char *argv[])
while (in != 'y' && in != 'n'); while (in != 'y' && in != 'n');
if (in == 'y') if (in == 'y')
{ {
string path; std::string path;
if (!Config.local_browser) if (!Config.local_browser)
path = Config.mpd_music_dir; path = Config.mpd_music_dir;
path += item.type == itSong ? item.song->GetFile() : item.name; path += item.type == itSong ? item.song->GetFile() : item.name;
@@ -599,12 +596,12 @@ int main(int argc, char *argv[])
{ {
if (myPlaylistEditor->Content->hasSelected()) if (myPlaylistEditor->Content->hasSelected())
{ {
vector<size_t> list; std::vector<size_t> list;
myPlaylistEditor->Content->GetSelected(list); myPlaylistEditor->Content->GetSelected(list);
string playlist = locale_to_utf_cpy(myPlaylistEditor->Playlists->Current()); std::string playlist = locale_to_utf_cpy(myPlaylistEditor->Playlists->Current());
ShowMessage("Deleting selected items..."); ShowMessage("Deleting selected items...");
Mpd.StartCommandsList(); Mpd.StartCommandsList();
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); ++it) for (std::vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); ++it)
{ {
Mpd.Delete(playlist, *it); Mpd.Delete(playlist, *it);
myPlaylistEditor->Content->DeleteOption(*it); myPlaylistEditor->Content->DeleteOption(*it);
@@ -649,10 +646,10 @@ int main(int argc, char *argv[])
{ {
LockStatusbar(); LockStatusbar();
Statusbar() << "Save playlist as: "; Statusbar() << "Save playlist as: ";
string playlist_name = wFooter->GetString(); std::string playlist_name = wFooter->GetString();
string real_playlist_name = locale_to_utf_cpy(playlist_name); std::string real_playlist_name = locale_to_utf_cpy(playlist_name);
UnlockStatusbar(); UnlockStatusbar();
if (playlist_name.find("/") != string::npos) if (playlist_name.find("/") != std::string::npos)
{ {
ShowMessage("Playlist name cannot contain slashes!"); ShowMessage("Playlist name cannot contain slashes!");
continue; continue;
@@ -723,21 +720,21 @@ int main(int argc, char *argv[])
myPlaylist->Main()->SetTimeout(50); myPlaylist->Main()->SetTimeout(50);
if (myPlaylist->Main()->hasSelected()) if (myPlaylist->Main()->hasSelected())
{ {
vector<size_t> list; std::vector<size_t> list;
myPlaylist->Main()->GetSelected(list); myPlaylist->Main()->GetSelected(list);
for (vector<size_t>::iterator it = list.begin(); it != list.end(); ++it) for (std::vector<size_t>::iterator it = list.begin(); it != list.end(); ++it)
if (*it == size_t(myPlaylist->NowPlaying) && list.front() > 0) if (*it == size_t(myPlaylist->NowPlaying) && list.front() > 0)
myPlaylist->Main()->BoldOption(myPlaylist->NowPlaying, 0); myPlaylist->Main()->BoldOption(myPlaylist->NowPlaying, 0);
vector<size_t> origs(list); std::vector<size_t> origs(list);
while (Keypressed(input, Key.MvSongUp) && list.front() > 0) while (Keypressed(input, Key.MvSongUp) && list.front() > 0)
{ {
TraceMpdStatus(); TraceMpdStatus();
Playlist::BlockUpdate = 1; Playlist::BlockUpdate = 1;
myPlaylist->UpdateTimer(); myPlaylist->UpdateTimer();
for (vector<size_t>::iterator it = list.begin(); it != list.end(); ++it) for (std::vector<size_t>::iterator it = list.begin(); it != list.end(); ++it)
{ {
(*it)--; (*it)--;
myPlaylist->Main()->at((*it)+1).SetPosition(*it); myPlaylist->Main()->at((*it)+1).SetPosition(*it);
@@ -783,16 +780,16 @@ int main(int argc, char *argv[])
myPlaylistEditor->Content->SetTimeout(50); myPlaylistEditor->Content->SetTimeout(50);
if (myPlaylistEditor->Content->hasSelected()) if (myPlaylistEditor->Content->hasSelected())
{ {
vector<size_t> list; std::vector<size_t> list;
myPlaylistEditor->Content->GetSelected(list); myPlaylistEditor->Content->GetSelected(list);
vector<size_t> origs(list); std::vector<size_t> origs(list);
while (Keypressed(input, Key.MvSongUp) && list.front() > 0) while (Keypressed(input, Key.MvSongUp) && list.front() > 0)
{ {
TraceMpdStatus(); TraceMpdStatus();
myPlaylist->UpdateTimer(); myPlaylist->UpdateTimer();
for (vector<size_t>::iterator it = list.begin(); it != list.end(); ++it) for (std::vector<size_t>::iterator it = list.begin(); it != list.end(); ++it)
{ {
(*it)--; (*it)--;
myPlaylistEditor->Content->Swap(*it, (*it)+1); myPlaylistEditor->Content->Swap(*it, (*it)+1);
@@ -835,21 +832,21 @@ int main(int argc, char *argv[])
myPlaylist->Main()->SetTimeout(50); myPlaylist->Main()->SetTimeout(50);
if (myPlaylist->Main()->hasSelected()) if (myPlaylist->Main()->hasSelected())
{ {
vector<size_t> list; std::vector<size_t> list;
myPlaylist->Main()->GetSelected(list); myPlaylist->Main()->GetSelected(list);
for (vector<size_t>::iterator it = list.begin(); it != list.end(); ++it) for (std::vector<size_t>::iterator it = list.begin(); it != list.end(); ++it)
if (*it == size_t(myPlaylist->NowPlaying) && list.back() < myPlaylist->Main()->Size()-1) if (*it == size_t(myPlaylist->NowPlaying) && list.back() < myPlaylist->Main()->Size()-1)
myPlaylist->Main()->BoldOption(myPlaylist->NowPlaying, 0); myPlaylist->Main()->BoldOption(myPlaylist->NowPlaying, 0);
vector<size_t> origs(list); std::vector<size_t> origs(list);
while (Keypressed(input, Key.MvSongDown) && list.back() < myPlaylist->Main()->Size()-1) while (Keypressed(input, Key.MvSongDown) && list.back() < myPlaylist->Main()->Size()-1)
{ {
TraceMpdStatus(); TraceMpdStatus();
Playlist::BlockUpdate = 1; Playlist::BlockUpdate = 1;
myPlaylist->UpdateTimer(); myPlaylist->UpdateTimer();
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); ++it) for (std::vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); ++it)
{ {
(*it)++; (*it)++;
myPlaylist->Main()->at((*it)-1).SetPosition(*it); myPlaylist->Main()->at((*it)-1).SetPosition(*it);
@@ -896,16 +893,16 @@ int main(int argc, char *argv[])
myPlaylistEditor->Content->SetTimeout(50); myPlaylistEditor->Content->SetTimeout(50);
if (myPlaylistEditor->Content->hasSelected()) if (myPlaylistEditor->Content->hasSelected())
{ {
vector<size_t> list; std::vector<size_t> list;
myPlaylistEditor->Content->GetSelected(list); myPlaylistEditor->Content->GetSelected(list);
vector<size_t> origs(list); std::vector<size_t> origs(list);
while (Keypressed(input, Key.MvSongDown) && list.back() < myPlaylistEditor->Content->Size()-1) while (Keypressed(input, Key.MvSongDown) && list.back() < myPlaylistEditor->Content->Size()-1)
{ {
TraceMpdStatus(); TraceMpdStatus();
myPlaylist->UpdateTimer(); myPlaylist->UpdateTimer();
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); ++it) for (std::vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); ++it)
{ {
(*it)++; (*it)++;
myPlaylistEditor->Content->Swap(*it, (*it)-1); myPlaylistEditor->Content->Swap(*it, (*it)-1);
@@ -953,7 +950,7 @@ int main(int argc, char *argv[])
// if cursor is at the last item, break convention and move at the end of playlist // if cursor is at the last item, break convention and move at the end of playlist
if (pos == myPlaylist->Main()->Size()-1) if (pos == myPlaylist->Main()->Size()-1)
pos++; pos++;
vector<size_t> list; std::vector<size_t> list;
myPlaylist->Main()->GetSelected(list); myPlaylist->Main()->GetSelected(list);
if (pos >= list.front() && pos <= list.back()) if (pos >= list.front() && pos <= list.back())
continue; continue;
@@ -963,7 +960,7 @@ int main(int argc, char *argv[])
{ {
pos -= list.size(); pos -= list.size();
size_t i = list.size()-1; size_t i = list.size()-1;
for (vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); ++it, --i) for (std::vector<size_t>::reverse_iterator it = list.rbegin(); it != list.rend(); ++it, --i)
{ {
Mpd.Move(*it, pos+i); Mpd.Move(*it, pos+i);
myPlaylist->Main()->Move(*it, pos+i); myPlaylist->Main()->Move(*it, pos+i);
@@ -972,7 +969,7 @@ int main(int argc, char *argv[])
else if (diff < 0) else if (diff < 0)
{ {
size_t i = 0; size_t i = 0;
for (vector<size_t>::const_iterator it = list.begin(); it != list.end(); ++it, ++i) for (std::vector<size_t>::const_iterator it = list.begin(); it != list.end(); ++it, ++i)
{ {
Mpd.Move(*it, pos+i); Mpd.Move(*it, pos+i);
myPlaylist->Main()->Move(*it, pos+i); myPlaylist->Main()->Move(*it, pos+i);
@@ -988,7 +985,7 @@ int main(int argc, char *argv[])
continue; continue;
LockStatusbar(); LockStatusbar();
Statusbar() << (myScreen == myPlaylistEditor ? "Add to playlist: " : "Add: "); Statusbar() << (myScreen == myPlaylistEditor ? "Add to playlist: " : "Add: ");
string path = wFooter->GetString(); std::string path = wFooter->GetString();
UnlockStatusbar(); UnlockStatusbar();
if (!path.empty()) if (!path.empty())
{ {
@@ -1076,7 +1073,7 @@ int main(int argc, char *argv[])
} }
wFooter->Bold(1); wFooter->Bold(1);
string tracklength = "[" + Song::ShowTime(songpos) + "/" + s->GetLength() + "]"; std::string tracklength = "[" + Song::ShowTime(songpos) + "/" + s->GetLength() + "]";
*wFooter << XY(wFooter->GetWidth()-tracklength.length(), 1) << tracklength; *wFooter << XY(wFooter->GetWidth()-tracklength.length(), 1) << tracklength;
double progressbar_size = songpos/double(s->GetTotalLength()); double progressbar_size = songpos/double(s->GetTotalLength());
int howlong = wFooter->GetWidth()*progressbar_size; int howlong = wFooter->GetWidth()*progressbar_size;
@@ -1227,7 +1224,7 @@ int main(int argc, char *argv[])
{ {
LockStatusbar(); LockStatusbar();
Statusbar() << "Set crossfade to: "; Statusbar() << "Set crossfade to: ";
string crossfade = wFooter->GetString(3); std::string crossfade = wFooter->GetString(3);
UnlockStatusbar(); UnlockStatusbar();
int cf = StrToInt(crossfade); int cf = StrToInt(crossfade);
if (cf > 0) if (cf > 0)
@@ -1250,7 +1247,7 @@ int main(int argc, char *argv[])
{ {
LockStatusbar(); LockStatusbar();
Statusbar() << fmtBold << IntoStr(Config.media_lib_primary_tag) << fmtBoldEnd << ": "; Statusbar() << fmtBold << IntoStr(Config.media_lib_primary_tag) << fmtBoldEnd << ": ";
string new_tag = wFooter->GetString(myLibrary->Artists->Current()); std::string new_tag = wFooter->GetString(myLibrary->Artists->Current());
UnlockStatusbar(); UnlockStatusbar();
if (!new_tag.empty() && new_tag != myLibrary->Artists->Current()) if (!new_tag.empty() && new_tag != myLibrary->Artists->Current())
{ {
@@ -1268,7 +1265,7 @@ int main(int argc, char *argv[])
(*it)->Localize(); (*it)->Localize();
((*it)->*set)(new_tag); ((*it)->*set)(new_tag);
ShowMessage("Updating tags in \"%s\"...", (*it)->GetName().c_str()); ShowMessage("Updating tags in \"%s\"...", (*it)->GetName().c_str());
string path = Config.mpd_music_dir + (*it)->GetFile(); std::string path = Config.mpd_music_dir + (*it)->GetFile();
if (!TagEditor::WriteTags(**it)) if (!TagEditor::WriteTags(**it))
{ {
ShowMessage("Error updating tags in \"%s\"!", (*it)->GetFile().c_str()); ShowMessage("Error updating tags in \"%s\"!", (*it)->GetFile().c_str());
@@ -1288,7 +1285,7 @@ int main(int argc, char *argv[])
{ {
LockStatusbar(); LockStatusbar();
Statusbar() << fmtBold << "Album: " << fmtBoldEnd; Statusbar() << fmtBold << "Album: " << fmtBoldEnd;
string new_album = wFooter->GetString(myLibrary->Albums->Current().second.Album); std::string new_album = wFooter->GetString(myLibrary->Albums->Current().second.Album);
UnlockStatusbar(); UnlockStatusbar();
if (!new_album.empty() && new_album != myLibrary->Albums->Current().second.Album) if (!new_album.empty() && new_album != myLibrary->Albums->Current().second.Album)
{ {
@@ -1298,7 +1295,7 @@ int main(int argc, char *argv[])
{ {
(*myLibrary->Songs)[i].Localize(); (*myLibrary->Songs)[i].Localize();
ShowMessage("Updating tags in \"%s\"...", (*myLibrary->Songs)[i].GetName().c_str()); ShowMessage("Updating tags in \"%s\"...", (*myLibrary->Songs)[i].GetName().c_str());
string path = Config.mpd_music_dir + (*myLibrary->Songs)[i].GetFile(); std::string path = Config.mpd_music_dir + (*myLibrary->Songs)[i].GetFile();
TagLib::FileRef f(locale_to_utf_cpy(path).c_str()); TagLib::FileRef f(locale_to_utf_cpy(path).c_str());
if (f.isNull()) if (f.isNull())
{ {
@@ -1323,15 +1320,15 @@ int main(int argc, char *argv[])
} }
else if (myScreen->ActiveWindow() == myTagEditor->Dirs) else if (myScreen->ActiveWindow() == myTagEditor->Dirs)
{ {
string old_dir = myTagEditor->Dirs->Current().first; std::string old_dir = myTagEditor->Dirs->Current().first;
LockStatusbar(); LockStatusbar();
Statusbar() << fmtBold << "Directory: " << fmtBoldEnd; Statusbar() << fmtBold << "Directory: " << fmtBoldEnd;
string new_dir = wFooter->GetString(old_dir); std::string new_dir = wFooter->GetString(old_dir);
UnlockStatusbar(); UnlockStatusbar();
if (!new_dir.empty() && new_dir != old_dir) if (!new_dir.empty() && new_dir != old_dir)
{ {
string full_old_dir = Config.mpd_music_dir + myTagEditor->CurrentDir() + "/" + locale_to_utf_cpy(old_dir); std::string full_old_dir = Config.mpd_music_dir + myTagEditor->CurrentDir() + "/" + locale_to_utf_cpy(old_dir);
string full_new_dir = Config.mpd_music_dir + myTagEditor->CurrentDir() + "/" + locale_to_utf_cpy(new_dir); std::string full_new_dir = Config.mpd_music_dir + myTagEditor->CurrentDir() + "/" + locale_to_utf_cpy(new_dir);
if (rename(full_old_dir.c_str(), full_new_dir.c_str()) == 0) if (rename(full_old_dir.c_str(), full_new_dir.c_str()) == 0)
{ {
Mpd.UpdateDirectory(myTagEditor->CurrentDir()); Mpd.UpdateDirectory(myTagEditor->CurrentDir());
@@ -1350,18 +1347,18 @@ int main(int argc, char *argv[])
} }
if (myScreen == myBrowser && myBrowser->Main()->Current().type == itDirectory) if (myScreen == myBrowser && myBrowser->Main()->Current().type == itDirectory)
{ {
string old_dir = myBrowser->Main()->Current().name; std::string old_dir = myBrowser->Main()->Current().name;
LockStatusbar(); LockStatusbar();
Statusbar() << fmtBold << "Directory: " << fmtBoldEnd; Statusbar() << fmtBold << "Directory: " << fmtBoldEnd;
string new_dir = wFooter->GetString(old_dir); std::string new_dir = wFooter->GetString(old_dir);
UnlockStatusbar(); UnlockStatusbar();
if (!new_dir.empty() && new_dir != old_dir) if (!new_dir.empty() && new_dir != old_dir)
{ {
string full_old_dir; std::string full_old_dir;
if (!Config.local_browser) if (!Config.local_browser)
full_old_dir += Config.mpd_music_dir; full_old_dir += Config.mpd_music_dir;
full_old_dir += locale_to_utf_cpy(old_dir); full_old_dir += locale_to_utf_cpy(old_dir);
string full_new_dir; std::string full_new_dir;
if (!Config.local_browser) if (!Config.local_browser)
full_new_dir += Config.mpd_music_dir; full_new_dir += Config.mpd_music_dir;
full_new_dir += locale_to_utf_cpy(new_dir); full_new_dir += locale_to_utf_cpy(new_dir);
@@ -1379,10 +1376,10 @@ int main(int argc, char *argv[])
} }
else if (myScreen->ActiveWindow() == myPlaylistEditor->Playlists || (myScreen == myBrowser && myBrowser->Main()->Current().type == itPlaylist)) else if (myScreen->ActiveWindow() == myPlaylistEditor->Playlists || (myScreen == myBrowser && myBrowser->Main()->Current().type == itPlaylist))
{ {
string old_name = myScreen->ActiveWindow() == myPlaylistEditor->Playlists ? myPlaylistEditor->Playlists->Current() : myBrowser->Main()->Current().name; std::string old_name = myScreen->ActiveWindow() == myPlaylistEditor->Playlists ? myPlaylistEditor->Playlists->Current() : myBrowser->Main()->Current().name;
LockStatusbar(); LockStatusbar();
Statusbar() << fmtBold << "Playlist: " << fmtBoldEnd; Statusbar() << fmtBold << "Playlist: " << fmtBoldEnd;
string new_name = wFooter->GetString(old_name); std::string new_name = wFooter->GetString(old_name);
UnlockStatusbar(); UnlockStatusbar();
if (!new_name.empty() && new_name != old_name) if (!new_name.empty() && new_name != old_name)
{ {
@@ -1414,14 +1411,14 @@ int main(int argc, char *argv[])
} }
LockStatusbar(); LockStatusbar();
Statusbar() << "Position to go (in %/mm:ss/seconds(s)): "; Statusbar() << "Position to go (in %/mm:ss/seconds(s)): ";
string position = wFooter->GetString(); std::string position = wFooter->GetString();
UnlockStatusbar(); UnlockStatusbar();
if (position.empty()) if (position.empty())
continue; continue;
int newpos = 0; int newpos = 0;
if (position.find(':') != string::npos) // probably time in mm:ss if (position.find(':') != std::string::npos) // probably time in mm:ss
{ {
try try
{ {
@@ -1433,7 +1430,7 @@ int main(int argc, char *argv[])
else else
ShowMessage("Out of bounds, 0:00-%s possible for mm:ss, %d given.", s->GetLength().c_str(), newpos); ShowMessage("Out of bounds, 0:00-%s possible for mm:ss, %d given.", s->GetLength().c_str(), newpos);
} }
else if (position.find('s') != string::npos) // probably position in seconds else if (position.find('s') != std::string::npos) // probably position in seconds
{ {
newpos = StrToInt(position); newpos = StrToInt(position);
if (newpos > 0 && newpos < s->GetTotalLength()) if (newpos > 0 && newpos < s->GetTotalLength())
@@ -1486,7 +1483,7 @@ int main(int argc, char *argv[])
const size_t dialog_width = COLS*0.8; const size_t dialog_width = COLS*0.8;
const size_t dialog_height = LINES*0.6; const size_t dialog_height = LINES*0.6;
Menu<string> mDialog((COLS-dialog_width)/2, (LINES-dialog_height)/2, dialog_width, dialog_height, "Add selected items to...", Config.main_color, Config.window_border); Menu<std::string> mDialog((COLS-dialog_width)/2, (LINES-dialog_height)/2, dialog_width, dialog_height, "Add selected items to...", Config.main_color, Config.window_border);
mDialog.SetTimeout(ncmpcpp_window_timeout); mDialog.SetTimeout(ncmpcpp_window_timeout);
mDialog.CyclicScrolling(Config.use_cyclic_scrolling); mDialog.CyclicScrolling(Config.use_cyclic_scrolling);
mDialog.SetItemDisplayer(Display::Generic); mDialog.SetItemDisplayer(Display::Generic);
@@ -1560,8 +1557,8 @@ int main(int argc, char *argv[])
{ {
LockStatusbar(); LockStatusbar();
Statusbar() << "Save playlist as: "; Statusbar() << "Save playlist as: ";
string playlist = wFooter->GetString(); std::string playlist = wFooter->GetString();
string real_playlist = playlist; std::string real_playlist = playlist;
locale_to_utf(real_playlist); locale_to_utf(real_playlist);
UnlockStatusbar(); UnlockStatusbar();
if (!playlist.empty()) if (!playlist.empty())
@@ -1575,7 +1572,7 @@ int main(int argc, char *argv[])
} }
else if (id > 1 && id < mDialog.Size()-1) else if (id > 1 && id < mDialog.Size()-1)
{ {
string playlist = locale_to_utf_cpy(mDialog.Current()); std::string playlist = locale_to_utf_cpy(mDialog.Current());
Mpd.StartCommandsList(); Mpd.StartCommandsList();
for (SongList::const_iterator it = result.begin(); it != result.end(); ++it) for (SongList::const_iterator it = result.begin(); it != result.end(); ++it)
Mpd.AddToPlaylist(playlist, **it); Mpd.AddToPlaylist(playlist, **it);
@@ -1722,7 +1719,7 @@ int main(int argc, char *argv[])
{ {
LockStatusbar(); LockStatusbar();
Statusbar() << "Find " << (Keypressed(input, Key.FindForward) ? "forward" : "backward") << ": "; Statusbar() << "Find " << (Keypressed(input, Key.FindForward) ? "forward" : "backward") << ": ";
string findme = wFooter->GetString(); std::string findme = wFooter->GetString();
UnlockStatusbar(); UnlockStatusbar();
myPlaylist->UpdateTimer(); myPlaylist->UpdateTimer();
@@ -1748,7 +1745,7 @@ int main(int argc, char *argv[])
{ {
LockStatusbar(); LockStatusbar();
Statusbar() << "Find: "; Statusbar() << "Find: ";
string findme = wFooter->GetString(); std::string findme = wFooter->GetString();
UnlockStatusbar(); UnlockStatusbar();
ShowMessage("Searching..."); ShowMessage("Searching...");
@@ -1825,7 +1822,7 @@ int main(int argc, char *argv[])
if (new_tagitem != Config.media_lib_primary_tag) if (new_tagitem != Config.media_lib_primary_tag)
{ {
Config.media_lib_primary_tag = new_tagitem; Config.media_lib_primary_tag = new_tagitem;
string item_type = IntoStr(Config.media_lib_primary_tag); std::string item_type = IntoStr(Config.media_lib_primary_tag);
myLibrary->Artists->SetTitle(item_type + "s"); myLibrary->Artists->SetTitle(item_type + "s");
myLibrary->Artists->Reset(); myLibrary->Artists->Reset();
ToLower(item_type); ToLower(item_type);

View File

@@ -29,7 +29,6 @@
#include "status.h" #include "status.h"
using namespace Global; using namespace Global;
using std::vector;
Playlist *myPlaylist = new Playlist; Playlist *myPlaylist = new Playlist;
@@ -162,9 +161,9 @@ MPD::Song *Playlist::CurrentSong()
void Playlist::GetSelectedSongs(MPD::SongList &v) void Playlist::GetSelectedSongs(MPD::SongList &v)
{ {
vector<size_t> selected; std::vector<size_t> selected;
w->GetSelected(selected); w->GetSelected(selected);
for (vector<size_t>::const_iterator it = selected.begin(); it != selected.end(); ++it) for (std::vector<size_t>::const_iterator it = selected.begin(); it != selected.end(); ++it)
{ {
v.push_back(new MPD::Song(w->at(*it))); v.push_back(new MPD::Song(w->at(*it)));
} }

View File

@@ -32,7 +32,6 @@
using namespace Global; using namespace Global;
using namespace MPD; using namespace MPD;
using std::string;
PlaylistEditor *myPlaylistEditor = new PlaylistEditor; PlaylistEditor *myPlaylistEditor = new PlaylistEditor;
@@ -46,7 +45,7 @@ void PlaylistEditor::Init()
RightColumnStartX = LeftColumnWidth+1; RightColumnStartX = LeftColumnWidth+1;
RightColumnWidth = COLS-LeftColumnWidth-1; RightColumnWidth = COLS-LeftColumnWidth-1;
Playlists = new Menu<string>(0, MainStartY, LeftColumnWidth, MainHeight, "Playlists", Config.main_color, brNone); Playlists = new Menu<std::string>(0, MainStartY, LeftColumnWidth, MainHeight, "Playlists", Config.main_color, brNone);
Playlists->HighlightColor(Config.active_column_color); Playlists->HighlightColor(Config.active_column_color);
Playlists->SetTimeout(ncmpcpp_window_timeout); Playlists->SetTimeout(ncmpcpp_window_timeout);
Playlists->CyclicScrolling(Config.use_cyclic_scrolling); Playlists->CyclicScrolling(Config.use_cyclic_scrolling);

View File

@@ -21,13 +21,12 @@
#include "scrollpad.h" #include "scrollpad.h"
using namespace NCurses; using namespace NCurses;
using std::string;
Scrollpad::Scrollpad(size_t startx, Scrollpad::Scrollpad(size_t startx,
size_t starty, size_t starty,
size_t width, size_t width,
size_t height, size_t height,
const string &title, const std::string &title,
Color color, Color color,
Border border) Border border)
: Window(startx, starty, width, height, title, color, border), : Window(startx, starty, width, height, title, color, border),

View File

@@ -28,7 +28,6 @@
using namespace MPD; using namespace MPD;
using namespace Global; using namespace Global;
using std::string;
SearchEngine *mySearcher = new SearchEngine; SearchEngine *mySearcher = new SearchEngine;
@@ -434,7 +433,7 @@ void SearchEngine::Search()
if (!CaseSensitive && !MatchToPattern) if (!CaseSensitive && !MatchToPattern)
{ {
string t; std::string t;
t = s.Any(); t = s.Any();
ToLower(t); ToLower(t);
s.Any(t); s.Any(t);
@@ -479,7 +478,7 @@ void SearchEngine::Search()
if (!CaseSensitive && !MatchToPattern) if (!CaseSensitive && !MatchToPattern)
{ {
string t; std::string t;
t = copy.GetArtist(); t = copy.GetArtist();
ToLower(t); ToLower(t);
copy.SetArtist(t); copy.SetArtist(t);

View File

@@ -28,18 +28,15 @@
#include "helpers.h" #include "helpers.h"
#include "settings.h" #include "settings.h"
using std::ifstream; const std::string config_file = config_dir + "config";
using std::string; const std::string keys_config_file = config_dir + "keys";
const string config_file = config_dir + "config";
const string keys_config_file = config_dir + "keys";
ncmpcpp_config Config; ncmpcpp_config Config;
ncmpcpp_keys Key; ncmpcpp_keys Key;
namespace namespace
{ {
void GetKeys(string &line, int *key) void GetKeys(std::string &line, int *key)
{ {
size_t i = line.find("=")+1; size_t i = line.find("=")+1;
line = line.substr(i, line.length()-i); line = line.substr(i, line.length()-i);
@@ -48,9 +45,9 @@ namespace
while (line[++i] == ' ') { } while (line[++i] == ' ') { }
line = line.substr(i, line.length()-i); line = line.substr(i, line.length()-i);
i = line.find(" "); i = line.find(" ");
string one; std::string one;
string two; std::string two;
if (i != string::npos) if (i != std::string::npos)
{ {
one = line.substr(0, i); one = line.substr(0, i);
i++; i++;
@@ -62,9 +59,9 @@ namespace
key[1] = !two.empty() && two[0] == '\'' ? two[1] : (atoi(two.c_str()) == 0 ? null_key : atoi(two.c_str())); key[1] = !two.empty() && two[0] == '\'' ? two[1] : (atoi(two.c_str()) == 0 ? null_key : atoi(two.c_str()));
} }
void String2Buffer(const string &s, Buffer &buf) void String2Buffer(const std::string &s, Buffer &buf)
{ {
for (string::const_iterator it = s.begin(); it != s.end(); ++it) for (std::string::const_iterator it = s.begin(); it != s.end(); ++it)
{ {
if (*it != '$') if (*it != '$')
buf << *it; buf << *it;
@@ -73,7 +70,7 @@ namespace
} }
} }
Border IntoBorder(const string &color) Border IntoBorder(const std::string &color)
{ {
return Border(IntoColor(color)); return Border(IntoColor(color));
} }
@@ -299,8 +296,8 @@ void DefaultConfiguration(ncmpcpp_config &conf)
void ReadKeys(ncmpcpp_keys &keys) void ReadKeys(ncmpcpp_keys &keys)
{ {
ifstream f(keys_config_file.c_str()); std::ifstream f(keys_config_file.c_str());
string key; std::string key;
if (!f.is_open()) if (!f.is_open())
return; return;
@@ -310,141 +307,141 @@ void ReadKeys(ncmpcpp_keys &keys)
getline(f, key); getline(f, key);
if (!key.empty() && key[0] != '#') if (!key.empty() && key[0] != '#')
{ {
if (key.find("key_up ") != string::npos) if (key.find("key_up ") != std::string::npos)
GetKeys(key, keys.Up); GetKeys(key, keys.Up);
else if (key.find("key_down ") != string::npos) else if (key.find("key_down ") != std::string::npos)
GetKeys(key, keys.Down); GetKeys(key, keys.Down);
else if (key.find("key_page_up ") != string::npos) else if (key.find("key_page_up ") != std::string::npos)
GetKeys(key, keys.PageUp); GetKeys(key, keys.PageUp);
else if (key.find("key_page_down ") != string::npos) else if (key.find("key_page_down ") != std::string::npos)
GetKeys(key, keys.PageDown); GetKeys(key, keys.PageDown);
else if (key.find("key_home ") != string::npos) else if (key.find("key_home ") != std::string::npos)
GetKeys(key, keys.Home); GetKeys(key, keys.Home);
else if (key.find("key_end ") != string::npos) else if (key.find("key_end ") != std::string::npos)
GetKeys(key, keys.End); GetKeys(key, keys.End);
else if (key.find("key_space ") != string::npos) else if (key.find("key_space ") != std::string::npos)
GetKeys(key, keys.Space); GetKeys(key, keys.Space);
else if (key.find("key_enter ") != string::npos) else if (key.find("key_enter ") != std::string::npos)
GetKeys(key, keys.Enter); GetKeys(key, keys.Enter);
else if (key.find("key_delete ") != string::npos) else if (key.find("key_delete ") != std::string::npos)
GetKeys(key, keys.Delete); GetKeys(key, keys.Delete);
else if (key.find("key_volume_up ") != string::npos) else if (key.find("key_volume_up ") != std::string::npos)
GetKeys(key, keys.VolumeUp); GetKeys(key, keys.VolumeUp);
else if (key.find("key_volume_down ") != string::npos) else if (key.find("key_volume_down ") != std::string::npos)
GetKeys(key, keys.VolumeDown); GetKeys(key, keys.VolumeDown);
else if (key.find("key_screen_switcher ") != string::npos) else if (key.find("key_screen_switcher ") != std::string::npos)
GetKeys(key, keys.ScreenSwitcher); GetKeys(key, keys.ScreenSwitcher);
else if (key.find("key_help ") != string::npos) else if (key.find("key_help ") != std::string::npos)
GetKeys(key, keys.Help); GetKeys(key, keys.Help);
else if (key.find("key_playlist ") != string::npos) else if (key.find("key_playlist ") != std::string::npos)
GetKeys(key, keys.Playlist); GetKeys(key, keys.Playlist);
else if (key.find("key_browser ") != string::npos) else if (key.find("key_browser ") != std::string::npos)
GetKeys(key, keys.Browser); GetKeys(key, keys.Browser);
else if (key.find("key_search_engine ") != string::npos) else if (key.find("key_search_engine ") != std::string::npos)
GetKeys(key, keys.SearchEngine); GetKeys(key, keys.SearchEngine);
else if (key.find("key_media_library ") != string::npos) else if (key.find("key_media_library ") != std::string::npos)
GetKeys(key, keys.MediaLibrary); GetKeys(key, keys.MediaLibrary);
else if (key.find("key_playlist_editor ") != string::npos) else if (key.find("key_playlist_editor ") != std::string::npos)
GetKeys(key, keys.PlaylistEditor); GetKeys(key, keys.PlaylistEditor);
else if (key.find("key_tag_editor ") != string::npos) else if (key.find("key_tag_editor ") != std::string::npos)
GetKeys(key, keys.TagEditor); GetKeys(key, keys.TagEditor);
else if (key.find("key_outputs ") != string::npos) else if (key.find("key_outputs ") != std::string::npos)
GetKeys(key, keys.Outputs); GetKeys(key, keys.Outputs);
else if (key.find("key_clock ") != string::npos) else if (key.find("key_clock ") != std::string::npos)
GetKeys(key, keys.Clock); GetKeys(key, keys.Clock);
else if (key.find("key_stop ") != string::npos) else if (key.find("key_stop ") != std::string::npos)
GetKeys(key, keys.Stop); GetKeys(key, keys.Stop);
else if (key.find("key_pause ") != string::npos) else if (key.find("key_pause ") != std::string::npos)
GetKeys(key, keys.Pause); GetKeys(key, keys.Pause);
else if (key.find("key_next ") != string::npos) else if (key.find("key_next ") != std::string::npos)
GetKeys(key, keys.Next); GetKeys(key, keys.Next);
else if (key.find("key_prev ") != string::npos) else if (key.find("key_prev ") != std::string::npos)
GetKeys(key, keys.Prev); GetKeys(key, keys.Prev);
else if (key.find("key_seek_forward ") != string::npos) else if (key.find("key_seek_forward ") != std::string::npos)
GetKeys(key, keys.SeekForward); GetKeys(key, keys.SeekForward);
else if (key.find("key_seek_backward ") != string::npos) else if (key.find("key_seek_backward ") != std::string::npos)
GetKeys(key, keys.SeekBackward); GetKeys(key, keys.SeekBackward);
else if (key.find("key_toggle_repeat ") != string::npos) else if (key.find("key_toggle_repeat ") != std::string::npos)
GetKeys(key, keys.ToggleRepeat); GetKeys(key, keys.ToggleRepeat);
else if (key.find("key_toggle_random ") != string::npos) else if (key.find("key_toggle_random ") != std::string::npos)
GetKeys(key, keys.ToggleRandom); GetKeys(key, keys.ToggleRandom);
else if (key.find("key_toggle_single ") != string::npos) else if (key.find("key_toggle_single ") != std::string::npos)
GetKeys(key, keys.ToggleSingle); GetKeys(key, keys.ToggleSingle);
else if (key.find("key_toggle_consume ") != string::npos) else if (key.find("key_toggle_consume ") != std::string::npos)
GetKeys(key, keys.ToggleConsume); GetKeys(key, keys.ToggleConsume);
else if (key.find("key_toggle_space_mode ") != string::npos) else if (key.find("key_toggle_space_mode ") != std::string::npos)
GetKeys(key, keys.ToggleSpaceMode); GetKeys(key, keys.ToggleSpaceMode);
else if (key.find("key_toggle_add_mode ") != string::npos) else if (key.find("key_toggle_add_mode ") != std::string::npos)
GetKeys(key, keys.ToggleAddMode); GetKeys(key, keys.ToggleAddMode);
else if (key.find("key_toggle_mouse ") != string::npos) else if (key.find("key_toggle_mouse ") != std::string::npos)
GetKeys(key, keys.ToggleMouse); GetKeys(key, keys.ToggleMouse);
else if (key.find("key_shuffle ") != string::npos) else if (key.find("key_shuffle ") != std::string::npos)
GetKeys(key, keys.Shuffle); GetKeys(key, keys.Shuffle);
else if (key.find("key_toggle_crossfade ") != string::npos) else if (key.find("key_toggle_crossfade ") != std::string::npos)
GetKeys(key, keys.ToggleCrossfade); GetKeys(key, keys.ToggleCrossfade);
else if (key.find("key_set_crossfade ") != string::npos) else if (key.find("key_set_crossfade ") != std::string::npos)
GetKeys(key, keys.SetCrossfade); GetKeys(key, keys.SetCrossfade);
else if (key.find("key_update_db ") != string::npos) else if (key.find("key_update_db ") != std::string::npos)
GetKeys(key, keys.UpdateDB); GetKeys(key, keys.UpdateDB);
else if (key.find("key_sort_playlist ") != string::npos) else if (key.find("key_sort_playlist ") != std::string::npos)
GetKeys(key, keys.SortPlaylist); GetKeys(key, keys.SortPlaylist);
else if (key.find("key_apply_filter ") != string::npos) else if (key.find("key_apply_filter ") != std::string::npos)
GetKeys(key, keys.ApplyFilter); GetKeys(key, keys.ApplyFilter);
else if (key.find("key_find_forward ") != string::npos) else if (key.find("key_find_forward ") != std::string::npos)
GetKeys(key, keys.FindForward); GetKeys(key, keys.FindForward);
else if (key.find("key_find_backward ") != string::npos) else if (key.find("key_find_backward ") != std::string::npos)
GetKeys(key, keys.FindBackward); GetKeys(key, keys.FindBackward);
else if (key.find("key_next_found_position ") != string::npos) else if (key.find("key_next_found_position ") != std::string::npos)
GetKeys(key, keys.NextFoundPosition); GetKeys(key, keys.NextFoundPosition);
else if (key.find("key_prev_found_position ") != string::npos) else if (key.find("key_prev_found_position ") != std::string::npos)
GetKeys(key, keys.PrevFoundPosition); GetKeys(key, keys.PrevFoundPosition);
else if (key.find("key_toggle_find_mode ") != string::npos) else if (key.find("key_toggle_find_mode ") != std::string::npos)
GetKeys(key, keys.ToggleFindMode); GetKeys(key, keys.ToggleFindMode);
else if (key.find("key_edit_tags ") != string::npos) else if (key.find("key_edit_tags ") != std::string::npos)
GetKeys(key, keys.EditTags); GetKeys(key, keys.EditTags);
else if (key.find("key_go_to_position ") != string::npos) else if (key.find("key_go_to_position ") != std::string::npos)
GetKeys(key, keys.GoToPosition); GetKeys(key, keys.GoToPosition);
else if (key.find("key_song_info ") != string::npos) else if (key.find("key_song_info ") != std::string::npos)
GetKeys(key, keys.SongInfo); GetKeys(key, keys.SongInfo);
else if (key.find("key_artist_info ") != string::npos) else if (key.find("key_artist_info ") != std::string::npos)
GetKeys(key, keys.ArtistInfo); GetKeys(key, keys.ArtistInfo);
else if (key.find("key_lyrics ") != string::npos) else if (key.find("key_lyrics ") != std::string::npos)
GetKeys(key, keys.Lyrics); GetKeys(key, keys.Lyrics);
else if (key.find("key_reverse_selection ") != string::npos) else if (key.find("key_reverse_selection ") != std::string::npos)
GetKeys(key, keys.ReverseSelection); GetKeys(key, keys.ReverseSelection);
else if (key.find("key_deselect_all ") != string::npos) else if (key.find("key_deselect_all ") != std::string::npos)
GetKeys(key, keys.DeselectAll); GetKeys(key, keys.DeselectAll);
else if (key.find("key_add_selected_items ") != string::npos) else if (key.find("key_add_selected_items ") != std::string::npos)
GetKeys(key, keys.AddSelected); GetKeys(key, keys.AddSelected);
else if (key.find("key_clear ") != string::npos) else if (key.find("key_clear ") != std::string::npos)
GetKeys(key, keys.Clear); GetKeys(key, keys.Clear);
else if (key.find("key_crop ") != string::npos) else if (key.find("key_crop ") != std::string::npos)
GetKeys(key, keys.Crop); GetKeys(key, keys.Crop);
else if (key.find("key_move_song_up ") != string::npos) else if (key.find("key_move_song_up ") != std::string::npos)
GetKeys(key, keys.MvSongUp); GetKeys(key, keys.MvSongUp);
else if (key.find("key_move_song_down ") != string::npos) else if (key.find("key_move_song_down ") != std::string::npos)
GetKeys(key, keys.MvSongDown); GetKeys(key, keys.MvSongDown);
else if (key.find("key_move_to ") != string::npos) else if (key.find("key_move_to ") != std::string::npos)
GetKeys(key, keys.MoveTo); GetKeys(key, keys.MoveTo);
else if (key.find("key_add ") != string::npos) else if (key.find("key_add ") != std::string::npos)
GetKeys(key, keys.Add); GetKeys(key, keys.Add);
else if (key.find("key_save_playlist ") != string::npos) else if (key.find("key_save_playlist ") != std::string::npos)
GetKeys(key, keys.SavePlaylist); GetKeys(key, keys.SavePlaylist);
else if (key.find("key_go_to_now_playing ") != string::npos) else if (key.find("key_go_to_now_playing ") != std::string::npos)
GetKeys(key, keys.GoToNowPlaying); GetKeys(key, keys.GoToNowPlaying);
else if (key.find("key_toggle_auto_center ") != string::npos) else if (key.find("key_toggle_auto_center ") != std::string::npos)
GetKeys(key, keys.ToggleAutoCenter); GetKeys(key, keys.ToggleAutoCenter);
else if (key.find("key_toggle_display_mode ") != string::npos) else if (key.find("key_toggle_display_mode ") != std::string::npos)
GetKeys(key, keys.ToggleDisplayMode); GetKeys(key, keys.ToggleDisplayMode);
else if (key.find("key_toggle_lyrics_db ") != string::npos) else if (key.find("key_toggle_lyrics_db ") != std::string::npos)
GetKeys(key, keys.ToggleLyricsDB); GetKeys(key, keys.ToggleLyricsDB);
else if (key.find("key_go_to_containing_directory ") != string::npos) else if (key.find("key_go_to_containing_directory ") != std::string::npos)
GetKeys(key, keys.GoToContainingDir); GetKeys(key, keys.GoToContainingDir);
else if (key.find("key_go_to_parent_dir ") != string::npos) else if (key.find("key_go_to_parent_dir ") != std::string::npos)
GetKeys(key, keys.GoToParentDir); GetKeys(key, keys.GoToParentDir);
else if (key.find("key_switch_tag_type_list ") != string::npos) else if (key.find("key_switch_tag_type_list ") != std::string::npos)
GetKeys(key, keys.SwitchTagTypeList); GetKeys(key, keys.SwitchTagTypeList);
else if (key.find("key_quit ") != string::npos) else if (key.find("key_quit ") != std::string::npos)
GetKeys(key, keys.Quit); GetKeys(key, keys.Quit);
} }
} }
@@ -453,8 +450,8 @@ void ReadKeys(ncmpcpp_keys &keys)
void ReadConfiguration(ncmpcpp_config &conf) void ReadConfiguration(ncmpcpp_config &conf)
{ {
ifstream f(config_file.c_str()); std::ifstream f(config_file.c_str());
string cl, v; std::string cl, v;
if (!f.is_open()) if (!f.is_open())
return; return;
@@ -465,12 +462,12 @@ void ReadConfiguration(ncmpcpp_config &conf)
if (!cl.empty() && cl[0] != '#') if (!cl.empty() && cl[0] != '#')
{ {
v = GetLineValue(cl); v = GetLineValue(cl);
if (cl.find("mpd_host") != string::npos) if (cl.find("mpd_host") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.mpd_host = v; conf.mpd_host = v;
} }
else if (cl.find("mpd_music_dir") != string::npos) else if (cl.find("mpd_music_dir") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
{ {
@@ -480,77 +477,77 @@ void ReadConfiguration(ncmpcpp_config &conf)
conf.mpd_music_dir = v + "/"; conf.mpd_music_dir = v + "/";
} }
} }
else if (cl.find("mpd_port") != string::npos) else if (cl.find("mpd_port") != std::string::npos)
{ {
if (StrToInt(v)) if (StrToInt(v))
conf.mpd_port = StrToInt(v); conf.mpd_port = StrToInt(v);
} }
else if (cl.find("mpd_connection_timeout") != string::npos) else if (cl.find("mpd_connection_timeout") != std::string::npos)
{ {
if (StrToInt(v)) if (StrToInt(v))
conf.mpd_connection_timeout = StrToInt(v); conf.mpd_connection_timeout = StrToInt(v);
} }
else if (cl.find("mpd_crossfade_time") != string::npos) else if (cl.find("mpd_crossfade_time") != std::string::npos)
{ {
if (StrToInt(v) > 0) if (StrToInt(v) > 0)
conf.crossfade_time = StrToInt(v); conf.crossfade_time = StrToInt(v);
} }
else if (cl.find("seek_time") != string::npos) else if (cl.find("seek_time") != std::string::npos)
{ {
if (StrToInt(v) > 0) if (StrToInt(v) > 0)
conf.seek_time = StrToInt(v); conf.seek_time = StrToInt(v);
} }
else if (cl.find("playlist_disable_highlight_delay") != string::npos) else if (cl.find("playlist_disable_highlight_delay") != std::string::npos)
{ {
if (StrToInt(v) >= 0) if (StrToInt(v) >= 0)
conf.playlist_disable_highlight_delay = StrToInt(v); conf.playlist_disable_highlight_delay = StrToInt(v);
} }
else if (cl.find("message_delay_time") != string::npos) else if (cl.find("message_delay_time") != std::string::npos)
{ {
if (StrToInt(v) > 0) if (StrToInt(v) > 0)
conf.message_delay_time = StrToInt(v); conf.message_delay_time = StrToInt(v);
} }
else if (cl.find("song_list_format") != string::npos) else if (cl.find("song_list_format") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.song_list_format = v; conf.song_list_format = v;
} }
else if (cl.find("song_columns_list_format") != string::npos) else if (cl.find("song_columns_list_format") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.song_columns_list_format = v; conf.song_columns_list_format = v;
} }
else if (cl.find("song_status_format") != string::npos) else if (cl.find("song_status_format") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.song_status_format = v; conf.song_status_format = v;
} }
else if (cl.find("song_library_format") != string::npos) else if (cl.find("song_library_format") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.song_library_format = v; conf.song_library_format = v;
} }
else if (cl.find("tag_editor_album_format") != string::npos) else if (cl.find("tag_editor_album_format") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.tag_editor_album_format = v; conf.tag_editor_album_format = v;
} }
else if (cl.find("external_editor") != string::npos) else if (cl.find("external_editor") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.external_editor = v; conf.external_editor = v;
} }
else if (cl.find("system_encoding") != string::npos) else if (cl.find("system_encoding") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.system_encoding = v + "//TRANSLIT"; conf.system_encoding = v + "//TRANSLIT";
} }
else if (cl.find("execute_on_song_change") != string::npos) else if (cl.find("execute_on_song_change") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.execute_on_song_change = v; conf.execute_on_song_change = v;
} }
else if (cl.find("browser_playlist_prefix") != string::npos) else if (cl.find("browser_playlist_prefix") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
{ {
@@ -558,12 +555,12 @@ void ReadConfiguration(ncmpcpp_config &conf)
String2Buffer(v, conf.browser_playlist_prefix); String2Buffer(v, conf.browser_playlist_prefix);
} }
} }
else if (cl.find("default_tag_editor_pattern") != string::npos) else if (cl.find("default_tag_editor_pattern") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.pattern = v; conf.pattern = v;
} }
else if (cl.find("selected_item_prefix") != string::npos) else if (cl.find("selected_item_prefix") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
{ {
@@ -571,7 +568,7 @@ void ReadConfiguration(ncmpcpp_config &conf)
String2Buffer(v, conf.selected_item_prefix); String2Buffer(v, conf.selected_item_prefix);
} }
} }
else if (cl.find("selected_item_suffix") != string::npos) else if (cl.find("selected_item_suffix") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
{ {
@@ -579,203 +576,203 @@ void ReadConfiguration(ncmpcpp_config &conf)
String2Buffer(v, conf.selected_item_suffix); String2Buffer(v, conf.selected_item_suffix);
} }
} }
else if (cl.find("color1") != string::npos) else if (cl.find("color1") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.color1 = IntoColor(v); conf.color1 = IntoColor(v);
} }
else if (cl.find("color2") != string::npos) else if (cl.find("color2") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.color2 = IntoColor(v); conf.color2 = IntoColor(v);
} }
else if (cl.find("colors_enabled") != string::npos) else if (cl.find("colors_enabled") != std::string::npos)
{ {
conf.colors_enabled = v == "yes"; conf.colors_enabled = v == "yes";
} }
else if (cl.find("fancy_scrolling") != string::npos) else if (cl.find("fancy_scrolling") != std::string::npos)
{ {
conf.fancy_scrolling = v == "yes"; conf.fancy_scrolling = v == "yes";
} }
else if (cl.find("cyclic_scrolling") != string::npos) else if (cl.find("cyclic_scrolling") != std::string::npos)
{ {
conf.use_cyclic_scrolling = v == "yes"; conf.use_cyclic_scrolling = v == "yes";
} }
else if (cl.find("playlist_show_remaining_time") != string::npos) else if (cl.find("playlist_show_remaining_time") != std::string::npos)
{ {
conf.playlist_show_remaining_time = v == "yes"; conf.playlist_show_remaining_time = v == "yes";
} }
else if (cl.find("playlist_display_mode") != string::npos) else if (cl.find("playlist_display_mode") != std::string::npos)
{ {
conf.columns_in_playlist = v == "columns"; conf.columns_in_playlist = v == "columns";
} }
else if (cl.find("browser_display_mode") != string::npos) else if (cl.find("browser_display_mode") != std::string::npos)
{ {
conf.columns_in_browser = v == "columns"; conf.columns_in_browser = v == "columns";
} }
else if (cl.find("search_engine_display_mode") != string::npos) else if (cl.find("search_engine_display_mode") != std::string::npos)
{ {
conf.columns_in_search_engine = v == "columns"; conf.columns_in_search_engine = v == "columns";
} }
else if (cl.find("header_visibility") != string::npos) else if (cl.find("header_visibility") != std::string::npos)
{ {
conf.header_visibility = v == "yes"; conf.header_visibility = v == "yes";
} }
else if (cl.find("header_text_scrolling") != string::npos) else if (cl.find("header_text_scrolling") != std::string::npos)
{ {
conf.header_text_scrolling = v == "yes"; conf.header_text_scrolling = v == "yes";
} }
else if (cl.find("statusbar_visibility") != string::npos) else if (cl.find("statusbar_visibility") != std::string::npos)
{ {
conf.statusbar_visibility = v == "yes"; conf.statusbar_visibility = v == "yes";
} }
else if (cl.find("autocenter_mode") != string::npos) else if (cl.find("autocenter_mode") != std::string::npos)
{ {
conf.autocenter_mode = v == "yes"; conf.autocenter_mode = v == "yes";
} }
else if (cl.find("default_find_mode") != string::npos) else if (cl.find("default_find_mode") != std::string::npos)
{ {
conf.wrapped_search = v == "wrapped"; conf.wrapped_search = v == "wrapped";
} }
else if (cl.find("default_space_mode") != string::npos) else if (cl.find("default_space_mode") != std::string::npos)
{ {
conf.space_selects = v == "select"; conf.space_selects = v == "select";
} }
else if (cl.find("default_tag_editor_left_col") != string::npos) else if (cl.find("default_tag_editor_left_col") != std::string::npos)
{ {
conf.albums_in_tag_editor = v == "albums"; conf.albums_in_tag_editor = v == "albums";
} }
else if (cl.find("incremental_seeking") != string::npos) else if (cl.find("incremental_seeking") != std::string::npos)
{ {
conf.incremental_seeking = v == "yes"; conf.incremental_seeking = v == "yes";
} }
else if (cl.find("show_hidden_files_in_local_browser") != string::npos) else if (cl.find("show_hidden_files_in_local_browser") != std::string::npos)
{ {
conf.local_browser_show_hidden_files = v == "yes"; conf.local_browser_show_hidden_files = v == "yes";
} }
else if (cl.find("follow_now_playing_lyrics") != string::npos) else if (cl.find("follow_now_playing_lyrics") != std::string::npos)
{ {
conf.now_playing_lyrics = v == "yes"; conf.now_playing_lyrics = v == "yes";
} }
else if (cl.find("ncmpc_like_songs_adding") != string::npos) else if (cl.find("ncmpc_like_songs_adding") != std::string::npos)
{ {
conf.ncmpc_like_songs_adding = v == "yes"; conf.ncmpc_like_songs_adding = v == "yes";
} }
else if (cl.find("default_place_to_search_in") != string::npos) else if (cl.find("default_place_to_search_in") != std::string::npos)
{ {
conf.search_in_db = v == "database"; conf.search_in_db = v == "database";
} }
else if (cl.find("display_screens_numbers_on_start") != string::npos) else if (cl.find("display_screens_numbers_on_start") != std::string::npos)
{ {
conf.display_screens_numbers_on_start = v == "yes"; conf.display_screens_numbers_on_start = v == "yes";
} }
else if (cl.find("clock_display_seconds") != string::npos) else if (cl.find("clock_display_seconds") != std::string::npos)
{ {
conf.clock_display_seconds = v == "yes"; conf.clock_display_seconds = v == "yes";
} }
else if (cl.find("ignore_leading_the") != string::npos) else if (cl.find("ignore_leading_the") != std::string::npos)
{ {
conf.ignore_leading_the = v == "yes"; conf.ignore_leading_the = v == "yes";
} }
else if (cl.find("use_console_editor") != string::npos) else if (cl.find("use_console_editor") != std::string::npos)
{ {
conf.use_console_editor = v == "yes"; conf.use_console_editor = v == "yes";
} }
else if (cl.find("block_search_constraints_change_if_items_found") != string::npos) else if (cl.find("block_search_constraints_change_if_items_found") != std::string::npos)
{ {
conf.block_search_constraints_change = v == "yes"; conf.block_search_constraints_change = v == "yes";
} }
else if (cl.find("allow_physical_files_deletion") != string::npos) else if (cl.find("allow_physical_files_deletion") != std::string::npos)
{ {
conf.allow_physical_files_deletion = v == "yes"; conf.allow_physical_files_deletion = v == "yes";
} }
else if (cl.find("allow_physical_directories_deletion") != string::npos) else if (cl.find("allow_physical_directories_deletion") != std::string::npos)
{ {
conf.allow_physical_directories_deletion = v == "yes"; conf.allow_physical_directories_deletion = v == "yes";
} }
else if (cl.find("mouse_support") != string::npos) else if (cl.find("mouse_support") != std::string::npos)
{ {
conf.mouse_support = v == "yes"; conf.mouse_support = v == "yes";
} }
else if (cl.find("enable_window_title") != string::npos) else if (cl.find("enable_window_title") != std::string::npos)
{ {
conf.set_window_title = v == "yes"; conf.set_window_title = v == "yes";
} }
else if (cl.find("regular_expressions") != string::npos) else if (cl.find("regular_expressions") != std::string::npos)
{ {
conf.regex_type = REG_EXTENDED * (v != "basic"); conf.regex_type = REG_EXTENDED * (v != "basic");
} }
else if (cl.find("lyrics_database") != string::npos) else if (cl.find("lyrics_database") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.lyrics_db = StrToInt(v)-1; conf.lyrics_db = StrToInt(v)-1;
} }
else if (cl.find("song_window_title_format") != string::npos) else if (cl.find("song_window_title_format") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.song_window_title_format = v; conf.song_window_title_format = v;
} }
else if (cl.find("empty_tag_color") != string::npos) else if (cl.find("empty_tag_color") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.empty_tags_color = IntoColor(v); conf.empty_tags_color = IntoColor(v);
} }
else if (cl.find("header_window_color") != string::npos) else if (cl.find("header_window_color") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.header_color = IntoColor(v); conf.header_color = IntoColor(v);
} }
else if (cl.find("volume_color") != string::npos) else if (cl.find("volume_color") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.volume_color = IntoColor(v); conf.volume_color = IntoColor(v);
} }
else if (cl.find("state_line_color") != string::npos) else if (cl.find("state_line_color") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.state_line_color = IntoColor(v); conf.state_line_color = IntoColor(v);
} }
else if (cl.find("state_flags_color") != string::npos) else if (cl.find("state_flags_color") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.state_flags_color = IntoColor(v); conf.state_flags_color = IntoColor(v);
} }
else if (cl.find("main_window_color") != string::npos) else if (cl.find("main_window_color") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.main_color = IntoColor(v); conf.main_color = IntoColor(v);
} }
else if (cl.find("main_window_highlight_color") != string::npos) else if (cl.find("main_window_highlight_color") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.main_highlight_color = IntoColor(v); conf.main_highlight_color = IntoColor(v);
} }
else if (cl.find("progressbar_color") != string::npos) else if (cl.find("progressbar_color") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.progressbar_color = IntoColor(v); conf.progressbar_color = IntoColor(v);
} }
else if (cl.find("statusbar_color") != string::npos) else if (cl.find("statusbar_color") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.statusbar_color = IntoColor(v); conf.statusbar_color = IntoColor(v);
} }
else if (cl.find("active_column_color") != string::npos) else if (cl.find("active_column_color") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.active_column_color = IntoColor(v); conf.active_column_color = IntoColor(v);
} }
else if (cl.find("window_border_color ") != string::npos) else if (cl.find("window_border_color ") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.window_border = IntoBorder(v); conf.window_border = IntoBorder(v);
} }
else if (cl.find("active_window_border") != string::npos) else if (cl.find("active_window_border") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.active_window_border = IntoBorder(v); conf.active_window_border = IntoBorder(v);
} }
else if (cl.find("media_library_left_column") != string::npos) else if (cl.find("media_library_left_column") != std::string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.media_lib_primary_tag = IntoTagItem(v[0]); conf.media_lib_primary_tag = IntoTagItem(v[0]);

View File

@@ -30,15 +30,12 @@
#include "misc.h" #include "misc.h"
#include "song.h" #include "song.h"
using MPD::Song; MPD::Song::Song(mpd_Song *s, bool copy_ptr) : itsSong(s ? s : mpd_newSong()),
using std::string; itsSlash(std::string::npos),
itsHash(0),
Song::Song(mpd_Song *s, bool copy_ptr) : itsSong(s ? s : mpd_newSong()), copyPtr(copy_ptr),
itsSlash(string::npos), isStream(0),
itsHash(0), isLocalised(0)
copyPtr(copy_ptr),
isStream(0),
isLocalised(0)
{ {
size_t file_len = itsSong->file ? strlen(itsSong->file) : 0; size_t file_len = itsSong->file ? strlen(itsSong->file) : 0;
@@ -58,7 +55,7 @@ Song::Song(mpd_Song *s, bool copy_ptr) : itsSong(s ? s : mpd_newSong()),
} }
} }
Song::Song(const Song &s) : itsSong(0), MPD::Song::Song(const Song &s) : itsSong(0),
itsNewName(s.itsNewName), itsNewName(s.itsNewName),
itsSlash(s.itsSlash), itsSlash(s.itsSlash),
itsHash(s.itsHash), itsHash(s.itsHash),
@@ -69,20 +66,20 @@ Song::Song(const Song &s) : itsSong(0),
itsSong = s.copyPtr ? s.itsSong : mpd_songDup(s.itsSong); itsSong = s.copyPtr ? s.itsSong : mpd_songDup(s.itsSong);
} }
Song::~Song() MPD::Song::~Song()
{ {
if (itsSong) if (itsSong)
mpd_freeSong(itsSong); mpd_freeSong(itsSong);
} }
string Song::GetLength() const std::string MPD::Song::GetLength() const
{ {
if (itsSong->time <= 0) if (itsSong->time <= 0)
return "-:--"; return "-:--";
return ShowTime(itsSong->time); return ShowTime(itsSong->time);
} }
void Song::Localize() void MPD::Song::Localize()
{ {
# ifdef HAVE_ICONV_H # ifdef HAVE_ICONV_H
if (isLocalised) if (isLocalised)
@@ -104,7 +101,7 @@ void Song::Localize()
# endif // HAVE_ICONV_H # endif // HAVE_ICONV_H
} }
void Song::Clear() void MPD::Song::Clear()
{ {
if (itsSong) if (itsSong)
mpd_freeSong(itsSong); mpd_freeSong(itsSong);
@@ -117,83 +114,83 @@ void Song::Clear()
copyPtr = 0; copyPtr = 0;
} }
bool Song::Empty() const bool MPD::Song::Empty() const
{ {
return !itsSong || (!itsSong->file && !itsSong->title && !itsSong->artist && !itsSong->album && !itsSong->date && !itsSong->track && !itsSong->genre && !itsSong->composer && !itsSong->performer && !itsSong->disc && !itsSong->comment); return !itsSong || (!itsSong->file && !itsSong->title && !itsSong->artist && !itsSong->album && !itsSong->date && !itsSong->track && !itsSong->genre && !itsSong->composer && !itsSong->performer && !itsSong->disc && !itsSong->comment);
} }
bool Song::IsFromDB() const bool MPD::Song::IsFromDB() const
{ {
const string &dir = GetDirectory(); const std::string &dir = GetDirectory();
return dir[0] != '/' || dir == "/"; return dir[0] != '/' || dir == "/";
} }
string Song::GetFile() const std::string MPD::Song::GetFile() const
{ {
return !itsSong->file ? "" : itsSong->file; return !itsSong->file ? "" : itsSong->file;
} }
string Song::GetName() const std::string MPD::Song::GetName() const
{ {
return !itsSong->file ? "" : (itsSlash != string::npos && !isStream ? itsSong->file+itsSlash+1 : (isStream && itsSong->name ? itsSong->name : itsSong->file)); return !itsSong->file ? "" : (itsSlash != std::string::npos && !isStream ? itsSong->file+itsSlash+1 : (isStream && itsSong->name ? itsSong->name : itsSong->file));
} }
string Song::GetDirectory() const std::string MPD::Song::GetDirectory() const
{ {
return !itsSong->file || isStream ? "" : itsSlash != string::npos ? string(itsSong->file).substr(0, itsSlash) : "/"; return !itsSong->file || isStream ? "" : itsSlash != std::string::npos ? std::string(itsSong->file).substr(0, itsSlash) : "/";
} }
string Song::GetArtist() const std::string MPD::Song::GetArtist() const
{ {
return !itsSong->artist ? "" : itsSong->artist; return !itsSong->artist ? "" : itsSong->artist;
} }
string Song::GetTitle() const std::string MPD::Song::GetTitle() const
{ {
return !itsSong->title ? "" : itsSong->title; return !itsSong->title ? "" : itsSong->title;
} }
string Song::GetAlbum() const std::string MPD::Song::GetAlbum() const
{ {
return !itsSong->album ? "" : itsSong->album; return !itsSong->album ? "" : itsSong->album;
} }
string Song::GetTrack() const std::string MPD::Song::GetTrack() const
{ {
return !itsSong->track ? "" : (StrToInt(itsSong->track) < 10 && itsSong->track[0] != '0' ? "0"+string(itsSong->track) : itsSong->track); return !itsSong->track ? "" : (StrToInt(itsSong->track) < 10 && itsSong->track[0] != '0' ? "0"+std::string(itsSong->track) : itsSong->track);
} }
string Song::GetYear() const std::string MPD::Song::GetYear() const
{ {
return !itsSong->date ? "" : itsSong->date; return !itsSong->date ? "" : itsSong->date;
} }
string Song::GetGenre() const std::string MPD::Song::GetGenre() const
{ {
return !itsSong->genre ? "" : itsSong->genre; return !itsSong->genre ? "" : itsSong->genre;
} }
string Song::GetComposer() const std::string MPD::Song::GetComposer() const
{ {
return !itsSong->composer ? "" : itsSong->composer; return !itsSong->composer ? "" : itsSong->composer;
} }
string Song::GetPerformer() const std::string MPD::Song::GetPerformer() const
{ {
return !itsSong->performer ? "" : itsSong->performer; return !itsSong->performer ? "" : itsSong->performer;
} }
string Song::GetDisc() const std::string MPD::Song::GetDisc() const
{ {
return !itsSong->disc ? "" : itsSong->disc; return !itsSong->disc ? "" : itsSong->disc;
} }
string Song::GetComment() const std::string MPD::Song::GetComment() const
{ {
return !itsSong->comment ? "" : itsSong->comment; return !itsSong->comment ? "" : itsSong->comment;
} }
void Song::SetFile(const string &str) void MPD::Song::SetFile(const std::string &str)
{ {
if (itsSong->file) if (itsSong->file)
str_pool_put(itsSong->file); str_pool_put(itsSong->file);
@@ -201,101 +198,101 @@ void Song::SetFile(const string &str)
CountLastSlashPosition(); CountLastSlashPosition();
} }
void Song::SetArtist(const string &str) void MPD::Song::SetArtist(const std::string &str)
{ {
if (itsSong->artist) if (itsSong->artist)
str_pool_put(itsSong->artist); str_pool_put(itsSong->artist);
itsSong->artist = str.empty() ? 0 : str_pool_get(str.c_str()); itsSong->artist = str.empty() ? 0 : str_pool_get(str.c_str());
} }
void Song::SetTitle(const string &str) void MPD::Song::SetTitle(const std::string &str)
{ {
if (itsSong->title) if (itsSong->title)
str_pool_put(itsSong->title); str_pool_put(itsSong->title);
itsSong->title = str.empty() ? 0 : str_pool_get(str.c_str()); itsSong->title = str.empty() ? 0 : str_pool_get(str.c_str());
} }
void Song::SetAlbum(const string &str) void MPD::Song::SetAlbum(const std::string &str)
{ {
if (itsSong->album) if (itsSong->album)
str_pool_put(itsSong->album); str_pool_put(itsSong->album);
itsSong->album = str.empty() ? 0 : str_pool_get(str.c_str()); itsSong->album = str.empty() ? 0 : str_pool_get(str.c_str());
} }
void Song::SetTrack(const string &str) void MPD::Song::SetTrack(const std::string &str)
{ {
if (itsSong->track) if (itsSong->track)
str_pool_put(itsSong->track); str_pool_put(itsSong->track);
itsSong->track = str.empty() ? 0 : str_pool_get(IntoStr(StrToInt(str)).c_str()); itsSong->track = str.empty() ? 0 : str_pool_get(IntoStr(StrToInt(str)).c_str());
} }
void Song::SetTrack(int track) void MPD::Song::SetTrack(int track)
{ {
if (itsSong->track) if (itsSong->track)
str_pool_put(itsSong->track); str_pool_put(itsSong->track);
itsSong->track = str_pool_get(IntoStr(track).c_str()); itsSong->track = str_pool_get(IntoStr(track).c_str());
} }
void Song::SetYear(const string &str) void MPD::Song::SetYear(const std::string &str)
{ {
if (itsSong->date) if (itsSong->date)
str_pool_put(itsSong->date); str_pool_put(itsSong->date);
itsSong->date = str.empty() ? 0 : str_pool_get(str.c_str()); itsSong->date = str.empty() ? 0 : str_pool_get(str.c_str());
} }
void Song::SetYear(int year) void MPD::Song::SetYear(int year)
{ {
if (itsSong->date) if (itsSong->date)
str_pool_put(itsSong->date); str_pool_put(itsSong->date);
itsSong->date = str_pool_get(IntoStr(year).c_str()); itsSong->date = str_pool_get(IntoStr(year).c_str());
} }
void Song::SetGenre(const string &str) void MPD::Song::SetGenre(const std::string &str)
{ {
if (itsSong->genre) if (itsSong->genre)
str_pool_put(itsSong->genre); str_pool_put(itsSong->genre);
itsSong->genre = str.empty() ? 0 : str_pool_get(str.c_str()); itsSong->genre = str.empty() ? 0 : str_pool_get(str.c_str());
} }
void Song::SetComposer(const string &str) void MPD::Song::SetComposer(const std::string &str)
{ {
if (itsSong->composer) if (itsSong->composer)
str_pool_put(itsSong->composer); str_pool_put(itsSong->composer);
itsSong->composer = str.empty() ? 0 : str_pool_get(str.c_str()); itsSong->composer = str.empty() ? 0 : str_pool_get(str.c_str());
} }
void Song::SetPerformer(const string &str) void MPD::Song::SetPerformer(const std::string &str)
{ {
if (itsSong->performer) if (itsSong->performer)
str_pool_put(itsSong->performer); str_pool_put(itsSong->performer);
itsSong->performer = str.empty() ? 0 : str_pool_get(str.c_str()); itsSong->performer = str.empty() ? 0 : str_pool_get(str.c_str());
} }
void Song::SetDisc(const string &str) void MPD::Song::SetDisc(const std::string &str)
{ {
if (itsSong->disc) if (itsSong->disc)
str_pool_put(itsSong->disc); str_pool_put(itsSong->disc);
itsSong->disc = str.empty() ? 0 : str_pool_get(str.c_str()); itsSong->disc = str.empty() ? 0 : str_pool_get(str.c_str());
} }
void Song::SetComment(const string &str) void MPD::Song::SetComment(const std::string &str)
{ {
if (itsSong->comment) if (itsSong->comment)
str_pool_put(itsSong->comment); str_pool_put(itsSong->comment);
itsSong->comment = str.empty() ? 0 : str_pool_get(str.c_str()); itsSong->comment = str.empty() ? 0 : str_pool_get(str.c_str());
} }
void Song::SetPosition(int pos) void MPD::Song::SetPosition(int pos)
{ {
itsSong->pos = pos; itsSong->pos = pos;
} }
string Song::toString(const std::string &format) const std::string MPD::Song::toString(const std::string &format) const
{ {
string result; std::string result;
string::const_iterator goto_pos, prev_pos; std::string::const_iterator goto_pos, prev_pos;
for (string::const_iterator it = format.begin(); it != format.end(); ++it) for (std::string::const_iterator it = format.begin(); it != format.end(); ++it)
{ {
CHECK_LINKED_TAGS:; CHECK_LINKED_TAGS:;
if (*it == '{') if (*it == '{')
@@ -452,7 +449,7 @@ string Song::toString(const std::string &format) const
return result; return result;
} }
Song & Song::operator=(const Song &s) MPD::Song & MPD::Song::operator=(const MPD::Song &s)
{ {
if (this == &s) if (this == &s)
return *this; return *this;
@@ -468,7 +465,7 @@ Song & Song::operator=(const Song &s)
return *this; return *this;
} }
bool Song::operator==(const Song &s) const bool MPD::Song::operator==(const Song &s) const
{ {
return (itsSong->file && s.itsSong->file return (itsSong->file && s.itsSong->file
? strcmp(itsSong->file, s.itsSong->file) == 0 ? strcmp(itsSong->file, s.itsSong->file) == 0
@@ -509,17 +506,17 @@ bool Song::operator==(const Song &s) const
&& itsHash == s.itsHash; && itsHash == s.itsHash;
} }
bool Song::operator!=(const Song &s) const bool MPD::Song::operator!=(const Song &s) const
{ {
return !operator==(s); return !operator==(s);
} }
bool Song::operator<(const Song &s) const bool MPD::Song::operator<(const Song &s) const
{ {
return itsSong->pos < s.itsSong->pos; return itsSong->pos < s.itsSong->pos;
} }
string Song::ShowTime(int length) std::string MPD::Song::ShowTime(int length)
{ {
std::ostringstream ss; std::ostringstream ss;
@@ -543,11 +540,11 @@ string Song::ShowTime(int length)
return ss.str(); return ss.str();
} }
void Song::CountLastSlashPosition() void MPD::Song::CountLastSlashPosition()
{ {
if (!itsSong->file) if (!itsSong->file)
return; return;
char *tmp = strrchr(itsSong->file, '/'); char *tmp = strrchr(itsSong->file, '/');
itsSlash = tmp ? tmp-itsSong->file : string::npos; itsSlash = tmp ? tmp-itsSong->file : std::string::npos;
} }

View File

@@ -36,9 +36,8 @@
using namespace Global; using namespace Global;
using namespace MPD; using namespace MPD;
using std::string;
string Global::VolumeState; std::string Global::VolumeState;
bool Global::UpdateStatusImmediately = 0; bool Global::UpdateStatusImmediately = 0;
bool Global::RedrawStatusbar = 0; bool Global::RedrawStatusbar = 0;
@@ -54,11 +53,9 @@ namespace
} }
#ifndef USE_PDCURSES #ifndef USE_PDCURSES
void WindowTitle(const string &status) void WindowTitle(const std::string &status)
{ {
static const string term_type = getenv("TERM") ? getenv("TERM") : ""; if (strcmp(getenv("TERM"), "linux") && Config.set_window_title)
if (term_type != "linux" && Config.set_window_title)
std::cout << "\033]0;" << status << "\7"; std::cout << "\033]0;" << status << "\7";
} }
#endif // !USE_PDCURSES #endif // !USE_PDCURSES
@@ -157,7 +154,7 @@ void NcmpcppErrorCallback(Connection *, int errorid, const char *msg, void *)
{ {
wFooter->SetGetStringHelper(NULL); wFooter->SetGetStringHelper(NULL);
Statusbar() << "Password: "; Statusbar() << "Password: ";
string password = wFooter->GetString(-1, 0, 1); std::string password = wFooter->GetString(-1, 0, 1);
Mpd.SetPassword(password); Mpd.SetPassword(password);
Mpd.SendPassword(); Mpd.SendPassword();
Mpd.UpdateStatus(); Mpd.UpdateStatus();
@@ -170,7 +167,7 @@ void NcmpcppErrorCallback(Connection *, int errorid, const char *msg, void *)
void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *) void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
{ {
static size_t playing_song_scroll_begin = 0; static size_t playing_song_scroll_begin = 0;
static string player_state; static std::string player_state;
static int elapsed; static int elapsed;
static MPD::Song np; static MPD::Song np;
@@ -395,7 +392,7 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
if (!block_statusbar_update && Config.statusbar_visibility) if (!block_statusbar_update && Config.statusbar_visibility)
{ {
string tracklength; std::string tracklength;
if (np.GetTotalLength()) if (np.GetTotalLength())
{ {
tracklength = " ["; tracklength = " [";
@@ -478,7 +475,7 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
} }
if (changed.StatusFlags && Config.header_visibility) if (changed.StatusFlags && Config.header_visibility)
{ {
string switch_state; std::string switch_state;
if (mpd_repeat) if (mpd_repeat)
switch_state += mpd_repeat; switch_state += mpd_repeat;

View File

@@ -30,9 +30,6 @@
using namespace NCurses; using namespace NCurses;
using std::string;
using std::wstring;
void NCurses::InitScreen(GNUC_UNUSED const char *window_title, bool enable_colors) void NCurses::InitScreen(GNUC_UNUSED const char *window_title, bool enable_colors)
{ {
const int ColorsTable[] = const int ColorsTable[] =
@@ -75,7 +72,7 @@ Window::Window(size_t startx,
size_t starty, size_t starty,
size_t width, size_t width,
size_t height, size_t height,
const string &title, const std::string &title,
Color color, Color color,
Border border) Border border)
: itsWindow(0), : itsWindow(0),
@@ -203,7 +200,7 @@ void Window::SetBorder(Border border)
itsBorder = border; itsBorder = border;
} }
void Window::SetTitle(const string &newtitle) void Window::SetTitle(const std::string &newtitle)
{ {
if (itsTitle == newtitle) if (itsTitle == newtitle)
{ {
@@ -379,7 +376,7 @@ void Window::WriteXY(int x, int y, bool cte, const char *format, ...) const
wclrtoeol(itsWindow); wclrtoeol(itsWindow);
}*/ }*/
string Window::GetString(const string &base, size_t length, size_t width, bool encrypted) const std::string Window::GetString(const std::string &base, size_t length, size_t width, bool encrypted) const
{ {
int input; int input;
size_t beginning, maxbeginning, minx, x, real_x, y, maxx, real_maxx; size_t beginning, maxbeginning, minx, x, real_x, y, maxx, real_maxx;
@@ -397,13 +394,13 @@ string Window::GetString(const string &base, size_t length, size_t width, bool e
std::wstring *tmp = &wbase; std::wstring *tmp = &wbase;
size_t history_offset = itsHistory && !encrypted ? itsHistory->size() : -1; size_t history_offset = itsHistory && !encrypted ? itsHistory->size() : -1;
string tmp_in; std::string tmp_in;
wchar_t wc_in; wchar_t wc_in;
bool gotoend = 1; bool gotoend = 1;
bool block_scrolling = 0; bool block_scrolling = 0;
// disable scrolling if wide chars are used // disable scrolling if wide chars are used
for (wstring::const_iterator it = tmp->begin(); it != tmp->end(); ++it) for (std::wstring::const_iterator it = tmp->begin(); it != tmp->end(); ++it)
if (wcwidth(*it) > 1) if (wcwidth(*it) > 1)
block_scrolling = 1; block_scrolling = 1;
@@ -430,7 +427,7 @@ string Window::GetString(const string &base, size_t length, size_t width, bool e
if (block_scrolling && maxx >= biggest_x) if (block_scrolling && maxx >= biggest_x)
{ {
size_t i = 0; size_t i = 0;
for (wstring::const_iterator it = tmp->begin(); i < width; ++it, ++real_real_maxx) for (std::wstring::const_iterator it = tmp->begin(); i < width; ++it, ++real_real_maxx)
i += wcwidth(*it); i += wcwidth(*it);
} }
else else
@@ -683,7 +680,7 @@ size_t Window::GetStartY() const
return starty; return starty;
} }
const string &Window::GetTitle() const const std::string &Window::GetTitle() const
{ {
return itsTitle; return itsTitle;
} }
@@ -844,16 +841,16 @@ Window &Window::operator<<(double d)
return *this; return *this;
} }
Window &Window::operator<<(const string &s) Window &Window::operator<<(const std::string &s)
{ {
for (string::const_iterator it = s.begin(); it != s.end(); ++it) for (std::string::const_iterator it = s.begin(); it != s.end(); ++it)
wprintw(itsWindow, "%c", *it); wprintw(itsWindow, "%c", *it);
return *this; return *this;
} }
Window &Window::operator<<(const wstring &ws) Window &Window::operator<<(const std::wstring &ws)
{ {
for (wstring::const_iterator it = ws.begin(); it != ws.end(); ++it) for (std::wstring::const_iterator it = ws.begin(); it != ws.end(); ++it)
wprintw(itsWindow, "%lc", *it); wprintw(itsWindow, "%lc", *it);
return *this; return *this;
} }
@@ -869,9 +866,9 @@ Window * Window::EmptyClone() const
return new Window(GetStartX(), GetStartY(), GetWidth(), GetHeight(), itsTitle, itsBaseColor, itsBorder); return new Window(GetStartX(), GetStartY(), GetWidth(), GetHeight(), itsTitle, itsBaseColor, itsBorder);
} }
string ToString(const wstring &ws) std::string ToString(const std::wstring &ws)
{ {
string result; std::string result;
char *s = new char[MB_CUR_MAX]; char *s = new char[MB_CUR_MAX];
for (size_t i = 0; i < ws.length(); ++i) for (size_t i = 0; i < ws.length(); ++i)
{ {
@@ -883,9 +880,9 @@ string ToString(const wstring &ws)
return result; return result;
} }
wstring ToWString(const string &s) std::wstring ToWString(const std::string &s)
{ {
wstring result; std::wstring result;
wchar_t *ws = new wchar_t[s.length()]; wchar_t *ws = new wchar_t[s.length()];
const char *c_s = s.c_str(); const char *c_s = s.c_str();
int n = mbsrtowcs(ws, &c_s, s.length(), 0); int n = mbsrtowcs(ws, &c_s, s.length(), 0);
@@ -895,10 +892,10 @@ wstring ToWString(const string &s)
return result; return result;
} }
size_t Window::Length(const wstring &ws) size_t Window::Length(const std::wstring &ws)
{ {
size_t length = 0; size_t length = 0;
for (wstring::const_iterator it = ws.begin(); it != ws.end(); ++it) for (std::wstring::const_iterator it = ws.begin(); it != ws.end(); ++it)
length += wcwidth(*it); length += wcwidth(*it);
return length; return length;
} }