1
// file : xsd/cxx/xml/sax/error-handler-proxy.hxx
2
// author : Boris Kolpackov <boris@codesynthesis.com>
3
// copyright : Copyright (c) 2005-2006 Code Synthesis Tools CC
4
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
6
#ifndef XSD_CXX_XML_SAX_ERROR_HANDLER_PROXY_HXX
7
#define XSD_CXX_XML_SAX_ERROR_HANDLER_PROXY_HXX
9
#include <xercesc/sax/ErrorHandler.hpp>
10
#include <xercesc/sax/SAXParseException.hpp>
12
#include <xsd/cxx/xml/error-handler.hxx>
25
class error_handler_proxy: public xercesc::ErrorHandler
28
error_handler_proxy (error_handler<C>& eh)
29
: failed_ (false), eh_ (&eh), native_eh_ (0)
33
error_handler_proxy (xercesc::ErrorHandler& eh)
34
: failed_ (false), eh_ (0), native_eh_ (&eh)
40
warning (const xercesc::SAXParseException& e);
43
error (const xercesc::SAXParseException& e);
46
fatalError (const xercesc::SAXParseException& e);
62
typedef typename error_handler<C>::severity severity;
65
handle (const xercesc::SAXParseException&, severity);
69
error_handler<C>* eh_;
70
xercesc::ErrorHandler* native_eh_;
75
void error_handler_proxy<C>::
76
warning (const xercesc::SAXParseException& e)
79
native_eh_->warning (e);
81
handle (e, severity::warning);
86
void error_handler_proxy<C>::
87
error (const xercesc::SAXParseException& e)
92
native_eh_->error (e);
94
handle (e, severity::error);
99
void error_handler_proxy<C>::
100
fatalError (const xercesc::SAXParseException& e)
105
native_eh_->fatalError (e);
107
handle (e, severity::fatal);
111
template <typename C>
112
void error_handler_proxy<C>::
113
handle (const xercesc::SAXParseException& e, severity s)
115
//@@ I do not honor return values from the handler. This
116
// is not too bad at the moment because I set
117
// all-errors-are-fatal flag on the parser.
120
const XMLCh* id (e.getPublicId ()
124
XMLSSize_t l (e.getLineNumber ());
125
XMLSSize_t c (e.getColumnNumber ());
127
eh_->handle (transcode<C> (id),
128
(l == -1 ? 0 : static_cast<unsigned long> (l)),
129
(c == -1 ? 0 : static_cast<unsigned long> (c)),
131
transcode<C> (e.getMessage ()));
139
#endif // XSD_CXX_XML_SAX_ERROR_HANDLER_PROXY_HXX