includes cleaning

This commit is contained in:
Andrzej Rybczak
2009-02-10 12:19:59 +01:00
parent b607617193
commit f9f5149b76
27 changed files with 137 additions and 126 deletions

View File

@@ -31,6 +31,7 @@
#endif // HAVE_TAGLIB_H
using namespace MPD;
using std::string;
extern Connection *Mpd;

View File

@@ -18,8 +18,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef HAVE_BROWSER_H
#define HAVE_BROWSER_H
#ifndef _BROWSER_H
#define _BROWSER_H
#include "mpdpp.h"
#include "ncmpcpp.h"
@@ -28,7 +28,7 @@ void UpdateItemList(Menu<MPD::Item> *);
void DisplayItem(const MPD::Item &, void *, Menu<MPD::Item> *);
void GetDirectory(string, string = "/");
void GetDirectory(std::string, std::string = "/");
#endif

View File

@@ -23,6 +23,8 @@
#include "help.h"
#include "settings.h"
using std::string;
extern MPD::Connection *Mpd;
extern ncmpcpp_keys Key;

View File

@@ -18,8 +18,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef HAVE_HELP_H
#define HAVE_HELP_H
#ifndef _HELP_H
#define _HELP_H
#include "ncmpcpp.h"

View File

@@ -26,6 +26,7 @@
#include "tag_editor.h"
using namespace MPD;
using std::string;
extern Connection *Mpd;

View File

@@ -18,8 +18,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef HAVE_HELPERS_H
#define HAVE_HELPERS_H
#ifndef _HELPERS_H
#define _HELPERS_H
#include "mpdpp.h"
#include "ncmpcpp.h"
@@ -31,7 +31,7 @@ void ParseArgv(int, char **);
class CaseInsensitiveSorting
{
public:
bool operator()(string, string);
bool operator()(std::string, std::string);
bool operator()(Song *, Song *);
bool operator()(const MPD::Item &, const MPD::Item &);
};
@@ -47,26 +47,26 @@ void UpdateSongList(Menu<Song> *);
bool Keypressed(int, const int *);
void WindowTitle(const string &);
void EscapeUnallowedChars(string &);
void WindowTitle(const std::string &);
void EscapeUnallowedChars(std::string &);
Window &operator<<(Window &, mpd_TagItems);
string IntoStr(mpd_TagItems);
string FindSharedDir(const string &, const string &);
std::string IntoStr(mpd_TagItems);
std::string FindSharedDir(const std::string &, const std::string &);
void DisplayTotalPlaylistLength(Window &);
void DisplayStringPair(const StringPair &, void *, Menu<StringPair> *);
string DisplayColumns(string);
std::string DisplayColumns(std::string);
void DisplaySongInColumns(const Song &, void *, Menu<Song> *);
void DisplaySong(const Song &, void * = &Config.song_list_format, Menu<Song> * = NULL);
void GetInfo(Song &, Scrollpad &);
Window &Statusbar();
const Buffer &ShowTag(const string &);
const basic_buffer<my_char_t> &ShowTagInInfoScreen(const string &);
const Buffer &ShowTag(const std::string &);
const basic_buffer<my_char_t> &ShowTagInInfoScreen(const std::string &);
void Scroller(Window &, const string &, size_t, size_t &);
void Scroller(Window &, const std::string &, size_t, size_t &);
#endif

View File

@@ -27,6 +27,9 @@
#include "settings.h"
#include "song.h"
using std::vector;
using std::string;
extern Window *wCurrent;
extern Scrollpad *sLyrics;
extern Scrollpad *sInfo;

View File

@@ -18,8 +18,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef HAVE_LYRICS_H
#define HAVE_LYRICS_H
#ifndef _LYRICS_H
#define _LYRICS_H
#include "ncmpcpp.h"
@@ -33,7 +33,7 @@ struct LyricsPlugin
const char *url;
const char *tag_open;
const char *tag_close;
bool (*not_found)(const string &);
bool (*not_found)(const std::string &);
};
const char *GetLyricsPluginName(int);

View File

@@ -18,16 +18,12 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef HAVE_MENU_H
#define HAVE_MENU_H
#ifndef _MENU_H
#define _MENU_H
#include "window.h"
#include "strbuffer.h"
//include <stdexcept>
//enum Location { lLeft, lCenter, lRight };
class List
{
public:

View File

@@ -19,6 +19,8 @@
***************************************************************************/
#include <algorithm>
#include <sstream>
#include "misc.h"
/*int Abs(int num)
@@ -26,17 +28,17 @@
return (num < 0 ? -num : num);
}*/
void ToLower(string &s)
void ToLower(std::string &s)
{
transform(s.begin(), s.end(), s.begin(), tolower);
}
int StrToInt(string str)
int StrToInt(std::string str)
{
return atoi(str.c_str());
}
string IntoStr(int l)
std::string IntoStr(int l)
{
std::stringstream ss;
ss << l;

View File

@@ -18,23 +18,18 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef HAVE_MISC_H
#define HAVE_MISC_H
#ifndef _MISC_H
#define _MISC_H
#include <cstdlib>
#include <sstream>
#include <iomanip>
#include <string>
using std::string;
//int Abs(int);
void ToLower(string &);
void ToLower(std::string &);
int StrToInt(string);
int StrToInt(std::string);
string IntoStr(int);
std::string IntoStr(int);
//string IntoStr(double, int);
#endif

View File

@@ -25,6 +25,7 @@
#include <iostream>
#include <fstream>
#include <map>
#include <stdexcept>
#include "mpdpp.h"
#include "ncmpcpp.h"
@@ -88,6 +89,10 @@
using namespace MPD;
using std::make_pair;
using std::string;
using std::vector;
ncmpcpp_config Config;
ncmpcpp_keys Key;

View File

@@ -18,16 +18,15 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef HAVE_NCMPCPP_H
#define HAVE_NCMPCPP_H
#ifndef _NCMPCPP_H
#define _NCMPCPP_H
#include "window.h"
#include "menu.h"
#include "scrollpad.h"
#include "misc.h"
typedef std::pair<string, string> StringPair;
using std::make_pair;
typedef std::pair<std::string, std::string> StringPair;
enum NcmpcppScreen
{
@@ -47,7 +46,7 @@ enum NcmpcppScreen
const int ncmpcpp_window_timeout = 500;
const string home_folder = getenv("HOME") ? getenv("HOME") : "";
const std::string home_folder = getenv("HOME") ? getenv("HOME") : "";
#endif

View File

@@ -20,6 +20,8 @@
#include "scrollpad.h"
using std::string;
Scrollpad::Scrollpad(size_t startx,
size_t starty,
size_t width,

View File

@@ -18,8 +18,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef HAVE_SCROLLPAD_H
#define HAVE_SCROLLPAD_H
#ifndef _SCROLLPAD_H
#define _SCROLLPAD_H
#include "window.h"
#include "strbuffer.h"

View File

@@ -23,6 +23,7 @@
#include "settings.h"
using namespace MPD;
using std::string;
extern Connection *Mpd;
extern Menu<Song> *mPlaylist;
@@ -287,7 +288,7 @@ void Search(SearchPattern s)
if (found && any_found)
{
Song *ss = Config.search_in_db ? *it : new Song(**it);
mSearcher->AddOption(make_pair((Buffer *)0, ss));
mSearcher->AddOption(std::make_pair((Buffer *)0, ss));
list[it-list.begin()] = 0;
}
found = 1;

View File

@@ -18,8 +18,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef HAVE_SEARCH_ENGINE_H
#define HAVE_SEARCH_ENGINE_H
#ifndef _SEARCH_ENGINE_H
#define _SEARCH_ENGINE_H
#include "mpdpp.h"
#include "ncmpcpp.h"
@@ -27,14 +27,14 @@
class SearchPattern : public Song
{
public:
const string &Any() { return itsAnyField; }
const string &Any(const string &s) { itsAnyField = s; return itsAnyField; }
const std::string &Any() { return itsAnyField; }
const std::string &Any(const std::string &s) { itsAnyField = s; return itsAnyField; }
void Clear() { Song::Clear(); itsAnyField.clear(); }
bool Empty() { return Song::Empty() && itsAnyField.empty(); }
protected:
string itsAnyField;
std::string itsAnyField;
};
const size_t search_engine_static_options = 20;

View File

@@ -23,11 +23,12 @@
#include "settings.h"
using std::ifstream;
using std::string;
const string config_file = config_dir + "config";
const string keys_config_file = config_dir + "keys";
using std::ifstream;
namespace
{
void GetKeys(string &line, int *key)

View File

@@ -18,13 +18,13 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef HAVE_SETTINGS_H
#define HAVE_SETTINGS_H
#ifndef _SETTINGS_H
#define _SETTINGS_H
#include "libmpdclient.h"
#include "ncmpcpp.h"
const string config_dir = home_folder + "/.ncmpcpp/";
const std::string config_dir = home_folder + "/.ncmpcpp/";
const int null_key = 0x0fffffff;
struct ncmpcpp_keys
@@ -96,18 +96,18 @@ struct ncmpcpp_keys
struct ncmpcpp_config
{
string mpd_host;
string mpd_music_dir;
string empty_tag;
string song_list_format;
string song_columns_list_format;
string song_status_format;
string song_window_title_format;
string song_library_format;
string media_lib_album_format;
string tag_editor_album_format;
std::string mpd_host;
std::string mpd_music_dir;
std::string empty_tag;
std::string song_list_format;
std::string song_columns_list_format;
std::string song_status_format;
std::string song_window_title_format;
std::string song_library_format;
std::string media_lib_album_format;
std::string tag_editor_album_format;
string pattern;
std::string pattern;
Buffer browser_playlist_prefix;
Buffer selected_item_prefix;
@@ -170,10 +170,10 @@ void DefaultConfiguration(ncmpcpp_config &);
void ReadKeys(ncmpcpp_keys &);
void ReadConfiguration(ncmpcpp_config &);
Color IntoColor(const string &);
string IntoStr(Color);
Color IntoColor(const std::string &);
std::string IntoStr(Color);
mpd_TagItems IntoTagItem(char);
string GetLineValue(string &, char = '"', char = '"', bool = 0);
std::string GetLineValue(std::string &, char = '"', char = '"', bool = 0);
#endif

View File

@@ -22,9 +22,14 @@
#include <config.h>
#endif
#include <cstring>
#include <iomanip>
#include <sstream>
#include "charset.h"
#include "song.h"
#include "settings.h"
using std::string;
Song::Song(mpd_Song *s, bool copy_ptr) : itsSong(s ? s : mpd_newSong()),
itsSlash(string::npos),

View File

@@ -18,63 +18,58 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef HAVE_SONG_H
#define HAVE_SONG_H
#ifndef _SONG_H
#define _SONG_H
#include <cstdlib>
#include <string>
#include <sstream>
#include <stdexcept>
#include "misc.h"
#include "libmpdclient.h"
using std::string;
class Song
{
public:
Song() : itsSlash(string::npos), itsHash(0), copyPtr(0), isStream(0), isLocalised(0) { itsSong = mpd_newSong(); }
Song() : itsSlash(std::string::npos), itsHash(0), copyPtr(0), isStream(0), isLocalised(0) { itsSong = mpd_newSong(); }
Song(mpd_Song *, bool = 0);
Song(const Song &);
~Song();
string GetFile() const;
string GetName() const;
string GetDirectory() const;
string GetArtist() const;
string GetTitle() const;
string GetAlbum() const;
string GetTrack() const;
string GetYear() const;
string GetGenre() const;
string GetComposer() const;
string GetPerformer() const;
string GetDisc() const;
string GetComment() const;
string GetLength() const;
std::string GetFile() const;
std::string GetName() const;
std::string GetDirectory() const;
std::string GetArtist() const;
std::string GetTitle() const;
std::string GetAlbum() const;
std::string GetTrack() const;
std::string GetYear() const;
std::string GetGenre() const;
std::string GetComposer() const;
std::string GetPerformer() const;
std::string GetDisc() const;
std::string GetComment() const;
std::string GetLength() const;
const long long &GetHash() const { return itsHash; }
int GetTotalLength() const { return itsSong->time < 0 ? 0 : itsSong->time; }
int GetPosition() const { return itsSong->pos; }
int GetID() const { return itsSong->id; }
void SetFile(const string &);
void SetArtist(const string &);
void SetTitle(const string &);
void SetAlbum(const string &);
void SetTrack(const string &);
void SetFile(const std::string &);
void SetArtist(const std::string &);
void SetTitle(const std::string &);
void SetAlbum(const std::string &);
void SetTrack(const std::string &);
void SetTrack(int);
void SetYear(const string &);
void SetYear(const std::string &);
void SetYear(int);
void SetGenre(const string &);
void SetComposer(const string &);
void SetPerformer(const string &);
void SetDisc(const string &);
void SetComment(const string &);
void SetGenre(const std::string &);
void SetComposer(const std::string &);
void SetPerformer(const std::string &);
void SetDisc(const std::string &);
void SetComment(const std::string &);
void SetPosition(int);
void SetNewName(const string &name) { itsNewName = name == GetName() ? "" : name; }
string GetNewName() const { return itsNewName; }
void SetNewName(const std::string &name) { itsNewName = name == GetName() ? "" : name; }
std::string GetNewName() const { return itsNewName; }
std::string toString(const std::string &) const;
@@ -95,12 +90,12 @@ class Song
bool operator!=(const Song &) const;
bool operator<(const Song &rhs) const;
static string ShowTime(int);
static std::string ShowTime(int);
private:
void __Count_Last_Slash_Position();
mpd_Song *itsSong;
string itsNewName;
std::string itsNewName;
size_t itsSlash;
long long itsHash;
bool copyPtr;

View File

@@ -18,6 +18,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include <stdexcept>
#include "browser.h"
#include "charset.h"
#include "helpers.h"
@@ -26,6 +28,7 @@
#include "status_checker.h"
using namespace MPD;
using std::string;
extern Connection *Mpd;

View File

@@ -18,8 +18,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef HAVE_STATUS_CHECKER_H
#define HAVE_STATUS_CHECKER_H
#ifndef _STATUS_CHECKER_H
#define _STATUS_CHECKER_H
#include "mpdpp.h"
#include "ncmpcpp.h"

View File

@@ -23,6 +23,7 @@
#ifdef HAVE_TAGLIB_H
#include <fstream>
#include <stdexcept>
#include "id3v2tag.h"
#include "textidentificationframe.h"

View File

@@ -22,8 +22,8 @@
#ifdef HAVE_TAGLIB_H
#ifndef HAVE_TAG_EDITOR_H
#define HAVE_TAG_EDITOR_H
#ifndef _TAG_EDITOR_H
#define _TAG_EDITOR_H
// taglib headers
#include "fileref.h"
@@ -32,11 +32,11 @@
#include "mpdpp.h"
#include "settings.h"
typedef void (Song::*SongSetFunction)(const string &);
typedef string (Song::*SongGetFunction)() const;
typedef void (Song::*SongSetFunction)(const std::string &);
typedef std::string (Song::*SongGetFunction)() const;
string FindSharedDir(Menu<Song> *);
string FindSharedDir(const MPD::SongList &);
std::string FindSharedDir(Menu<Song> *);
std::string FindSharedDir(const MPD::SongList &);
void DisplayTag(const Song &, void *, Menu<Song> *);
SongSetFunction IntoSetFunction(mpd_TagItems);

View File

@@ -20,6 +20,9 @@
#include "window.h"
using std::string;
using std::wstring;
void InitScreen(bool enable_colors)
{
setlocale(LC_ALL, "");

View File

@@ -18,8 +18,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef HAVE_WINDOW_H
#define HAVE_WINDOW_H
#ifndef _WINDOW_H
#define _WINDOW_H
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -47,10 +47,6 @@
# define TO_WSTRING(x) x
#endif
using std::string;
using std::wstring;
using std::vector;
enum Color { clDefault, clBlack, clRed, clGreen, clYellow, clBlue, clMagenta, clCyan, clWhite, clEnd };
enum Format { fmtNone = 100, fmtBold, fmtBoldEnd, fmtReverse, fmtReverseEnd, fmtAltCharset, fmtAltCharsetEnd };
enum Border { brNone, brBlack, brRed, brGreen, brYellow, brBlue, brMagenta, brCyan, brWhite };
@@ -98,7 +94,7 @@ class Window
Color GetColor() const;
Border GetBorder() const;
std::string GetString(const std::string &, size_t = -1, size_t = 0, bool = 0) const;
string GetString(size_t length = -1, size_t width = 0, bool encrypted = 0) const { return GetString("", length, width, encrypted); }
std::string GetString(size_t length = -1, size_t width = 0, bool encrypted = 0) const { return GetString("", length, width, encrypted); }
void GetXY(int &, int &);
void GotoXY(int, int);
const int &X() const;
@@ -109,7 +105,7 @@ class Window
void SetBaseColor(Color, Color = clDefault);
void SetBorder(Border);
void SetTimeout(int);
void SetTitle(const string &);
void SetTitle(const std::string &);
void Hide(char = 32) const;
void Bold(bool) const;
@@ -150,7 +146,7 @@ class Window
virtual Window *Clone() const { return new Window(*this); }
virtual Window *EmptyClone() const;
static size_t Length(const wstring &);
static size_t Length(const std::wstring &);
protected:
@@ -173,7 +169,7 @@ class Window
int itsX;
int itsY;
string itsTitle;
std::string itsTitle;
std::stack<Colors> itsColors;
Color itsColor;