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

« back to all changes in this revision

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