~ubuntu-branches/ubuntu/feisty/strigi/feisty-backports

« back to all changes in this revision

Viewing changes to src/daemon/xsd/xsd/cxx/xml/sax/bits/error-handler-proxy.hxx

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2006-11-12 19:23:58 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20061112192358-bopz8iu9cr8bosyc
Tags: 0.3.9-1
* New upstream release
* Remove patch to inotify support option, merged upstream
* Add poppler-utils and wv as Depends
* Include utils.mk to rules
* Add deepfind, deepgrep, luceneindexer and xmlindexer to
  strigi-daemon.install
* Update strigi-daemon.lintian-overrides for 0.3.9 version

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
5
 
 
6
 
#ifndef XSD_CXX_XML_SAX_ERROR_HANDLER_PROXY_HXX
7
 
#define XSD_CXX_XML_SAX_ERROR_HANDLER_PROXY_HXX
8
 
 
9
 
#include <xercesc/sax/ErrorHandler.hpp>
10
 
#include <xercesc/sax/SAXParseException.hpp>
11
 
 
12
 
#include <xsd/cxx/xml/error-handler.hxx>
13
 
 
14
 
namespace xsd
15
 
{
16
 
  namespace cxx
17
 
  {
18
 
    namespace xml
19
 
    {
20
 
      namespace sax
21
 
      {
22
 
        namespace bits
23
 
        {
24
 
          template <typename C>
25
 
          class error_handler_proxy: public xercesc::ErrorHandler
26
 
          {
27
 
          public:
28
 
            error_handler_proxy (error_handler<C>& eh)
29
 
                : failed_ (false), eh_ (&eh), native_eh_ (0)
30
 
            {
31
 
            }
32
 
 
33
 
            error_handler_proxy (xercesc::ErrorHandler& eh)
34
 
                : failed_ (false), eh_ (0), native_eh_ (&eh)
35
 
            {
36
 
            }
37
 
 
38
 
          public:
39
 
            virtual void
40
 
            warning (const xercesc::SAXParseException& e);
41
 
 
42
 
            virtual void
43
 
            error (const xercesc::SAXParseException& e);
44
 
 
45
 
            virtual void
46
 
            fatalError (const xercesc::SAXParseException& e);
47
 
 
48
 
          public:
49
 
            bool
50
 
            failed () const
51
 
            {
52
 
              return failed_;
53
 
            }
54
 
 
55
 
            virtual void
56
 
            resetErrors()
57
 
            {
58
 
              failed_ = false;
59
 
            }
60
 
 
61
 
          private:
62
 
            typedef typename error_handler<C>::severity severity;
63
 
 
64
 
            void
65
 
            handle (const xercesc::SAXParseException&, severity);
66
 
 
67
 
          private:
68
 
            bool failed_;
69
 
            error_handler<C>* eh_;
70
 
            xercesc::ErrorHandler* native_eh_;
71
 
          };
72
 
 
73
 
 
74
 
          template <typename C>
75
 
          void error_handler_proxy<C>::
76
 
          warning (const xercesc::SAXParseException& e)
77
 
          {
78
 
            if (native_eh_)
79
 
              native_eh_->warning (e);
80
 
            else
81
 
              handle (e, severity::warning);
82
 
          }
83
 
 
84
 
 
85
 
          template <typename C>
86
 
          void error_handler_proxy<C>::
87
 
          error (const xercesc::SAXParseException& e)
88
 
          {
89
 
            failed_ = true;
90
 
 
91
 
            if (native_eh_)
92
 
              native_eh_->error (e);
93
 
            else
94
 
              handle (e, severity::error);
95
 
          }
96
 
 
97
 
 
98
 
          template <typename C>
99
 
          void error_handler_proxy<C>::
100
 
          fatalError (const xercesc::SAXParseException& e)
101
 
          {
102
 
            failed_ = true;
103
 
 
104
 
            if (native_eh_)
105
 
              native_eh_->fatalError (e);
106
 
            else
107
 
              handle (e, severity::fatal);
108
 
          }
109
 
 
110
 
 
111
 
          template <typename C>
112
 
          void error_handler_proxy<C>::
113
 
          handle (const xercesc::SAXParseException& e, severity s)
114
 
          {
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.
118
 
            //
119
 
 
120
 
            const XMLCh* id (e.getPublicId ()
121
 
                             ? e.getPublicId ()
122
 
                             : e.getSystemId ());
123
 
 
124
 
            XMLSSize_t l (e.getLineNumber ());
125
 
            XMLSSize_t c (e.getColumnNumber ());
126
 
 
127
 
            eh_->handle (transcode<C> (id),
128
 
                         (l == -1 ? 0 : static_cast<unsigned long> (l)),
129
 
                         (c == -1 ? 0 : static_cast<unsigned long> (c)),
130
 
                         s,
131
 
                         transcode<C> (e.getMessage ()));
132
 
          }
133
 
        }
134
 
      }
135
 
    }
136
 
  }
137
 
}
138
 
 
139
 
#endif  // XSD_CXX_XML_SAX_ERROR_HANDLER_PROXY_HXX
140