fix compilation --without-taglib
[ncmpcpp/cirrus.git] / src / song.h
blobd5d63b3af8e057deb803196ce16f688df74834ff
1 /***************************************************************************
2 * Copyright (C) 2008 by Andrzej Rybczak *
3 * electricityispower@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef HAVE_SONG_H
22 #define HAVE_SONG_H
24 #include <cstdlib>
25 #include <string>
26 #include <sstream>
27 #include <stdexcept>
29 #include "misc.h"
30 #include "libmpdclient.h"
32 using std::string;
34 class Song
36 public:
37 Song() : itsSlash(string::npos), itsHash(0), copyPtr(0), isStream(0) { itsSong = mpd_newSong(); }
38 Song(mpd_Song *, bool = 0);
39 Song(const Song &);
40 ~Song();
42 string GetFile() const;
43 string GetName() const;
44 string GetDirectory() const;
45 string GetArtist() const;
46 string GetTitle() const;
47 string GetAlbum() const;
48 string GetTrack() const;
49 string GetYear() const;
50 string GetGenre() const;
51 string GetComposer() const;
52 string GetPerformer() const;
53 string GetDisc() const;
54 string GetComment() const;
55 string GetLength() const;
56 const long long &GetHash() const { return itsHash; }
57 int GetTotalLength() const { return itsSong->time < 0 ? 0 : itsSong->time; }
58 int GetPosition() const { return itsSong->pos; }
59 int GetID() const { return itsSong->id; }
61 void SetFile(const string &);
62 void SetArtist(const string &);
63 void SetTitle(const string &);
64 void SetAlbum(const string &);
65 void SetTrack(const string &);
66 void SetTrack(int);
67 void SetYear(const string &);
68 void SetYear(int);
69 void SetGenre(const string &);
70 void SetComposer(const string &);
71 void SetPerformer(const string &);
72 void SetDisc(const string &);
73 void SetComment(const string &);
74 void SetPosition(int);
76 void SetNewName(const string &name) { itsNewName = name == GetName() ? "" : name; }
77 string GetNewName() const { return itsNewName; }
79 std::string toString(const std::string &) const;
81 void NullMe() { itsSong = 0; }
82 void CopyPtr(bool copy) { copyPtr = copy; }
84 //void GetEmptyFields(bool get) { itsGetEmptyFields = get; }
85 void Clear();
86 bool Empty() const;
87 bool IsFromDB() const;
88 bool IsStream() const { return isStream; }
90 Song & operator=(const Song &);
91 bool operator==(const Song &) const;
92 bool operator!=(const Song &) const;
93 bool operator<(const Song &rhs) const;
95 static string ShowTime(int);
96 private:
97 mpd_Song *itsSong;
98 string itsNewName;
99 size_t itsSlash;
100 long long itsHash;
101 bool copyPtr;
102 bool isStream;
103 //bool itsGetEmptyFields;
106 #endif