Skip to content

Commit

Permalink
CMusicInfo code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
psyton committed Jun 19, 2012
1 parent e4e5433 commit 6b4881c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 66 deletions.
76 changes: 13 additions & 63 deletions xbmc/music/tags/MusicInfoTag.cpp
Expand Up @@ -30,52 +30,24 @@
using namespace MUSIC_INFO;

CMusicInfoTag::CMusicInfoTag(const CStdString& strMediaFile /*= CStdString()*/)
: m_iDuration(0)
, m_iTrack(0)
, m_iDbId(-1)
, m_bLoaded(false)
, m_rating('0')
, m_listeners(0)
, m_iTimesPlayed(0)
, m_iArtistId(-1)
, m_iAlbumId(-1)
{
Clear();
memset(&m_dwReleaseDate, 0, sizeof(m_dwReleaseDate) );
if (!strMediaFile.IsEmpty())
LoadFromFile(strMediaFile);
}

CMusicInfoTag::CMusicInfoTag(const CMusicInfoTag& tag)
{
*this = tag;
}

CMusicInfoTag::~CMusicInfoTag()
{}

const CMusicInfoTag& CMusicInfoTag::operator =(const CMusicInfoTag& tag)
{
if (this == &tag) return * this;

m_strURL = tag.m_strURL;
m_artist = tag.m_artist;
m_albumArtist = tag.m_albumArtist;
m_strAlbum = tag.m_strAlbum;
m_genre = tag.m_genre;
m_strTitle = tag.m_strTitle;
m_strMusicBrainzTrackID = tag.m_strMusicBrainzTrackID;
m_strMusicBrainzArtistID = tag.m_strMusicBrainzArtistID;
m_strMusicBrainzAlbumID = tag.m_strMusicBrainzAlbumID;
m_strMusicBrainzAlbumArtistID = tag.m_strMusicBrainzAlbumArtistID;
m_strMusicBrainzTRMID = tag.m_strMusicBrainzTRMID;
m_strComment = tag.m_strComment;
m_strLyrics = tag.m_strLyrics;
m_lastPlayed = tag.m_lastPlayed;
m_iDuration = tag.m_iDuration;
m_iTrack = tag.m_iTrack;
m_bLoaded = tag.m_bLoaded;
m_rating = tag.m_rating;
m_listeners = tag.m_listeners;
m_iTimesPlayed = tag.m_iTimesPlayed;
m_iDbId = tag.m_iDbId;
m_iArtistId = tag.m_iArtistId;
m_iAlbumId = tag.m_iAlbumId;
m_strCue = tag.m_strCue;
memcpy(&m_dwReleaseDate, &tag.m_dwReleaseDate, sizeof(m_dwReleaseDate) );
return *this;
}

bool CMusicInfoTag::operator !=(const CMusicInfoTag& tag) const
{
if (this == &tag) return false;
Expand Down Expand Up @@ -430,7 +402,7 @@ bool CMusicInfoTag::HasEmbeddedCue() const
{
return !GetEmbeddedCue().IsEmpty();
}

const CStdString& CMusicInfoTag::GetEmbeddedCue() const
{
return m_strCue;
Expand All @@ -441,7 +413,6 @@ void CMusicInfoTag::SetEmbeddedCue(const CStdString& cuesheet)
m_strCue = cuesheet;
}


void CMusicInfoTag::Serialize(CVariant& value)
{
/* TODO:
Expand Down Expand Up @@ -470,6 +441,7 @@ void CMusicInfoTag::Serialize(CVariant& value)
value["artistid"] = m_iArtistId;
value["albumid"] = m_iAlbumId;
}

void CMusicInfoTag::Archive(CArchive& ar)
{
if (ar.IsStoring())
Expand Down Expand Up @@ -524,29 +496,7 @@ void CMusicInfoTag::Archive(CArchive& ar)

void CMusicInfoTag::Clear()
{
m_strURL.Empty();
m_artist.clear();
m_strAlbum.Empty();
m_albumArtist.clear();
m_genre.clear();
m_strTitle.Empty();
m_strMusicBrainzTrackID.Empty();
m_strMusicBrainzArtistID.Empty();
m_strMusicBrainzAlbumID.Empty();
m_strMusicBrainzAlbumArtistID.Empty();
m_strMusicBrainzTRMID.Empty();
m_iDuration = 0;
m_iTrack = 0;
m_bLoaded = false;
m_lastPlayed.Reset();
m_strComment.Empty();
m_strCue.Empty();
m_rating = '0';
m_iDbId = -1;
m_iTimesPlayed = 0;
memset(&m_dwReleaseDate, 0, sizeof(m_dwReleaseDate) );
m_iArtistId = -1;
m_iAlbumId = -1;
*this = CMusicInfoTag();
}

void CMusicInfoTag::AppendArtist(const CStdString &artist)
Expand Down
10 changes: 7 additions & 3 deletions xbmc/music/tags/MusicInfoTag.h
Expand Up @@ -34,10 +34,12 @@ namespace MUSIC_INFO
class CMusicInfoTag : public IArchivable, public ISerializable
{
public:
/*! \brief Constructor.
* Create CMusicInfoTag object. If \b strMediaFile isn't empty try to load tag from file
* otherwise object will be empty.
*/
CMusicInfoTag(const CStdString& strMediaFile = CStdString());
CMusicInfoTag(const CMusicInfoTag& tag);
virtual ~CMusicInfoTag();
const CMusicInfoTag& operator =(const CMusicInfoTag& tag);
bool operator !=(const CMusicInfoTag& tag) const;
bool Loaded() const;
const CStdString& GetTitle() const;
Expand Down Expand Up @@ -122,7 +124,9 @@ class CMusicInfoTag : public IArchivable, public ISerializable
bool HasEmbeddedCue() const;
const CStdString& GetEmbeddedCue() const;
void SetEmbeddedCue(const CStdString& cuesheet);


/*! \brief Try to load metadata from file
*/
void LoadFromFile(const CStdString& strMediaFile);

virtual void Archive(CArchive& ar);
Expand Down

0 comments on commit 6b4881c

Please sign in to comment.