1
/* --------------------------------------------------------------------------
3
libmusicbrainz4 - Client library to access MusicBrainz
5
Copyright (C) 2011 Andrew Hawkins
7
This file is part of libmusicbrainz4.
9
This library is free software; you can redistribute it and/or
10
modify it under the terms of v2 of the GNU Lesser General Public
11
License as published by the Free Software Foundation.
13
libmusicbrainz4 is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
Lesser General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with this library. If not, see <http://www.gnu.org/licenses/>.
21
$Id: FreeDBDisc.cc 13259 2011-08-10 12:02:50Z adhawkins $
23
----------------------------------------------------------------------------*/
25
#include "musicbrainz4/FreeDBDisc.h"
27
#include "musicbrainz4/NonMBTrackList.h"
28
#include "musicbrainz4/NonMBTrack.h"
30
class MusicBrainz4::CFreeDBDiscPrivate
41
std::string m_Category;
43
CNonMBTrackList *m_NonMBTrackList;
46
MusicBrainz4::CFreeDBDisc::CFreeDBDisc(const XMLNode& Node)
48
m_d(new CFreeDBDiscPrivate)
52
//std::cout << "FreeDBDisc node: " << std::endl << Node.createXMLString(true) << std::endl;
58
MusicBrainz4::CFreeDBDisc::CFreeDBDisc(const CFreeDBDisc& Other)
60
m_d(new CFreeDBDiscPrivate)
65
MusicBrainz4::CFreeDBDisc& MusicBrainz4::CFreeDBDisc::operator =(const CFreeDBDisc& Other)
71
CEntity::operator =(Other);
73
m_d->m_ID=Other.m_d->m_ID;
74
m_d->m_Title=Other.m_d->m_Title;
75
m_d->m_Artist=Other.m_d->m_Artist;
76
m_d->m_Category=Other.m_d->m_Category;
77
m_d->m_Year=Other.m_d->m_Year;
79
if (Other.m_d->m_NonMBTrackList)
80
m_d->m_NonMBTrackList=new CNonMBTrackList(*Other.m_d->m_NonMBTrackList);
86
MusicBrainz4::CFreeDBDisc::~CFreeDBDisc()
93
void MusicBrainz4::CFreeDBDisc::Cleanup()
95
delete m_d->m_NonMBTrackList;
96
m_d->m_NonMBTrackList=0;
99
MusicBrainz4::CFreeDBDisc *MusicBrainz4::CFreeDBDisc::Clone()
101
return new CFreeDBDisc(*this);
104
bool MusicBrainz4::CFreeDBDisc::ParseAttribute(const std::string& Name, const std::string& Value)
113
std::cerr << "Unrecognised freedb disc attribute: '" << Name << "'" << std::endl;
120
bool MusicBrainz4::CFreeDBDisc::ParseElement(const XMLNode& Node)
124
std::string NodeName=Node.getName();
126
if ("title"==NodeName)
128
RetVal=ProcessItem(Node,m_d->m_Title);
130
else if ("artist"==NodeName)
132
RetVal=ProcessItem(Node,m_d->m_Artist);
134
else if ("category"==NodeName)
136
RetVal=ProcessItem(Node,m_d->m_Category);
138
else if ("year"==NodeName)
140
RetVal=ProcessItem(Node,m_d->m_Year);
142
else if ("nonmb-track-list"==NodeName)
144
RetVal=ProcessItem(Node,m_d->m_NonMBTrackList);
148
std::cerr << "Unrecognised freedb disc element: '" << NodeName << "'" << std::endl;
155
std::string MusicBrainz4::CFreeDBDisc::GetElementName()
157
return "freedb-disc";
160
std::string MusicBrainz4::CFreeDBDisc::ID() const
165
std::string MusicBrainz4::CFreeDBDisc::Title() const
170
std::string MusicBrainz4::CFreeDBDisc::Artist() const
172
return m_d->m_Artist;
175
std::string MusicBrainz4::CFreeDBDisc::Category() const
177
return m_d->m_Category;
180
std::string MusicBrainz4::CFreeDBDisc::Year() const
185
MusicBrainz4::CNonMBTrackList *MusicBrainz4::CFreeDBDisc::NonMBTrackList() const
187
return m_d->m_NonMBTrackList;
190
std::ostream& MusicBrainz4::CFreeDBDisc::Serialise(std::ostream& os) const
192
os << "FreeDBDisc:" << std::endl;
194
CEntity::Serialise(os);
196
os << "\tID: " << ID() << std::endl;
197
os << "\tTitle: " << Title() << std::endl;
198
os << "\tArtist: " << Artist() << std::endl;
199
os << "\tCategory: " << Category() << std::endl;
200
os << "\tYear: " << Year() << std::endl;
202
if (NonMBTrackList())
203
os << *NonMBTrackList() << std::endl;