put local functions into unnamed namespaces
This commit is contained in:
@@ -23,8 +23,10 @@
|
||||
|
||||
extern ncmpcpp_keys Key;
|
||||
|
||||
string DisplayKeys(int *key, int size = 2)
|
||||
namespace
|
||||
{
|
||||
string DisplayKeys(int *key, int size = 2)
|
||||
{
|
||||
bool backspace = 1;
|
||||
string result = "\t";
|
||||
for (int i = 0; i < size; i++)
|
||||
@@ -79,6 +81,7 @@ string DisplayKeys(int *key, int size = 2)
|
||||
for (int i = result.length(); i <= 12; result += " ", i++);
|
||||
result += ": ";
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
string GetKeybindings()
|
||||
|
||||
@@ -32,8 +32,10 @@ pthread_mutex_t curl = PTHREAD_MUTEX_INITIALIZER;
|
||||
bool data_ready = 0;
|
||||
#endif
|
||||
|
||||
size_t write_data(char *buffer, size_t size, size_t nmemb, string data)
|
||||
namespace
|
||||
{
|
||||
size_t write_data(char *buffer, size_t size, size_t nmemb, string data)
|
||||
{
|
||||
int result = 0;
|
||||
if (buffer)
|
||||
{
|
||||
@@ -41,10 +43,10 @@ size_t write_data(char *buffer, size_t size, size_t nmemb, string data)
|
||||
result = size*nmemb;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
void EscapeHtml(string &str)
|
||||
{
|
||||
void EscapeHtml(string &str)
|
||||
{
|
||||
for (int i = str.find("<"); i != string::npos; i = str.find("<"))
|
||||
{
|
||||
int j = str.find(">")+1;
|
||||
@@ -56,6 +58,7 @@ void EscapeHtml(string &str)
|
||||
str.replace(i, 6, "\"");
|
||||
for (int i = str.find("&"); i != string::npos; i = str.find("&"))
|
||||
str.replace(i, 5, "&");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_CURL_CURL_H
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
void * GetArtistInfo(void *);
|
||||
#endif
|
||||
|
||||
void EscapeHtml(string &);
|
||||
void * GetLyrics(void *);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -197,29 +197,6 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
conf.message_delay_time = 4;
|
||||
}
|
||||
|
||||
void GetKeys(string line, int *key)
|
||||
{
|
||||
int i = line.find("=")+1;
|
||||
line = line.substr(i, line.length()-i);
|
||||
i = 0;
|
||||
if (line[i] == ' ')
|
||||
while (line[++i] == ' ');
|
||||
line = line.substr(i, line.length()-i);
|
||||
i = line.find(" ");
|
||||
string one;
|
||||
string two;
|
||||
if (i != string::npos)
|
||||
{
|
||||
one = line.substr(0, i);
|
||||
i++;
|
||||
two = line.substr(i, line.length()-i);
|
||||
}
|
||||
else
|
||||
one = line;
|
||||
key[0] = !one.empty() && one[0] == '\'' ? one[1] : (atoi(one.c_str()) == 0 ? null_key : atoi(one.c_str()));
|
||||
key[1] = !two.empty() && two[0] == '\'' ? two[1] : (atoi(two.c_str()) == 0 ? null_key : atoi(two.c_str()));
|
||||
}
|
||||
|
||||
string GetLineValue(const string &line, char a, char b)
|
||||
{
|
||||
int i = 0;
|
||||
@@ -240,8 +217,33 @@ string GetLineValue(const string &line, char a, char b)
|
||||
return "";
|
||||
}
|
||||
|
||||
string IntoStr(Color color)
|
||||
namespace
|
||||
{
|
||||
void GetKeys(string line, int *key)
|
||||
{
|
||||
int i = line.find("=")+1;
|
||||
line = line.substr(i, line.length()-i);
|
||||
i = 0;
|
||||
if (line[i] == ' ')
|
||||
while (line[++i] == ' ');
|
||||
line = line.substr(i, line.length()-i);
|
||||
i = line.find(" ");
|
||||
string one;
|
||||
string two;
|
||||
if (i != string::npos)
|
||||
{
|
||||
one = line.substr(0, i);
|
||||
i++;
|
||||
two = line.substr(i, line.length()-i);
|
||||
}
|
||||
else
|
||||
one = line;
|
||||
key[0] = !one.empty() && one[0] == '\'' ? one[1] : (atoi(one.c_str()) == 0 ? null_key : atoi(one.c_str()));
|
||||
key[1] = !two.empty() && two[0] == '\'' ? two[1] : (atoi(two.c_str()) == 0 ? null_key : atoi(two.c_str()));
|
||||
}
|
||||
|
||||
string IntoStr(Color color)
|
||||
{
|
||||
string result;
|
||||
|
||||
if (color == clDefault)
|
||||
@@ -264,10 +266,10 @@ string IntoStr(Color color)
|
||||
result = "white";
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Color IntoColor(const string &color)
|
||||
{
|
||||
Color IntoColor(const string &color)
|
||||
{
|
||||
Color result = clDefault;
|
||||
|
||||
if (color == "black")
|
||||
@@ -288,6 +290,7 @@ Color IntoColor(const string &color)
|
||||
result = clWhite;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
void ReadKeys(ncmpcpp_keys &keys)
|
||||
|
||||
@@ -147,12 +147,10 @@ struct ncmpcpp_config
|
||||
|
||||
void DefaultKeys(ncmpcpp_keys &);
|
||||
void DefaultConfiguration(ncmpcpp_config &);
|
||||
void GetKeys(string, int *);
|
||||
string GetLineValue(const string &, char = '"', char = '"');
|
||||
string IntoStr(Color);
|
||||
Color IntoColor(const string &);
|
||||
void ReadKeys(ncmpcpp_keys &);
|
||||
void ReadConfiguration(ncmpcpp_config &);
|
||||
|
||||
string GetLineValue(const string &, char = '"', char = '"');
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -189,8 +189,10 @@ bool WriteTags(Song &s)
|
||||
return false;
|
||||
}
|
||||
|
||||
SongSetFunction IntoSetFunction(char c)
|
||||
namespace
|
||||
{
|
||||
SongSetFunction IntoSetFunction(char c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'a':
|
||||
@@ -216,10 +218,10 @@ SongSetFunction IntoSetFunction(char c)
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string GenerateFilename(const Song &s, string &pattern)
|
||||
{
|
||||
string GenerateFilename(const Song &s, string &pattern)
|
||||
{
|
||||
const string unallowed_chars = "\"*/:<>?\\|";
|
||||
string result = Window::OmitBBCodes(DisplaySong(s, &pattern));
|
||||
for (string::const_iterator it = unallowed_chars.begin(); it != unallowed_chars.end(); it++)
|
||||
@@ -231,10 +233,10 @@ string GenerateFilename(const Song &s, string &pattern)
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
string ParseFilename(Song &s, string mask, bool preview)
|
||||
{
|
||||
string ParseFilename(Song &s, string mask, bool preview)
|
||||
{
|
||||
std::stringstream result;
|
||||
vector<string> separators;
|
||||
vector< std::pair<char, string> > tags;
|
||||
@@ -281,6 +283,7 @@ string ParseFilename(Song &s, string mask, bool preview)
|
||||
result << "%" << it->first << ": " << it->second << "\n";
|
||||
}
|
||||
return result.str();
|
||||
}
|
||||
}
|
||||
|
||||
void __deal_with_filenames(SongList &v)
|
||||
|
||||
@@ -41,8 +41,6 @@ string DisplayTag(const Song &, void *, const Menu<Song> *);
|
||||
bool GetSongTags(Song &);
|
||||
bool WriteTags(Song &);
|
||||
|
||||
string GenerateFilename(const Song &, string &);
|
||||
string ParseFilename(Song &, string, bool);
|
||||
void __deal_with_filenames(SongList &);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user