Sophie

Sophie

distrib > Mandriva > 2011.0 > i586 > media > contrib-release-debug > by-pkgid > 0b102c0e3d0c39a3855aaf976204ce5c > files > 60

associationsubscribersmanager-debug-3.2.0-2mdv2011.0.i586.rpm


//  Copyright (C) 2009 by Arnaud Dupuis
//  a.dupuis@infinityperl.org
//  http://www.infinityperl.org
// 
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 3 of the License, or
//  (at your option) any later version.
// 
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
// 
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the
//  Free Software Foundation, Inc.,
//  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA

#ifndef FEDERATIONHANDLER_H
#define FEDERATIONHANDLER_H

#include <QXmlDefaultHandler>
#include <QList>
#include <QDebug>
/*! \class FederationLicenseFee
* \brief The federation abstraction.
*
* This class is the abstraction of a federation's license fee parsed from a .federation.xml file.
*/
class FederationLicenseFee {
	public:
		/*!
		Constructs a new FederationLicenseFee object.
		*/
		FederationLicenseFee(const QString & id="",const QString & name="", double fee=0.0 ){
// 			qDebug() << " ===> FederationLicenseFee : creating a new object with : " << id << name << fee;
			m_id = id;
			m_name = name;
			m_fee = fee;
		}
		/*!
		Returns the id of a license fee.
		*/
		QString getId(){ return m_id;}
		/*!
		Returns the name of a license fee.
		*/
		QString getName(){ return m_name; }
		/*!
		Returns the fee of a license fee.
		*/
		double getFee(){ return m_fee; }
		/*!
		Set  the id of a license fee.
		*/
		void setId(const QString & id){ m_id = id; }
		/*!
		Set the name of a license fee.
		*/
		void setName(const QString & name){ m_name = name; }
		/*!
		Set the fee of a license fee.
		*/
		void setFee(double fee){ m_fee = fee; }
	private:
		QString m_id;
		QString m_name;
		double m_fee;
		
};

class QString;
/*! \class FederationHandler
* \brief the XML handler for .federation.xml files.
*
* This class is the XML handler for federation description files.
*/
class FederationHandler : public QXmlDefaultHandler
{
	public:
		/*!
		Constructs a handler.
		*/
		FederationHandler();
		/*!
		The reader calls this function when it has parsed a start element tag.

		There is a corresponding endElement() call when the corresponding end element tag is read. The startElement() and endElement() calls are always nested correctly. Empty element tags (e.g. <x/>) cause a startElement() call to be immediately followed by an endElement() call.

		The attribute list provided only contains attributes with explicit values. The attribute list contains attributes used for namespace declaration (i.e. attributes starting with xmlns) only if the namespace-prefix property of the reader is true.

		The argument namespaceURI is the namespace URI, or an empty string if the element has no namespace URI or if no namespace processing is done. localName is the local name (without prefix), or an empty string if no namespace processing is done, qName is the qualified name (with prefix) and atts are the attributes attached to the element. If there are no attributes, atts is an empty attributes object.

		If this function returns false the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
		\sa endElement
		*/
		bool startElement( const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &attributes );
		/*!
		The reader calls this function when it has parsed an end element tag with the qualified name qName, the local name localName and the namespace URI namespaceURI.

		If this function returns false the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
		*/
		bool endElement( const QString &namespaceURI, const QString &localName, const QString &qName );
		/*!
		The reader calls this function when it has parsed a chunk of character data (either normal character data or character data inside a CDATA section; if you need to distinguish between those two types you must use QXmlLexicalHandler::startCDATA() and QXmlLexicalHandler::endCDATA()). The character data is reported in ch.

		If this function returns false the reader stops parsing and reports an error. The reader uses the function errorString() to get the error message.
		*/
		bool characters(const QString &str);
		/*!
		A reader must use this function to report a non-recoverable error. Details of the error are stored in exception.

		If this function returns true the reader might try to go on parsing and reporting further errors, but no regular parsing events are reported.
		*/
		bool fatalError(const QXmlParseException &exception);
		/*!
		Returns a QList which contains the licences parsed data as a FederationLicenseFee object.
		*/
		QList<FederationLicenseFee *> getLicenceFees();
	private:
		QString currentText;
		QList<FederationLicenseFee *> licences;
};


#endif