~ubuntu-branches/ubuntu/precise/libmusicbrainz/precise-updates

« back to all changes in this revision

Viewing changes to src/Attribute.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: Attribute.cc 13259 2011-08-10 12:02:50Z adhawkins $
 
22
 
 
23
----------------------------------------------------------------------------*/
 
24
 
 
25
#include "musicbrainz4/Attribute.h"
 
26
 
 
27
class MusicBrainz4::CAttributePrivate
 
28
{
 
29
        public:
 
30
                std::string m_Text;
 
31
};
 
32
 
 
33
MusicBrainz4::CAttribute::CAttribute(const XMLNode& Node)
 
34
:       CEntity(),
 
35
        m_d(new CAttributePrivate)
 
36
{
 
37
        if (!Node.isEmpty())
 
38
        {
 
39
                //std::cout << "Attribute node: " << std::endl << Node.createXMLString(true) << std::endl;
 
40
 
 
41
                Parse(Node);
 
42
 
 
43
                if (Node.getText())
 
44
                        ProcessItem(Node,m_d->m_Text);
 
45
        }
 
46
}
 
47
 
 
48
MusicBrainz4::CAttribute::CAttribute(const CAttribute& Other)
 
49
:       CEntity(),
 
50
        m_d(new CAttributePrivate)
 
51
{
 
52
        *this=Other;
 
53
}
 
54
 
 
55
MusicBrainz4::CAttribute& MusicBrainz4::CAttribute::operator =(const CAttribute& Other)
 
56
{
 
57
        if (this!=&Other)
 
58
        {
 
59
                CEntity::operator =(Other);
 
60
 
 
61
                m_d->m_Text=Other.m_d->m_Text;
 
62
        }
 
63
 
 
64
        return *this;
 
65
}
 
66
 
 
67
MusicBrainz4::CAttribute::~CAttribute()
 
68
{
 
69
        delete m_d;
 
70
}
 
71
 
 
72
MusicBrainz4::CAttribute *MusicBrainz4::CAttribute::Clone()
 
73
{
 
74
        return new CAttribute(*this);
 
75
}
 
76
 
 
77
bool MusicBrainz4::CAttribute::ParseAttribute(const std::string& Name, const std::string& /*Value*/)
 
78
{
 
79
        bool RetVal=true;
 
80
 
 
81
        std::cerr << "Unrecognised attribute attribute: '" << Name << "'" << std::endl;
 
82
        RetVal=false;
 
83
 
 
84
        return RetVal;
 
85
}
 
86
 
 
87
bool MusicBrainz4::CAttribute::ParseElement(const XMLNode& Node)
 
88
{
 
89
        bool RetVal=true;
 
90
 
 
91
        std::string NodeName=Node.getName();
 
92
 
 
93
        std::cerr << "Unrecognised attribute element: '" << NodeName << "'" << std::endl;
 
94
        RetVal=false;
 
95
 
 
96
        return RetVal;
 
97
}
 
98
 
 
99
std::string MusicBrainz4::CAttribute::GetElementName()
 
100
{
 
101
        return "attribute";
 
102
}
 
103
 
 
104
std::string MusicBrainz4::CAttribute::Text() const
 
105
{
 
106
        return m_d->m_Text;
 
107
}
 
108
 
 
109
std::ostream& MusicBrainz4::CAttribute::Serialise(std::ostream& os) const
 
110
{
 
111
        os << "Attribute:" << std::endl;
 
112
 
 
113
        CEntity::Serialise(os);
 
114
 
 
115
        os << "\tText: " << Text() << std::endl;
 
116
 
 
117
        return os;
 
118
}
 
119
 
 
120