/***************************************************************************
                          SIMPLY POWERFUL TOOLKIT (SPTK)
                          CXml.h  -  description
                             -------------------
    begin                : Sun May 22 2003
    based on the code    : Mikko Lahteenmaki <Laza@Flashmail.com>
    copyright            : (C) 2003-2006 by Alexey S.Parshin
    email                : alexeyp@gmail.com
 ***************************************************************************/

/***************************************************************************
   This library is free software; you can redistribute it and/or modify it 
   under the terms of the GNU Library General Public License as published by
   the Free Software Foundation; either version 2 of the License, or (at 
   your option) any later version.

   This library 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 Library
   General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; if not, write to the Free Software Foundation, 
   Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.

   Please report all bugs and problems to "alexeyp@gmail.com"
 ***************************************************************************/

#ifndef __CXML_H__
#define __CXML_H__

#include <sptk3/xml/CXmlDoc.h>
#include <sptk3/xml/CXmlNode.h>
#include <sptk3/xml/CXmlParser.h>
#include <sptk3/xml/CXmlTokenizer.h>

namespace sptk {

   /// @addtogroup XML
   /// @{

   /// XML extension error codes enumeration.
	enum ErrorCodes { 
		XML_NO_ERROR = 0,       /**< Operation success */
		XML_UNKNOWN,            /**< Unspecified or unknown error */
		XML_OPENTAG_EXPECTED,      /**< Expected an open tag literal '<' */
		XML_OPENTAG_CDATA_EXPECTED, /**< Expected a '<' or cdata */
		XML_CLOSETAG_EXPECTED,     /**< Expected a '>' closing tag literal */
		XML_PI_DOCTYPE_EXPECTED,   /**< Expected a processing instruction or doctype tag */
		XML_TAGNAME_EXPECTED,      /**< Expected a tag name after '<' or '</' */
		XML_COMMENT_START_EXPECTED,   /**< Starting '--' of comment expected after '!' */
		XML_COMMENT_END_MISSING,   /**< Ending '-->' missing */
		XML_SLASH_EXPECTED,        /**< Expected a '/' after closing tag literal '<' */
		XML_TAGNAME_MISMATCH,      /**< Tag name from start and end tag mismatch */
		XML_EQUAL_EXPECTED,        /**< Expected '=' after attribute name */
		XML_VALUE_EXPECTED         /**< Expected value after an '=' in attribute */
	};

   /// @brief XML exception
   ///
   /// Xml extension throws CXmlException type exceptions.
   /// You should catch always atleast these type of exceptions, when processing XML.
	class SP_EXPORT CXmlException : public std::exception {
		std::string     m_message; ///< Message text
	public:

      /// Constructs new exception
      /// @param error int, error code for error
      /// @param locator CXmlLocator *, XML locator for stream
		CXmlException(int error, CXmlLocator *locator);

      /// Destructor
		~CXmlException() throw() { }

      /// Returns human readable error string.
		const char *what() const throw() { return m_message.c_str(); }

      /// Return error string for given errorcode.
		static const char *error_string(int error);
	};
	/// @}
}
#endif
