Blame src/TextRepresentation.cc

Packit f70c98
/* --------------------------------------------------------------------------
Packit f70c98
Packit f70c98
   libmusicbrainz5 - Client library to access MusicBrainz
Packit f70c98
Packit f70c98
   Copyright (C) 2012 Andrew Hawkins
Packit f70c98
Packit f70c98
   This file is part of libmusicbrainz5.
Packit f70c98
Packit f70c98
   This library is free software; you can redistribute it and/or
Packit f70c98
   modify it under the terms of the GNU Lesser General Public
Packit f70c98
   License as published by the Free Software Foundation; either
Packit f70c98
   version 2.1 of the License, or (at your option) any later version.
Packit f70c98
Packit f70c98
   libmusicbrainz5 is distributed in the hope that it will be useful,
Packit f70c98
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit f70c98
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit f70c98
   Lesser General Public License for more details.
Packit f70c98
Packit f70c98
   You should have received a copy of the GNU General Public License
Packit f70c98
   along with this library.  If not, see <http://www.gnu.org/licenses/>.
Packit f70c98
Packit f70c98
     $Id$
Packit f70c98
Packit f70c98
----------------------------------------------------------------------------*/
Packit f70c98
Packit f70c98
#include "config.h"
Packit f70c98
#include "musicbrainz5/defines.h"
Packit f70c98
Packit f70c98
#include "musicbrainz5/TextRepresentation.h"
Packit f70c98
Packit f70c98
class MusicBrainz5::CTextRepresentationPrivate
Packit f70c98
{
Packit f70c98
	public:
Packit f70c98
		std::string m_Language;
Packit f70c98
		std::string m_Script;
Packit f70c98
};
Packit f70c98
Packit f70c98
MusicBrainz5::CTextRepresentation::CTextRepresentation(const XMLNode& Node)
Packit f70c98
:	CEntity(),
Packit f70c98
	m_d(new CTextRepresentationPrivate)
Packit f70c98
{
Packit f70c98
	if (!Node.isEmpty())
Packit f70c98
	{
Packit f70c98
		//std::cout << "Text representation node: " << std::endl << Node.createXMLString(true) << std::endl;
Packit f70c98
Packit f70c98
		Parse(Node);
Packit f70c98
	}
Packit f70c98
}
Packit f70c98
Packit f70c98
MusicBrainz5::CTextRepresentation::CTextRepresentation(const CTextRepresentation& Other)
Packit f70c98
:	CEntity(),
Packit f70c98
	m_d(new CTextRepresentationPrivate)
Packit f70c98
{
Packit f70c98
	*this=Other;
Packit f70c98
}
Packit f70c98
Packit f70c98
MusicBrainz5::CTextRepresentation& MusicBrainz5::CTextRepresentation::operator =(const CTextRepresentation& Other)
Packit f70c98
{
Packit f70c98
	if (this!=&Other)
Packit f70c98
	{
Packit f70c98
		CEntity::operator =(Other);
Packit f70c98
Packit f70c98
		m_d->m_Language=Other.m_d->m_Language;
Packit f70c98
		m_d->m_Script=Other.m_d->m_Script;
Packit f70c98
	}
Packit f70c98
Packit f70c98
	return *this;
Packit f70c98
}
Packit f70c98
Packit f70c98
MusicBrainz5::CTextRepresentation::~CTextRepresentation()
Packit f70c98
{
Packit f70c98
	delete m_d;
Packit f70c98
}
Packit f70c98
Packit f70c98
MusicBrainz5::CTextRepresentation *MusicBrainz5::CTextRepresentation::Clone()
Packit f70c98
{
Packit f70c98
	return new CTextRepresentation(*this);
Packit f70c98
}
Packit f70c98
Packit f70c98
void MusicBrainz5::CTextRepresentation::ParseAttribute(const std::string& Name, const std::string& /*Value*/)
Packit f70c98
{
Packit Service 1b21de
#ifdef _MB5_DEBUG_
Packit f70c98
	std::cerr << "Unrecognised textrepresentation attribute: '" << Name << "'" << std::endl;
Packit Service 1b21de
#else
Packit Service 1b21de
	(void)Name;
Packit Service 1b21de
#endif
Packit f70c98
}
Packit f70c98
Packit f70c98
void MusicBrainz5::CTextRepresentation::ParseElement(const XMLNode& Node)
Packit f70c98
{
Packit f70c98
	std::string NodeName=Node.getName();
Packit f70c98
Packit f70c98
	if ("language"==NodeName)
Packit f70c98
	{
Packit f70c98
		ProcessItem(Node,m_d->m_Language);
Packit f70c98
	}
Packit f70c98
	else if ("script"==NodeName)
Packit f70c98
	{
Packit f70c98
		ProcessItem(Node,m_d->m_Script);
Packit f70c98
	}
Packit f70c98
	else
Packit f70c98
	{
Packit Service 1b21de
#ifdef _MB5_DEBUG_
Packit f70c98
		std::cerr << "Unrecognised textrepresentation element: '" << NodeName << "'" << std::endl;
Packit Service 1b21de
#endif
Packit f70c98
	}
Packit f70c98
}
Packit f70c98
Packit f70c98
std::string MusicBrainz5::CTextRepresentation::GetElementName()
Packit f70c98
{
Packit f70c98
	return "text-representation";
Packit f70c98
}
Packit f70c98
Packit f70c98
std::string MusicBrainz5::CTextRepresentation::Language() const
Packit f70c98
{
Packit f70c98
	return m_d->m_Language;
Packit f70c98
}
Packit f70c98
Packit f70c98
std::string MusicBrainz5::CTextRepresentation::Script() const
Packit f70c98
{
Packit f70c98
	return m_d->m_Script;
Packit f70c98
}
Packit f70c98
Packit f70c98
std::ostream& MusicBrainz5::CTextRepresentation::Serialise(std::ostream& os) const
Packit f70c98
{
Packit f70c98
	os << "\tText Representation:" << std::endl;
Packit f70c98
Packit f70c98
	CEntity::Serialise(os);
Packit f70c98
Packit f70c98
	os << "\t\tLanguage: " << Language() << std::endl;
Packit f70c98
	os << "\t\tScript:   " << Script() << std::endl;
Packit f70c98
Packit f70c98
	return os;
Packit f70c98
}
Packit f70c98