/**
 * File: iweardomerrorhandler.h
 * Created by: <Joern Reimerdes>
 * Created on: 
 * @file
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is a part of The iWear Framework.
 * In particular is this file a part of the Framework context Library
 *
 * The iWear Framework 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 as in version 2 of the License.

 * 
 * The iWear Framework 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
 * The iWear Framework; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __IWEAR_DOM_ERROR_HANDLER_H_
#define __IWEAR_DOM_ERROR_HANDLER_H_

#include <list>
#include <iwear/debugstream.h>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/dom/DOMError.hpp>
#include <xercesc/dom/DOMErrorHandler.hpp>

using namespace std;
using namespace iwear;
using namespace xercesc;

namespace iwear{ 
namespace xml{ 

/** The IWearDOMErrorHandler can be used for the errorhandling of a 
 * xercesc::DOMParser.
 * 
 */
class IWearDOMErrorHandler : public DOMErrorHandler
{
public:
	
    /** Creates a new IWearDOMErrorHandler.
     * 
     */
    IWearDOMErrorHandler();

    /** Destroys the IWearDOMErrorHandler.
     *
     */
    ~IWearDOMErrorHandler();

    /** This method implements the reaction how an error should be handled.
     * @note It overloads the virtual method inherited from
     *  the xercesc::DOMErrorHandler.
     * @param const DOMError& domError A reference to the error that
     *  should be handled.
     * @return True if the DOM implementation should continue
     *  parsing and false if the DOM implementation should stop.
     */
    bool handleError(const DOMError& domError);

    /** Returns a list with the last 100 errors that occurred.
     * @return list<const DOMError*> The error_list.
     */
    list<const DOMError*>* get_error_list(void);

protected:

    /** A list saving the last 100 errors that occurred.
     */
    list<const DOMError*>* error_list;
    
    /** The maximum number of saved errors. 
     * By default this is 100 (see constructor).
     */
    const uint32_t MAX_ERROR_ELEMENTS;

private:
    
    /** Adds an error to the error list.
     * @note Only the last 100 Errors are stored. Older Errors will be
     *  removed from the list.
     * @param const DOMError& domError a reference of the error that
     *  should be added to the list.
     * @return unit32_t The size of the error_list.
     */
    uint32_t add_error_to_list(const DOMError& domError);

}; // IWearDOMErrorHandler 
}  // xml
}  // iwear


#endif	//__IWEAR_DOM_ERROR_HANDLER_H_

