From f9f5149b76e2943fa0f7b1709885340925d731fc Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Tue, 10 Feb 2009 12:19:59 +0100 Subject: [PATCH] includes cleaning --- src/browser.cpp | 1 + src/browser.h | 6 ++-- src/help.cpp | 2 ++ src/help.h | 4 +-- src/helpers.cpp | 1 + src/helpers.h | 22 +++++++------- src/lyrics.cpp | 3 ++ src/lyrics.h | 6 ++-- src/menu.h | 8 ++--- src/misc.cpp | 8 +++-- src/misc.h | 15 +++------ src/ncmpcpp.cpp | 5 +++ src/ncmpcpp.h | 9 +++--- src/scrollpad.cpp | 2 ++ src/scrollpad.h | 4 +-- src/search_engine.cpp | 3 +- src/search_engine.h | 10 +++--- src/settings.cpp | 5 +-- src/settings.h | 34 ++++++++++----------- src/song.cpp | 7 ++++- src/song.h | 69 ++++++++++++++++++++---------------------- src/status_checker.cpp | 3 ++ src/status_checker.h | 4 +-- src/tag_editor.cpp | 1 + src/tag_editor.h | 12 ++++---- src/window.cpp | 3 ++ src/window.h | 16 ++++------ 27 files changed, 137 insertions(+), 126 deletions(-) diff --git a/src/browser.cpp b/src/browser.cpp index 6bf13f9d..444a8d07 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -31,6 +31,7 @@ #endif // HAVE_TAGLIB_H using namespace MPD; +using std::string; extern Connection *Mpd; diff --git a/src/browser.h b/src/browser.h index ca021c47..89fedb43 100644 --- a/src/browser.h +++ b/src/browser.h @@ -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 *); void DisplayItem(const MPD::Item &, void *, Menu *); -void GetDirectory(string, string = "/"); +void GetDirectory(std::string, std::string = "/"); #endif diff --git a/src/help.cpp b/src/help.cpp index 70199133..6466ab4c 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -23,6 +23,8 @@ #include "help.h" #include "settings.h" +using std::string; + extern MPD::Connection *Mpd; extern ncmpcpp_keys Key; diff --git a/src/help.h b/src/help.h index d205cc8e..2b5e0972 100644 --- a/src/help.h +++ b/src/help.h @@ -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" diff --git a/src/helpers.cpp b/src/helpers.cpp index 830c3d38..4197d0d7 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -26,6 +26,7 @@ #include "tag_editor.h" using namespace MPD; +using std::string; extern Connection *Mpd; diff --git a/src/helpers.h b/src/helpers.h index f652727f..38f00aaa 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -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 *); 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 *); -string DisplayColumns(string); +std::string DisplayColumns(std::string); void DisplaySongInColumns(const Song &, void *, Menu *); void DisplaySong(const Song &, void * = &Config.song_list_format, Menu * = NULL); void GetInfo(Song &, Scrollpad &); Window &Statusbar(); -const Buffer &ShowTag(const string &); -const basic_buffer &ShowTagInInfoScreen(const string &); +const Buffer &ShowTag(const std::string &); +const basic_buffer &ShowTagInInfoScreen(const std::string &); -void Scroller(Window &, const string &, size_t, size_t &); +void Scroller(Window &, const std::string &, size_t, size_t &); #endif diff --git a/src/lyrics.cpp b/src/lyrics.cpp index 1f6cbb83..f496fc36 100644 --- a/src/lyrics.cpp +++ b/src/lyrics.cpp @@ -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; diff --git a/src/lyrics.h b/src/lyrics.h index 2202f3a7..da709112 100644 --- a/src/lyrics.h +++ b/src/lyrics.h @@ -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); diff --git a/src/menu.h b/src/menu.h index b5b78c74..3bab615f 100644 --- a/src/menu.h +++ b/src/menu.h @@ -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 - -//enum Location { lLeft, lCenter, lRight }; - class List { public: diff --git a/src/misc.cpp b/src/misc.cpp index b70370bc..5a504c89 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -19,6 +19,8 @@ ***************************************************************************/ #include +#include + #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; diff --git a/src/misc.h b/src/misc.h index b4a459fe..a4defcdc 100644 --- a/src/misc.h +++ b/src/misc.h @@ -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 -#include -#include #include -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 diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 75bc935f..89e35e75 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #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; diff --git a/src/ncmpcpp.h b/src/ncmpcpp.h index 1631177f..b9b3f019 100644 --- a/src/ncmpcpp.h +++ b/src/ncmpcpp.h @@ -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 StringPair; -using std::make_pair; +typedef std::pair 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 diff --git a/src/scrollpad.cpp b/src/scrollpad.cpp index 718989ce..c0085b09 100644 --- a/src/scrollpad.cpp +++ b/src/scrollpad.cpp @@ -20,6 +20,8 @@ #include "scrollpad.h" +using std::string; + Scrollpad::Scrollpad(size_t startx, size_t starty, size_t width, diff --git a/src/scrollpad.h b/src/scrollpad.h index 8199db11..0d6dcfc1 100644 --- a/src/scrollpad.h +++ b/src/scrollpad.h @@ -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" diff --git a/src/search_engine.cpp b/src/search_engine.cpp index d6bb0b55..721f3697 100644 --- a/src/search_engine.cpp +++ b/src/search_engine.cpp @@ -23,6 +23,7 @@ #include "settings.h" using namespace MPD; +using std::string; extern Connection *Mpd; extern Menu *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; diff --git a/src/search_engine.h b/src/search_engine.h index 40efc4c4..441c6c37 100644 --- a/src/search_engine.h +++ b/src/search_engine.h @@ -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; diff --git a/src/settings.cpp b/src/settings.cpp index 1c411acb..e1407313 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -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) diff --git a/src/settings.h b/src/settings.h index 9cb604e0..393f8094 100644 --- a/src/settings.h +++ b/src/settings.h @@ -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 diff --git a/src/song.cpp b/src/song.cpp index 293febfd..a44ab681 100644 --- a/src/song.cpp +++ b/src/song.cpp @@ -22,9 +22,14 @@ #include #endif +#include +#include +#include + #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), diff --git a/src/song.h b/src/song.h index 57521e3f..e9073c5a 100644 --- a/src/song.h +++ b/src/song.h @@ -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 #include -#include -#include #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; diff --git a/src/status_checker.cpp b/src/status_checker.cpp index be95ffe6..b0b704b6 100644 --- a/src/status_checker.cpp +++ b/src/status_checker.cpp @@ -18,6 +18,8 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include + #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; diff --git a/src/status_checker.h b/src/status_checker.h index ee1d0570..c509d49d 100644 --- a/src/status_checker.h +++ b/src/status_checker.h @@ -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" diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp index 5b5d39ff..8ee3385a 100644 --- a/src/tag_editor.cpp +++ b/src/tag_editor.cpp @@ -23,6 +23,7 @@ #ifdef HAVE_TAGLIB_H #include +#include #include "id3v2tag.h" #include "textidentificationframe.h" diff --git a/src/tag_editor.h b/src/tag_editor.h index 6b1d9852..bd885f59 100644 --- a/src/tag_editor.h +++ b/src/tag_editor.h @@ -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 *); -string FindSharedDir(const MPD::SongList &); +std::string FindSharedDir(Menu *); +std::string FindSharedDir(const MPD::SongList &); void DisplayTag(const Song &, void *, Menu *); SongSetFunction IntoSetFunction(mpd_TagItems); diff --git a/src/window.cpp b/src/window.cpp index c8251c16..080f9825 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -20,6 +20,9 @@ #include "window.h" +using std::string; +using std::wstring; + void InitScreen(bool enable_colors) { setlocale(LC_ALL, ""); diff --git a/src/window.h b/src/window.h index abe37b7c..7406fe76 100644 --- a/src/window.h +++ b/src/window.h @@ -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 @@ -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 itsColors; Color itsColor;