~ubuntu-branches/ubuntu/quantal/libmusicbrainz/quantal

« back to all changes in this revision

Viewing changes to src/ISRC.cc

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2012-02-01 17:18:10 UTC
  • Revision ID: package-import@ubuntu.com-20120201171810-jzz90w51dx6shdr1
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* --------------------------------------------------------------------------
 
2
 
 
3
   libmusicbrainz4 - Client library to access MusicBrainz
 
4
 
 
5
   Copyright (C) 2011 Andrew Hawkins
 
6
 
 
7
   This file is part of libmusicbrainz4.
 
8
 
 
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.
 
12
 
 
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.
 
17
 
 
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/>.
 
20
 
 
21
     $Id: ISRC.cc 13259 2011-08-10 12:02:50Z adhawkins $
 
22
 
 
23
----------------------------------------------------------------------------*/
 
24
 
 
25
#include "musicbrainz4/ISRC.h"
 
26
 
 
27
#include "musicbrainz4/RecordingList.h"
 
28
#include "musicbrainz4/Recording.h"
 
29
 
 
30
class MusicBrainz4::CISRCPrivate
 
31
{
 
32
        public:
 
33
                CISRCPrivate()
 
34
                :       m_RecordingList(0)
 
35
                {
 
36
                }
 
37
 
 
38
                std::string m_ID;
 
39
                CRecordingList *m_RecordingList;
 
40
};
 
41
 
 
42
MusicBrainz4::CISRC::CISRC(const XMLNode& Node)
 
43
:       CEntity(),
 
44
        m_d(new CISRCPrivate)
 
45
{
 
46
        if (!Node.isEmpty())
 
47
        {
 
48
                //std::cout << "ISRC node: " << std::endl << Node.createXMLString(true) << std::endl;
 
49
 
 
50
                Parse(Node);
 
51
        }
 
52
}
 
53
 
 
54
MusicBrainz4::CISRC::CISRC(const CISRC& Other)
 
55
:       CEntity(),
 
56
        m_d(new CISRCPrivate)
 
57
{
 
58
        *this=Other;
 
59
}
 
60
 
 
61
MusicBrainz4::CISRC& MusicBrainz4::CISRC::operator =(const CISRC& Other)
 
62
{
 
63
        if (this!=&Other)
 
64
        {
 
65
                Cleanup();
 
66
 
 
67
                CEntity::operator =(Other);
 
68
 
 
69
                m_d->m_ID=Other.m_d->m_ID;
 
70
 
 
71
                if (Other.m_d->m_RecordingList)
 
72
                        m_d->m_RecordingList=new CRecordingList(*Other.m_d->m_RecordingList);
 
73
        }
 
74
 
 
75
        return *this;
 
76
}
 
77
 
 
78
MusicBrainz4::CISRC::~CISRC()
 
79
{
 
80
        Cleanup();
 
81
 
 
82
        delete m_d;
 
83
}
 
84
 
 
85
void MusicBrainz4::CISRC::Cleanup()
 
86
{
 
87
        delete m_d->m_RecordingList;
 
88
        m_d->m_RecordingList=0;
 
89
}
 
90
 
 
91
MusicBrainz4::CISRC *MusicBrainz4::CISRC::Clone()
 
92
{
 
93
        return new CISRC(*this);
 
94
}
 
95
 
 
96
bool MusicBrainz4::CISRC::ParseAttribute(const std::string& Name, const std::string& Value)
 
97
{
 
98
        bool RetVal=true;
 
99
 
 
100
        if ("id"==Name)
 
101
                m_d->m_ID=Value;
 
102
        else
 
103
        {
 
104
                std::cerr << "Unrecognised isrc attribute: '" << Name << "'" << std::endl;
 
105
                RetVal=false;
 
106
        }
 
107
 
 
108
        return RetVal;
 
109
}
 
110
 
 
111
bool MusicBrainz4::CISRC::ParseElement(const XMLNode& Node)
 
112
{
 
113
        bool RetVal=true;
 
114
 
 
115
        std::string NodeName=Node.getName();
 
116
 
 
117
        if ("recording-list"==NodeName)
 
118
        {
 
119
                RetVal=ProcessItem(Node,m_d->m_RecordingList);
 
120
        }
 
121
        else
 
122
        {
 
123
                std::cerr << "Unrecognised ISRC element: '" << NodeName << "'" << std::endl;
 
124
                RetVal=false;
 
125
        }
 
126
 
 
127
        return RetVal;
 
128
}
 
129
 
 
130
std::string MusicBrainz4::CISRC::GetElementName()
 
131
{
 
132
        return "isrc";
 
133
}
 
134
 
 
135
std::string MusicBrainz4::CISRC::ID() const
 
136
{
 
137
        return m_d->m_ID;
 
138
}
 
139
 
 
140
MusicBrainz4::CRecordingList *MusicBrainz4::CISRC::RecordingList() const
 
141
{
 
142
        return m_d->m_RecordingList;
 
143
}
 
144
 
 
145
std::ostream& MusicBrainz4::CISRC::Serialise(std::ostream& os) const
 
146
{
 
147
        os << "ISRC:" << std::endl;
 
148
 
 
149
        CEntity::Serialise(os);
 
150
 
 
151
        os << "\tID: " << ID() << std::endl;
 
152
 
 
153
        if (RecordingList())
 
154
                os << *RecordingList() << std::endl;
 
155
 
 
156
        return os;
 
157
}
 
158