Line data Source code
1 : // file : xsd/cxx/tree/error-handler.hxx
2 : // copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC
3 : // license : GNU GPL v2 + exceptions; see accompanying LICENSE file
4 :
5 : #ifndef XSD_CXX_TREE_ERROR_HANDLER_HXX
6 : #define XSD_CXX_TREE_ERROR_HANDLER_HXX
7 :
8 : #include <xsd/cxx/xml/error-handler.hxx>
9 :
10 : #include <xsd/cxx/tree/exceptions.hxx>
11 :
12 : namespace xsd
13 : {
14 : namespace cxx
15 : {
16 : namespace tree
17 : {
18 : template <typename C>
19 : class error_handler: public xml::error_handler<C>
20 : {
21 : public:
22 : typedef typename xml::error_handler<C>::severity severity;
23 :
24 0 : error_handler ()
25 0 : : failed_ (false)
26 : {
27 0 : }
28 :
29 : virtual bool
30 : handle (const std::basic_string<C>& id,
31 : unsigned long line,
32 : unsigned long column,
33 : severity,
34 : const std::basic_string<C>& message);
35 :
36 : template <typename E>
37 : void
38 0 : throw_if_failed () const
39 : {
40 0 : if (failed_)
41 0 : throw E (diagnostics_);
42 0 : }
43 :
44 : void
45 : reset ()
46 : {
47 : failed_ = false;
48 : diagnostics_.clear ();
49 : }
50 :
51 : private:
52 : bool failed_;
53 : diagnostics<C> diagnostics_;
54 : };
55 : }
56 : }
57 : }
58 :
59 : #include <xsd/cxx/tree/error-handler.txx>
60 :
61 : #endif // XSD_CXX_TREE_ERROR_HANDLER_HXX
|