1 | // file : xsd/cxx/xml/sax/bits/error-handler-proxy.txx |
---|
2 | // author : Boris Kolpackov <boris@codesynthesis.com> |
---|
3 | // copyright : Copyright (c) 2005-2008 Code Synthesis Tools CC |
---|
4 | // license : GNU GPL v2 + exceptions; see accompanying LICENSE file |
---|
5 | |
---|
6 | #include <xsd/cxx/xml/string.hxx> |
---|
7 | |
---|
8 | namespace xsd |
---|
9 | { |
---|
10 | namespace cxx |
---|
11 | { |
---|
12 | namespace xml |
---|
13 | { |
---|
14 | namespace sax |
---|
15 | { |
---|
16 | namespace bits |
---|
17 | { |
---|
18 | template <typename C> |
---|
19 | void error_handler_proxy<C>:: |
---|
20 | warning (const xercesc::SAXParseException& e) |
---|
21 | { |
---|
22 | if (native_eh_) |
---|
23 | native_eh_->warning (e); |
---|
24 | else |
---|
25 | handle (e, severity::warning); |
---|
26 | } |
---|
27 | |
---|
28 | |
---|
29 | template <typename C> |
---|
30 | void error_handler_proxy<C>:: |
---|
31 | error (const xercesc::SAXParseException& e) |
---|
32 | { |
---|
33 | failed_ = true; |
---|
34 | |
---|
35 | if (native_eh_) |
---|
36 | native_eh_->error (e); |
---|
37 | else |
---|
38 | handle (e, severity::error); |
---|
39 | } |
---|
40 | |
---|
41 | |
---|
42 | template <typename C> |
---|
43 | void error_handler_proxy<C>:: |
---|
44 | fatalError (const xercesc::SAXParseException& e) |
---|
45 | { |
---|
46 | failed_ = true; |
---|
47 | |
---|
48 | if (native_eh_) |
---|
49 | native_eh_->fatalError (e); |
---|
50 | else |
---|
51 | handle (e, severity::fatal); |
---|
52 | } |
---|
53 | |
---|
54 | |
---|
55 | template <typename C> |
---|
56 | void error_handler_proxy<C>:: |
---|
57 | handle (const xercesc::SAXParseException& e, severity s) |
---|
58 | { |
---|
59 | //@@ I do not honor return values from the handler. This |
---|
60 | // is not too bad at the moment because I set |
---|
61 | // all-errors-are-fatal flag on the parser. |
---|
62 | // |
---|
63 | const XMLCh* id (e.getPublicId ()); |
---|
64 | |
---|
65 | if (id == 0) |
---|
66 | id = e.getSystemId (); |
---|
67 | |
---|
68 | XMLSSize_t l (e.getLineNumber ()); |
---|
69 | XMLSSize_t c (e.getColumnNumber ()); |
---|
70 | |
---|
71 | eh_->handle (transcode<C> (id), |
---|
72 | (l == -1 ? 0 : static_cast<unsigned long> (l)), |
---|
73 | (c == -1 ? 0 : static_cast<unsigned long> (c)), |
---|
74 | s, |
---|
75 | transcode<C> (e.getMessage ())); |
---|
76 | } |
---|
77 | } |
---|
78 | } |
---|
79 | } |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|