~logan/ubuntu/quantal/libmusicbrainz/new-upstream

« back to all changes in this revision

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