/*********************************************************************
 * This file is part of the cpplibs suite.
 *
 * Copyright (C) 2001 Topi Mäenpää
 * All rights reserved.
 *
 * This program is free software. You can redistribute and/or modify
 * it under the terms of the free software licence found in the
 * accompanying file "COPYING". The licence terms must always be
 * redistributed with this source file. The above copyright notice
 * must be reproduced in all modified and unmodified copies of this
 * source file.
 *
 * $Revision$
 *********************************************************************/

#ifndef _XMLOBJECT_H
#define _XMLOBJECT_H

#include "XMLDocument.h"
#include "XMLException.h"

namespace util { namespace xml {

	/**
	 * XMLObject is an interface for classes that are able to read and
	 * create XML document structures.
	 **/
	class XMLObject : virtual public Object
	{
	public:
		/**
		 * Read an XML document structure. The implementing object should
		 * be able to restore its internal variables based on the
		 * infomation present in the document tree rooted at <i>node</i>.
		 * The default implementation throws an XMLException.
		 **/
		virtual void readXML(const Node* node) throw (XMLException&)
		{
			throw XMLException("XMLObject::readXML(): " + getClassName() + " can not read a document tree.");
		}

		/**
		 * Create an XML document structure out of the contents of the
		 * implementing object. The returned value should point to a newly
		 * created XML document node that is the root of the document
		 * structure. The default implementation throws an XMLException.
		 **/
		virtual Node* createXML() throw (XMLException&)
		{
			throw XMLException("XMLObject::createXML(): Cannot create a document tree for " + getClassName() + ".");
		}
	};
}}

#endif
