summaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/xml/error-handler.hxx
blob: a9c0c6f08c6387c1e6d536320e7b33e5cd39afc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// file      : xsd/cxx/xml/error-handler.hxx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

#ifndef XSD_CXX_XML_ERROR_HANDLER_HXX
#define XSD_CXX_XML_ERROR_HANDLER_HXX

#include <string>

namespace xsd
{
  namespace cxx
  {
    namespace xml
    {
      template <typename C>
      class error_handler
      {
      public:
        virtual
        ~error_handler ()
        {
        }

      public:

        // The fatal severity level results in termination
        // of the parsing process no matter what is returned
        // from handle.
        //
        struct severity
        {
          enum value
          {
            warning,
            error,
            fatal
          };

          severity (value v) : v_ (v) {}
          operator value () const { return v_; }

        private:
          value v_;
        };

        virtual bool
        handle (const std::basic_string<C>& id,
                unsigned long line,
                unsigned long column,
                severity,
                const std::basic_string<C>& message) = 0;
      };
    }
  }
}

#endif  // XSD_CXX_XML_ERROR_HANDLER_HXX